Skip to content

Commit

Permalink
Handle errors with try-catch rather than returning an int.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchapman committed Nov 22, 2023
1 parent ca25cf0 commit 7d201b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/bout/coordinates.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public:
void calcCovariant(const std::string& region = "RGN_ALL");
/// Invert covariant metric to get contravariant components
void calcContravariant(const std::string& region = "RGN_ALL");
int jacobian(); ///< Calculate J and Bxy
void jacobian(); ///< Calculate J and Bxy
void CalculateChristoffelSymbols(); /// Calculate Christoffel symbol terms

///////////////////////////////////////////////////////////
Expand Down
17 changes: 9 additions & 8 deletions src/mesh/coordinates.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,7 @@ Coordinates::Coordinates(Mesh* mesh, Options* options, const CELL_LOC loc,
checkCovariant();

/// Calculate Jacobian and Bxy
if (jacobian()) {
throw BoutException("Error in jacobian call");
}
jacobian();

// Attempt to read J from the grid file
auto Jcalc = this_J;
Expand Down Expand Up @@ -1161,12 +1159,15 @@ void Coordinates::calcContravariant(const std::string& region) {
covariantMetricTensor.oppositeRepresentation(location, localmesh, region));
}

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

this_J = recalculateJacobian();
this_Bxy = recalculateBxy();
return 0;
try {
this_J = recalculateJacobian();
this_Bxy = recalculateBxy();
} catch (BoutException&) {
output_error.write("\tError in jacobian call\n");
throw;
}
}

MetricTensor::FieldMetric Coordinates::recalculateJacobian() {
Expand Down

0 comments on commit 7d201b2

Please sign in to comment.