Skip to content

Commit

Permalink
Use applyToComponents() method with covariantMetricTensor, to further…
Browse files Browse the repository at this point in the history
… DRY up the code.
  • Loading branch information
tomchapman committed Nov 22, 2023
1 parent 9a32de4 commit 24a2897
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions src/mesh/coordinates.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -471,30 +471,14 @@ Coordinates::Coordinates(Mesh* mesh, Options* options, const CELL_LOC loc,
};

std::basic_string<char> region = std::basic_string("RGN_NOBNDRY");
const auto new_metric_tensor = coords_in->contravariantMetricTensor.applyToComponents(
interpolateAndExtrapolate_function);
setContravariantMetricTensor(new_metric_tensor, region);

FieldMetric g_11, g_22, g_33, g_12, g_13, g_23;
// 3x3 matrix inversion can exaggerate small interpolation errors, so it is
// more robust to interpolate and extrapolate derived quantities directly,
// rather than deriving from interpolated/extrapolated covariant metric
// components
g_11 = interpolateAndExtrapolate(covariantMetricTensor.Getg11(), location, true, true,
false, transform.get());
g_22 = interpolateAndExtrapolate(covariantMetricTensor.Getg22(), location, true, true,
false, transform.get());
g_33 = interpolateAndExtrapolate(covariantMetricTensor.Getg33(), location, true, true,
false, transform.get());
g_12 = interpolateAndExtrapolate(covariantMetricTensor.Getg12(), location, true, true,
false, transform.get());
g_13 = interpolateAndExtrapolate(covariantMetricTensor.Getg13(), location, true, true,
false, transform.get());
g_23 = interpolateAndExtrapolate(covariantMetricTensor.Getg23(), location, true, true,
false, transform.get());

covariantMetricTensor.setMetricTensor(
MetricTensor(g_11, g_22, g_33, g_12, g_13, g_23));
const auto new_contravariant_metric_tensor =
coords_in->contravariantMetricTensor.applyToComponents(
interpolateAndExtrapolate_function);
setContravariantMetricTensor(new_contravariant_metric_tensor, region);

const auto new_covariant_metric_tensor =
covariantMetricTensor.applyToComponents(interpolateAndExtrapolate_function);
covariantMetricTensor.setMetricTensor(new_covariant_metric_tensor);

// Check input metrics
checkContravariant();
Expand Down

0 comments on commit 24a2897

Please sign in to comment.