Skip to content

Commit 42dc6ee

Browse files
committed
Inline some single-use functions
1 parent 61196bf commit 42dc6ee

2 files changed

Lines changed: 22 additions & 47 deletions

File tree

include/bout/coordinates.hxx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,6 @@ private:
450450

451451
FieldMetric Bxy_; ///< Magnitude of B = nabla z times nabla x
452452

453-
void invalidateAndRecalculateCachedVariables();
454-
455453
/// Set the parallel (y) transform from the options file.
456454
/// Used in the constructor to create the transform object.
457455
void setParallelTransform(Options* options);
@@ -468,10 +466,6 @@ private:
468466

469467
FieldMetric getUnaligned(const std::string& name, BoutReal default_value);
470468

471-
void extrapolateChristoffelSymbols();
472-
473-
void extrapolateGValues();
474-
475469
FieldMetric recalculateBxy() const;
476470

477471
/// Non-uniform meshes. Need to use DDX, DDY

src/mesh/coordinates.cxx

Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -797,12 +797,7 @@ void Coordinates::recalculateAndReset(bool recalculate_staggered,
797797
checkCovariant();
798798

799799
christoffel_symbols_cache.reset();
800-
christoffel_symbols();
801-
extrapolateChristoffelSymbols();
802-
803800
g_values_cache.reset();
804-
g_values();
805-
extrapolateGValues();
806801

807802
correctionForNonUniformMeshes(force_interpolate_from_centre);
808803

@@ -811,7 +806,9 @@ void Coordinates::recalculateAndReset(bool recalculate_staggered,
811806
localmesh->recalculateStaggeredCoordinates();
812807
}
813808

814-
invalidateAndRecalculateCachedVariables();
809+
zlength_cache.reset();
810+
Grad2_par2_DDY_invSgCache.clear();
811+
invSgCache.reset();
815812
}
816813

817814
void Coordinates::correctionForNonUniformMeshes(bool force_interpolate_from_centre) {
@@ -889,35 +886,6 @@ void Coordinates::correctionForNonUniformMeshes(bool force_interpolate_from_cent
889886
localmesh->communicate(d1_dx_, d1_dy_, d1_dz_);
890887
}
891888

892-
void Coordinates::extrapolateChristoffelSymbols() {
893-
894-
// Set boundary guard cells of Christoffel symbol terms
895-
// Ideally, when location is staggered, we would set the upper/outer boundary point
896-
// correctly rather than by extrapolating here: e.g. if location==CELL_YLOW and we are
897-
// at the upper y-boundary the x- and z-derivatives at yend+1 at the boundary can be
898-
// calculated because the guard cells are available, while the y-derivative could be
899-
// calculated from the CELL_CENTRE metric components (which have guard cells available
900-
// past the boundary location). This would avoid the problem that the y-boundary on the
901-
// CELL_YLOW grid is at a 'guard cell' location (yend+1).
902-
// However, the above would require lots of special handling, so just extrapolate for
903-
// now.
904-
905-
std::function<const FieldMetric(const FieldMetric)> const
906-
interpolateAndExtrapolate_function = [this](const FieldMetric& component) {
907-
return interpolateAndExtrapolate(component, location, true, true, false,
908-
transform.get());
909-
};
910-
911-
christoffel_symbols().map(interpolateAndExtrapolate_function);
912-
}
913-
914-
void Coordinates::extrapolateGValues() {
915-
g_values().map([this](const FieldMetric& component) {
916-
return interpolateAndExtrapolate(component, location, true, true, true,
917-
transform.get());
918-
});
919-
}
920-
921889
MetricTensor::FieldMetric Coordinates::recalculateJacobian() const {
922890

923891
TRACE("Coordinates::jacobian");
@@ -1451,13 +1419,32 @@ Field2D Coordinates::Laplace_perpXY([[maybe_unused]] const Field2D& A,
14511419
ChristoffelSymbols& Coordinates::christoffel_symbols() {
14521420
if (christoffel_symbols_cache == nullptr) {
14531421
christoffel_symbols_cache = std::make_unique<ChristoffelSymbols>(*this);
1422+
// Set boundary guard cells of Christoffel symbol terms
1423+
// Ideally, when location is staggered, we would set the upper/outer boundary point
1424+
// correctly rather than by extrapolating here: e.g. if location==CELL_YLOW and we are
1425+
// at the upper y-boundary the x- and z-derivatives at yend+1 at the boundary can be
1426+
// calculated because the guard cells are available, while the y-derivative could be
1427+
// calculated from the CELL_CENTRE metric components (which have guard cells available
1428+
// past the boundary location). This would avoid the problem that the y-boundary on the
1429+
// CELL_YLOW grid is at a 'guard cell' location (yend+1).
1430+
// However, the above would require lots of special handling, so just extrapolate for
1431+
// now.
1432+
1433+
christoffel_symbols_cache->map([this](const FieldMetric& component) {
1434+
return interpolateAndExtrapolate(component, location, true, true, false,
1435+
transform.get());
1436+
});
14541437
}
14551438
return *christoffel_symbols_cache;
14561439
}
14571440

14581441
GValues& Coordinates::g_values() const {
14591442
if (g_values_cache == nullptr) {
14601443
g_values_cache = std::make_unique<GValues>(*this);
1444+
g_values_cache->map([this](const FieldMetric& component) {
1445+
return interpolateAndExtrapolate(component, location, true, true, true,
1446+
transform.get());
1447+
});
14611448
}
14621449
return *g_values_cache;
14631450
}
@@ -1542,9 +1529,3 @@ void Coordinates::setMetricTensor(
15421529
contravariantMetricTensor.setMetricTensor(contravariant_metric_tensor);
15431530
covariantMetricTensor.setMetricTensor(covariant_metric_tensor);
15441531
}
1545-
1546-
void Coordinates::invalidateAndRecalculateCachedVariables() {
1547-
zlength_cache.reset();
1548-
Grad2_par2_DDY_invSgCache.clear();
1549-
invSgCache.reset();
1550-
}

0 commit comments

Comments
 (0)