Skip to content

Commit

Permalink
Remove calls to calcCovariant() and calcContravariant() since they ar…
Browse files Browse the repository at this point in the history
…e now calculated when calling setContravariantMetricTensor() and setCovariantMetricTensor().
  • Loading branch information
tomchapman committed Dec 5, 2023
1 parent 1412aaa commit 935c061
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 51 deletions.
6 changes: 0 additions & 6 deletions include/bout/coordinates.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,6 @@ public:
/// Calculate differential geometry quantities from the metric tensor
int calculateGeometry();

/// Invert contravariant metric to get covariant components
void calcCovariant(const std::string& region = "RGN_ALL");

/// Invert covariant metric to get contravariant components
void calcContravariant(const std::string& region = "RGN_ALL");

void jacobian(); ///< Calculate J and Bxy

///////////////////////////////////////////////////////////
Expand Down
6 changes: 0 additions & 6 deletions include/bout/geometry.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@ public:

void setBxy(FieldMetric Bxy);

/// Invert contravariant metric to get covariant components
void calcCovariant(const std::string& region = "RGN_ALL");

/// Invert covariant metric to get contravariant components
void calcContravariant(const std::string& region = "RGN_ALL");

/// Calculate Christoffel symbol terms
void CalculateChristoffelSymbols(FieldMetric& dx, FieldMetric& dy);

Expand Down
23 changes: 0 additions & 23 deletions src/mesh/coordinates.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -493,19 +493,6 @@ void Coordinates::setBoundaryCells(Mesh* mesh, Options* options,
} else {
output_warn.write("Not all covariant components of metric tensor found. "
"Calculating all from the contravariant tensor\n");
/// Calculate contravariant metric components if not found
try {
calcCovariant("RGN_NOCORNERS");
} catch (BoutException&) {
throw BoutException("Error in calcCovariant call");
}
}
} else {
/// Calculate contravariant metric components if not found
try {
calcCovariant("RGN_NOCORNERS");
} catch (BoutException&) {
throw BoutException("Error in calcCovariant call");
}
}

Expand Down Expand Up @@ -794,16 +781,6 @@ void Coordinates::calculateCommunicateAndExtrapolateChristoffelSymbols() {
geometry.applyToChristoffelSymbols(interpolateAndExtrapolate_function);
}

void Coordinates::calcCovariant(const std::string& region) {
TRACE("Coordinates::calcCovariant");
geometry.calcCovariant(region);
}

void Coordinates::calcContravariant(const std::string& region) {
TRACE("Coordinates::calcContravariant");
geometry.calcContravariant(region);
}

void Coordinates::jacobian() {
TRACE("Coordinates::jacobian");

Expand Down
10 changes: 0 additions & 10 deletions src/mesh/geometry.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,6 @@ void Geometry::CalculateChristoffelSymbols(FieldMetric& dx, FieldMetric& dy) {
* differential_operators->DDY(covariantMetricTensor.Getg33(), dy);
}

void Geometry::calcCovariant(const std::string& region) {
TRACE("Geometry::calcCovariant");
covariantMetricTensor.setMetricTensor(contravariantMetricTensor.inverse(region));
}

void Geometry::calcContravariant(const std::string& region) {
TRACE("Geometry::calcContravariant");
contravariantMetricTensor.setMetricTensor(covariantMetricTensor.inverse(region));
}

MetricTensor::FieldMetric Geometry::recalculateJacobian() {

// calculate Jacobian using g^-1 = det[g^ij], J = sqrt(g)
Expand Down
8 changes: 2 additions & 6 deletions tests/unit/mesh/test_coordinates.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ TEST_F(CoordinatesTest, CalcContravariant) {
FieldMetric{0.0}}; // IntShiftTorsion
// No call to Coordinates::calculateGeometry() needed here

output_info.disable();
coords.calcCovariant();
output_info.enable();
coords.setContravariantMetricTensor(MetricTensor(1.0, 1.0, 1.0, 0.0, 0.0, 0.0));

EXPECT_TRUE(IsFieldEqual(coords.g_11(), 1.0));
EXPECT_TRUE(IsFieldEqual(coords.g_22(), 1.0));
Expand Down Expand Up @@ -174,9 +172,7 @@ TEST_F(CoordinatesTest, CalcCovariant) {
FieldMetric{0.0}}; // IntShiftTorsion
// No call to Coordinates::calculateGeometry() needed here

output_info.disable();
coords.calcContravariant();
output_info.enable();
coords.setCovariantMetricTensor(MetricTensor(1.0, 1.0, 1.0, 0.0, 0.0, 0.0));

EXPECT_TRUE(IsFieldEqual(coords.g11(), 1.0));
EXPECT_TRUE(IsFieldEqual(coords.g22(), 1.0));
Expand Down

0 comments on commit 935c061

Please sign in to comment.