Skip to content

Commit

Permalink
Fix "Make TokamakCoordinates a struct rather than a class"
Browse files Browse the repository at this point in the history
(Need to pass TokamakCoordinates to set_tokamak_coordinates_on_mesh(), now that it is a free function).
  • Loading branch information
tomchapman committed Jan 15, 2025
1 parent 6131033 commit 5fd7d45
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/6field-simple/elm_6f.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ class Elm_6f : public PhysicsModel {
}

/**************** CALCULATE METRICS ******************/
set_tokamak_coordinates_on_mesh(noshear, Lbar, Bbar);
set_tokamak_coordinates_on_mesh(tokamak_coordinates, noshear, Lbar, Bbar);

//////////////////////////////////////////////////////////////
// SHIFTED RADIAL COORDINATES
Expand Down
2 changes: 1 addition & 1 deletion examples/conducting-wall-mode/cwm.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class CWM : public PhysicsModel {
Te0 /= Te_x;

// Normalise geometry
set_tokamak_coordinates_on_mesh(noshear, rho_s, bmag / 1e4, ShearFactor);
set_tokamak_coordinates_on_mesh(tokamak_coordinates, noshear, rho_s, bmag / 1e4, ShearFactor);

// Set nu
nu = nu_hat * Ni0 / pow(Te0, 1.5);
Expand Down
2 changes: 1 addition & 1 deletion examples/constraints/alfven-wave/alfven.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class Alfven : public PhysicsModel {
}

auto tokamak_coordinates = TokamakCoordinates(*mesh);
set_tokamak_coordinates_on_mesh(noshear, Lnorm, Bnorm);
set_tokamak_coordinates_on_mesh(tokamak_coordinates, noshear, Lnorm, Bnorm);
}
};

Expand Down
2 changes: 1 addition & 1 deletion examples/dalf3/dalf3.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class DALF3 : public PhysicsModel {
b0xcv.z *= rho_s * rho_s;

// Metrics
set_tokamak_coordinates_on_mesh(noshear, rho_s, Bnorm);
set_tokamak_coordinates_on_mesh(tokamak_coordinates, noshear, rho_s, Bnorm);

SOLVE_FOR3(Vort, Pe, Vpar);
comms.add(Vort, Pe, Vpar);
Expand Down
2 changes: 1 addition & 1 deletion examples/gyro-gem/gem.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class GEM : public PhysicsModel {
Bbar = options["Bbar"].withDefault(Bbar); // Override in options file
SAVE_ONCE(Bbar);

set_tokamak_coordinates_on_mesh(true, Lbar, Bbar);
set_tokamak_coordinates_on_mesh(tokamak_coordinates, true, Lbar, Bbar);

beta_e = 4.e-7 * PI * max(p_e, true) / (Bbar * Bbar);
SAVE_ONCE(beta_e);
Expand Down
2 changes: 1 addition & 1 deletion examples/laplacexy/alfven-wave/alfven.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class Alfven : public PhysicsModel {
void LoadMetric(BoutReal Lnorm, BoutReal Bnorm) {

auto tokamak_coordinates = TokamakCoordinates(*mesh);
set_tokamak_coordinates_on_mesh(true, Lnorm, Bnorm);
set_tokamak_coordinates_on_mesh(tokamak_coordinates, true, Lnorm, Bnorm);
Coordinates* coord = mesh->getCoordinates(); // Metric tensor
}
};
Expand Down
2 changes: 1 addition & 1 deletion examples/laplacexy/laplace_perp/test.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int main(int argc, char** argv) {
calc_metric = Options::root()["calc_metric"].withDefault(false);
if (calc_metric) {
auto tokamak_coordinates = TokamakCoordinates(*mesh);
set_tokamak_coordinates_on_mesh(true, 1.0, 1.0);
set_tokamak_coordinates_on_mesh(tokamak_coordinates, true, 1.0, 1.0);
}

Coordinates* coord = mesh->getCoordinates();
Expand Down
5 changes: 3 additions & 2 deletions include/bout/tokamak_coordinates.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ BoutReal get_sign_of_bp(Field2D Bpxy) {
return 1.0;
}

void set_tokamak_coordinates_on_mesh(Mesh& mesh, const bool noshear, BoutReal Lbar,
BoutReal Bbar, BoutReal ShearFactor = 1.0) {
void
set_tokamak_coordinates_on_mesh(tokamak_coordinates, TokamakCoordinates &tokamakCoordinates, Mesh &mesh, const bool noshear, BoutReal Lbar,
BoutReal Bbar, BoutReal ShearFactor = 1.0) {

tokamakCoordinates.normalise(Lbar, Bbar, ShearFactor);

Expand Down
2 changes: 1 addition & 1 deletion tests/integrated/test-drift-instability/2fluid.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class TwoFluid : public PhysicsModel {
pei0 = (Ti0 + Te0) * Ni0;
pe0 = Te0 * Ni0;

set_tokamak_coordinates_on_mesh(noshear, rho_s, bmag / 1e4, ShearFactor);
set_tokamak_coordinates_on_mesh(tokamak_coordinates, noshear, rho_s, bmag / 1e4, ShearFactor);

/**************** SET EVOLVING VARIABLES *************/

Expand Down
2 changes: 1 addition & 1 deletion tests/integrated/test-interchange-instability/2fluid.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class Interchange : public PhysicsModel {
hthe0 / rho_s);
}

set_tokamak_coordinates_on_mesh(noshear, rho_s, bmag / 1e4, ShearFactor);
set_tokamak_coordinates_on_mesh(tokamak_coordinates, noshear, rho_s, bmag / 1e4, ShearFactor);

if (ShiftXderivs) {
b0xcv.z += tokamak_coordinates.ShearFactor * b0xcv.x;
Expand Down

0 comments on commit 5fd7d45

Please sign in to comment.