Skip to content

Commit

Permalink
Use version of getAtLoc method that returns a new value rather than u…
Browse files Browse the repository at this point in the history
…pdated the existing one.
  • Loading branch information
tomchapman committed Nov 25, 2023
1 parent 6999275 commit 0bec506
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/mesh/coordinates.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -523,12 +523,13 @@ Coordinates::Coordinates(Mesh* mesh, Options* options, const CELL_LOC loc,

// Attempt to read J from the grid file
auto Jcalc = J();
if (getAtLoc(mesh, this_J, "J", suffix, location)) {
try {
Jcalc = getAtLoc(mesh, "J", suffix, location);
output_warn.write(
"\tWARNING: Jacobian 'J_{:s}' not found. Calculating from metric tensor\n",
suffix);
setJ(Jcalc);
} else {
} catch (BoutException) {
setJ(localmesh->interpolateAndExtrapolate(J(), location, extrapolate_x,
extrapolate_y, false, transform.get()));

Expand All @@ -550,12 +551,13 @@ Coordinates::Coordinates(Mesh* mesh, Options* options, const CELL_LOC loc,

// Attempt to read Bxy from the grid file
auto Bcalc = Bxy();
if (getAtLoc(mesh, this_Bxy, "Bxy", suffix, location)) {
try {
Bcalc = getAtLoc(mesh, "Bxy", suffix, location);
output_warn.write("\tWARNING: Magnitude of B field 'Bxy_{:s}' not found. "
"Calculating from metric tensor\n",
suffix);
setBxy(Bcalc);
} else {
} catch (BoutException) {
setBxy(localmesh->interpolateAndExtrapolate(Bxy(), location, extrapolate_x,
extrapolate_y, false, transform.get()));
output_warn.write("\tMaximum difference in Bxy is {:e}\n", max(abs(Bxy() - Bcalc)));
Expand Down

0 comments on commit 0bec506

Please sign in to comment.