Skip to content

Commit

Permalink
Assuming that all the metric tensor components have the same mesh, an…
Browse files Browse the repository at this point in the history
…d that covariant and contravariant components have the same mesh.
  • Loading branch information
tomchapman committed Nov 24, 2023
1 parent 5f782fd commit cb163cf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ coverage/
/_version.txt
/.idea
/cmake-build-debug
/cmake-build-debug-wsl
2 changes: 1 addition & 1 deletion include/bout/metricTensor.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public:

void setLocation(const CELL_LOC location);

MetricTensor oppositeRepresentation(const CELL_LOC location, Mesh* mesh,
MetricTensor oppositeRepresentation(const CELL_LOC location,
const std::string& region = "RGN_ALL");

// Transforms the MetricTensor by applying the given function to every component
Expand Down
8 changes: 4 additions & 4 deletions src/mesh/coordinates.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1151,13 +1151,13 @@ void Coordinates::CalculateChristoffelSymbols() {
void Coordinates::calcCovariant(const std::string& region) {
TRACE("Coordinates::calcCovariant");
covariantMetricTensor.setMetricTensor(
contravariantMetricTensor.oppositeRepresentation(location, localmesh, region));
contravariantMetricTensor.oppositeRepresentation(location, region));
}

void Coordinates::calcContravariant(const std::string& region) {
TRACE("Coordinates::calcContravariant");
contravariantMetricTensor.setMetricTensor(
covariantMetricTensor.oppositeRepresentation(location, localmesh, region));
covariantMetricTensor.oppositeRepresentation(location, region));
}

void Coordinates::jacobian() {
Expand Down Expand Up @@ -1792,14 +1792,14 @@ void Coordinates::setContravariantMetricTensor(MetricTensor metric_tensor,
const std::string& region) {
contravariantMetricTensor.setMetricTensor(metric_tensor);
covariantMetricTensor.setMetricTensor(
contravariantMetricTensor.oppositeRepresentation(location, localmesh, region));
contravariantMetricTensor.oppositeRepresentation(location, region));
}

void Coordinates::setCovariantMetricTensor(MetricTensor metric_tensor,
const std::string& region) {
covariantMetricTensor.setMetricTensor(metric_tensor);
contravariantMetricTensor.setMetricTensor(
covariantMetricTensor.oppositeRepresentation(location, localmesh, region));
covariantMetricTensor.oppositeRepresentation(location, region));
}

const MetricTensor::FieldMetric& Coordinates::g_11() const {
Expand Down
4 changes: 2 additions & 2 deletions src/mesh/metricTensor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void MetricTensor::setLocation(const CELL_LOC location) {
g23.setLocation(location);
}

MetricTensor MetricTensor::oppositeRepresentation(CELL_LOC location, Mesh* mesh,
MetricTensor MetricTensor::oppositeRepresentation(CELL_LOC location,
const std::string& region) {

TRACE("MetricTensor::CalculateOppositeRepresentation");
Expand Down Expand Up @@ -164,7 +164,7 @@ MetricTensor MetricTensor::oppositeRepresentation(CELL_LOC location, Mesh* mesh,
// + g_23 * g_33)));
//
// output_info.write("\tMaximum error in off-diagonal inversion is {:e}\n", maxerr);

const auto mesh = g11.getMesh(); // All the components have the same mesh
auto other_representation = MetricTensor(g_11, g_22, g_33, g_12, g_13, g_23, mesh);
other_representation.setLocation(location);
return other_representation;
Expand Down

0 comments on commit cb163cf

Please sign in to comment.