From d08ecf9425e0758df2fd3502f709191dc87de316 Mon Sep 17 00:00:00 2001 From: tomc271 Date: Wed, 15 Jan 2025 14:56:10 +0000 Subject: [PATCH] Rename struct TokamakCoordinates to TokamakOptions --- examples/6field-simple/elm_6f.cxx | 22 +-- examples/conducting-wall-mode/cwm.cxx | 12 +- examples/constraints/alfven-wave/alfven.cxx | 4 +- examples/dalf3/dalf3.cxx | 6 +- .../elm-pb-outerloop/elm_pb_outerloop.cxx | 26 ++-- examples/elm-pb/elm_pb.cxx | 126 +++++++++--------- examples/gyro-gem/gem.cxx | 6 +- examples/laplacexy/alfven-wave/alfven.cxx | 4 +- examples/laplacexy/laplace_perp/test.cxx | 4 +- examples/wave-slab/wave_slab.cxx | 4 +- include/bout/coordinates.hxx | 4 +- include/bout/tokamak_coordinates.hxx | 44 +++--- tests/MMS/GBS/gbs.cxx | 4 +- tests/MMS/elm-pb/elm_pb.cxx | 6 +- tests/MMS/tokamak/tokamak.cxx | 4 +- .../test-drift-instability/2fluid.cxx | 6 +- .../test-interchange-instability/2fluid.cxx | 6 +- .../integrated/test-laplacexy/loadmetric.cxx | 4 +- 18 files changed, 146 insertions(+), 146 deletions(-) diff --git a/examples/6field-simple/elm_6f.cxx b/examples/6field-simple/elm_6f.cxx index 65365f8d9f..2834c0f424 100644 --- a/examples/6field-simple/elm_6f.cxx +++ b/examples/6field-simple/elm_6f.cxx @@ -235,7 +235,7 @@ class Elm_6f : public PhysicsModel { int damp_width; // Width of inner damped region BoutReal damp_t_const; // Timescale of damping - TokamakCoordinates tokamak_coordinates = TokamakCoordinates(*mesh); + TokamakOptions tokamak_options = TokamakOptions(*mesh); BoutReal LnLambda; // ln(Lambda) @@ -366,7 +366,7 @@ class Elm_6f : public PhysicsModel { result = Grad_par(f, loc); if (nonlinear) { - result -= bracket(Psi, f, bm_mag) * tokamak_coordinates.Bxy; + result -= bracket(Psi, f, bm_mag) * tokamak_options.Bxy; } } @@ -681,7 +681,7 @@ class Elm_6f : public PhysicsModel { if (noshear) { if (include_curvature) { - b0xcv.z += tokamak_coordinates.ShearFactor * b0xcv.x; + b0xcv.z += tokamak_options.ShearFactor * b0xcv.x; } } @@ -691,7 +691,7 @@ class Elm_6f : public PhysicsModel { if (not mesh->IncIntShear) { // Dimits style, using local coordinate system if (include_curvature) { - b0xcv.z += tokamak_coordinates.ShearFactor * b0xcv.x; + b0xcv.z += tokamak_options.ShearFactor * b0xcv.x; } } @@ -835,11 +835,11 @@ class Elm_6f : public PhysicsModel { dump.add(sp_length, "sp_length", 1); } - auto Bpxy = tokamak_coordinates.Bpxy; - auto hthe = tokamak_coordinates.hthe; - auto Rxy = tokamak_coordinates.Rxy; - auto Btxy = tokamak_coordinates.Btxy; - auto B0 = tokamak_coordinates.Bxy; + auto Bpxy = tokamak_options.Bpxy; + auto hthe = tokamak_options.hthe; + auto Rxy = tokamak_options.Rxy; + auto Btxy = tokamak_options.Btxy; + auto B0 = tokamak_options.Bxy; J0 = SI::mu0 * Lbar * J0 / B0; P0 = P0 / (SI::kb * (Tibar + Tebar) * eV_K / 2. * Nbar * density); @@ -1034,7 +1034,7 @@ class Elm_6f : public PhysicsModel { } /**************** CALCULATE METRICS ******************/ - set_tokamak_coordinates_on_mesh(tokamak_coordinates, *mesh, noshear, Lbar, Bbar); + set_tokamak_coordinates_on_mesh(tokamak_options, *mesh, noshear, Lbar, Bbar); ////////////////////////////////////////////////////////////// // SHIFTED RADIAL COORDINATES @@ -1224,7 +1224,7 @@ class Elm_6f : public PhysicsModel { // Field2D lap_temp=0.0; Field2D logn0 = laplace_alpha * N0; - auto B0 = tokamak_coordinates.Bxy; + auto B0 = tokamak_options.Bxy; ubyn = U * B0 / N0; if (diamag) { diff --git a/examples/conducting-wall-mode/cwm.cxx b/examples/conducting-wall-mode/cwm.cxx index 638208f6e4..3c17b2c3e4 100644 --- a/examples/conducting-wall-mode/cwm.cxx +++ b/examples/conducting-wall-mode/cwm.cxx @@ -121,7 +121,7 @@ class CWM : public PhysicsModel { hthe0 / rho_s); } - auto tokamak_coordinates = TokamakCoordinates(*mesh); + auto tokamak_options = TokamakOptions(*mesh); /************** NORMALISE QUANTITIES *****************/ @@ -132,7 +132,7 @@ class CWM : public PhysicsModel { Te0 /= Te_x; // Normalise geometry - set_tokamak_coordinates_on_mesh(tokamak_coordinates, *mesh, noshear, rho_s, bmag / 1e4, ShearFactor); + set_tokamak_coordinates_on_mesh(tokamak_options, *mesh, noshear, rho_s, bmag / 1e4, ShearFactor); // Set nu nu = nu_hat * Ni0 / pow(Te0, 1.5); @@ -143,10 +143,10 @@ class CWM : public PhysicsModel { // add evolving variables to the communication object SOLVE_FOR(rho, te); - Field2D Rxy = tokamak_coordinates.Rxy; - Field2D Bpxy = tokamak_coordinates.Bpxy; - Field2D Btxy = tokamak_coordinates.Btxy; - Field2D hthe = tokamak_coordinates.hthe; + Field2D Rxy = tokamak_options.Rxy; + Field2D Bpxy = tokamak_options.Bpxy; + Field2D Btxy = tokamak_options.Btxy; + Field2D hthe = tokamak_options.hthe; SAVE_ONCE(Rxy, Bpxy, Btxy, Zxy, hthe); SAVE_ONCE(nu_hat, hthe0); diff --git a/examples/constraints/alfven-wave/alfven.cxx b/examples/constraints/alfven-wave/alfven.cxx index 24f0f41eea..dfad393ded 100644 --- a/examples/constraints/alfven-wave/alfven.cxx +++ b/examples/constraints/alfven-wave/alfven.cxx @@ -173,8 +173,8 @@ class Alfven : public PhysicsModel { noshear = true; } - auto tokamak_coordinates = TokamakCoordinates(*mesh); - set_tokamak_coordinates_on_mesh(tokamak_coordinates, *mesh, noshear, Lnorm, Bnorm); + auto tokamak_options = TokamakOptions(*mesh); + set_tokamak_coordinates_on_mesh(tokamak_options, *mesh, noshear, Lnorm, Bnorm); } }; diff --git a/examples/dalf3/dalf3.cxx b/examples/dalf3/dalf3.cxx index bb40d6fd4e..e70c15cf87 100644 --- a/examples/dalf3/dalf3.cxx +++ b/examples/dalf3/dalf3.cxx @@ -81,7 +81,7 @@ class DALF3 : public PhysicsModel { std::unique_ptr laplacexy{nullptr}; // Laplacian solver in X-Y (n=0) Field2D phi2D; // Axisymmetric potential, used when split_n0=true - TokamakCoordinates tokamak_coordinates = TokamakCoordinates(*mesh); + TokamakOptions tokamak_options = TokamakOptions(*mesh); protected: int init(bool UNUSED(restarting)) override { @@ -164,7 +164,7 @@ class DALF3 : public PhysicsModel { if (lowercase(ptstr) == "shifted") { // Dimits style, using local coordinate system - b0xcv.z += tokamak_coordinates.ShearFactor * b0xcv.x; + b0xcv.z += tokamak_options.ShearFactor * b0xcv.x; noshear = true; } @@ -224,7 +224,7 @@ class DALF3 : public PhysicsModel { b0xcv.z *= rho_s * rho_s; // Metrics - set_tokamak_coordinates_on_mesh(tokamak_coordinates, *mesh, noshear, rho_s, Bnorm); + set_tokamak_coordinates_on_mesh(tokamak_options, *mesh, noshear, rho_s, Bnorm); SOLVE_FOR3(Vort, Pe, Vpar); comms.add(Vort, Pe, Vpar); diff --git a/examples/elm-pb-outerloop/elm_pb_outerloop.cxx b/examples/elm-pb-outerloop/elm_pb_outerloop.cxx index 02218be8db..111e356bb2 100644 --- a/examples/elm-pb-outerloop/elm_pb_outerloop.cxx +++ b/examples/elm-pb-outerloop/elm_pb_outerloop.cxx @@ -288,7 +288,7 @@ class ELMpb : public PhysicsModel { int damp_width; // Width of inner damped region BoutReal damp_t_const; // Timescale of damping - TokamakCoordinates tokamak_coordinates = TokamakCoordinates(*mesh); + TokamakOptions tokamak_options = TokamakOptions(*mesh); const BoutReal MU0 = 4.0e-7 * PI; const BoutReal Mi = 2.0 * 1.6726e-27; // Ion mass @@ -717,13 +717,13 @@ class ELMpb : public PhysicsModel { if (mesh->get(Lbar, "rmag") != 0) { // Typical length scale Lbar = 1.0; } - set_tokamak_coordinates_on_mesh(tokamak_coordinates, *mesh, true, Lbar, Bbar); + set_tokamak_coordinates_on_mesh(tokamak_options, *mesh, true, Lbar, Bbar); - auto Bpxy = tokamak_coordinates.Bpxy; - auto hthe = tokamak_coordinates.hthe; - auto Rxy = tokamak_coordinates.Rxy; - auto Btxy = tokamak_coordinates.Btxy; - auto B0 = tokamak_coordinates.Bxy; + auto Bpxy = tokamak_options.Bpxy; + auto hthe = tokamak_options.hthe; + auto Rxy = tokamak_options.Rxy; + auto Btxy = tokamak_options.Btxy; + auto B0 = tokamak_options.Bxy; V0 = -Rxy * Bpxy * Dphi0 / B0; @@ -820,7 +820,7 @@ class ELMpb : public PhysicsModel { if (noshear) { if (include_curvature) { - b0xcv.z += tokamak_coordinates.ShearFactor * b0xcv.x; + b0xcv.z += tokamak_options.ShearFactor * b0xcv.x; } } @@ -830,7 +830,7 @@ class ELMpb : public PhysicsModel { if (not mesh->IncIntShear) { // Dimits style, using local coordinate system if (include_curvature) { - b0xcv.z += tokamak_coordinates.ShearFactor * b0xcv.x; + b0xcv.z += tokamak_options.ShearFactor * b0xcv.x; } } @@ -1231,7 +1231,7 @@ class ELMpb : public PhysicsModel { Field3D result = Grad_par(f, loc); - auto B0 = tokamak_coordinates.Bxy; + auto B0 = tokamak_options.Bxy; if (nonlinear) { result -= bracket(interp_to(Psi, loc), f, bm_mag) * B0; @@ -1252,7 +1252,7 @@ class ELMpb : public PhysicsModel { Coordinates* metric = mesh->getCoordinates(); - auto B0 = tokamak_coordinates.Bxy; + auto B0 = tokamak_options.Bxy; //////////////////////////////////////////// // Transitions from 0 in core to 1 in vacuum @@ -1999,7 +1999,7 @@ class ELMpb : public PhysicsModel { Field3D U1 = ddt(U); - auto B0 = tokamak_coordinates.Bxy; + auto B0 = tokamak_options.Bxy; U1 += (gamma * B0 * B0) * Grad_par(Jrhs, CELL_CENTRE) + (gamma * b0xcv) * Grad(P); @@ -2053,7 +2053,7 @@ class ELMpb : public PhysicsModel { JP.setBoundary("P"); JP.applyBoundary(); - auto B0 = tokamak_coordinates.Bxy; + auto B0 = tokamak_options.Bxy; Field3D B0phi = B0 * phi; mesh->communicate(B0phi); diff --git a/examples/elm-pb/elm_pb.cxx b/examples/elm-pb/elm_pb.cxx index 8d61f44d9a..7d44376e69 100644 --- a/examples/elm-pb/elm_pb.cxx +++ b/examples/elm-pb/elm_pb.cxx @@ -230,7 +230,7 @@ class ELMpb : public PhysicsModel { int damp_width; // Width of inner damped region BoutReal damp_t_const; // Timescale of damping - TokamakCoordinates tokamak_coordinates = TokamakCoordinates(*mesh); + TokamakOptions tokamak_options = TokamakOptions(*mesh); const BoutReal MU0 = 4.0e-7 * PI; const BoutReal Mi = 2.0 * 1.6726e-27; // Ion mass @@ -336,8 +336,8 @@ class ELMpb : public PhysicsModel { Psi_loc.setBoundary("Psi_loc"); ////////////////////////////////////////////////////////////// - auto &globalOptions = Options::root(); - auto &options = globalOptions["highbeta"]; + auto& globalOptions = Options::root(); + auto& options = globalOptions["highbeta"]; constn0 = options["constn0"].withDefault(true); // use the hyperbolic profile of n0. If both n0_fake_prof and @@ -647,11 +647,11 @@ class ELMpb : public PhysicsModel { Dphi0 *= -1; } - auto Bpxy = tokamak_coordinates.Bpxy; - auto hthe = tokamak_coordinates.hthe; - auto Rxy = tokamak_coordinates.Rxy; - auto Btxy = tokamak_coordinates.Btxy; - auto B0 = tokamak_coordinates.Bxy; + auto Bpxy = tokamak_options.Bpxy; + auto hthe = tokamak_options.hthe; + auto Rxy = tokamak_options.Rxy; + auto Btxy = tokamak_options.Btxy; + auto B0 = tokamak_options.Bxy; V0 = -Rxy * Bpxy * Dphi0 / B0; @@ -748,7 +748,7 @@ class ELMpb : public PhysicsModel { if (noshear) { if (include_curvature) { - b0xcv.z += tokamak_coordinates.ShearFactor * b0xcv.x; + b0xcv.z += tokamak_options.ShearFactor * b0xcv.x; } } @@ -758,7 +758,7 @@ class ELMpb : public PhysicsModel { if (not mesh->IncIntShear) { // Dimits style, using local coordinate system if (include_curvature) { - b0xcv.z += tokamak_coordinates.ShearFactor * b0xcv.x; + b0xcv.z += tokamak_options.ShearFactor * b0xcv.x; } } @@ -884,7 +884,7 @@ class ELMpb : public PhysicsModel { b0xcv.y *= Lbar * Lbar; b0xcv.z *= Lbar * Lbar; - set_tokamak_coordinates_on_mesh(tokamak_coordinates, *mesh, true, Lbar, Bbar); + set_tokamak_coordinates_on_mesh(tokamak_options, *mesh, true, Lbar, Bbar); ////////////////////////////////////////////////////////////// // SHIFTED RADIAL COORDINATES @@ -1158,76 +1158,76 @@ class ELMpb : public PhysicsModel { return 0; } - // Parallel gradient along perturbed field-line - Field3D Grad_parP(const Field3D& f, CELL_LOC loc = CELL_DEFAULT) const { + // Parallel gradient along perturbed field-line + Field3D Grad_parP(const Field3D& f, CELL_LOC loc = CELL_DEFAULT) const { - if (loc == CELL_DEFAULT) { - loc = f.getLocation(); - } + if (loc == CELL_DEFAULT) { + loc = f.getLocation(); + } - Field3D result = Grad_par(f, loc); + Field3D result = Grad_par(f, loc); - auto B0 = tokamak_coordinates.Bxy; + auto B0 = tokamak_options.Bxy; - if (nonlinear) { - result -= bracket(interp_to(Psi, loc), f, bm_mag) * B0; + if (nonlinear) { + result -= bracket(interp_to(Psi, loc), f, bm_mag) * B0; - if (include_rmp) { - result -= bracket(interp_to(rmp_Psi, loc), f, bm_mag) * B0; - } - } + if (include_rmp) { + result -= bracket(interp_to(rmp_Psi, loc), f, bm_mag) * B0; + } + } - return result; - } + return result; + } - bool first_run = true; // For printing out some diagnostics first time around + bool first_run = true; // For printing out some diagnostics first time around - int rhs(BoutReal t) override { - // Perform communications - mesh->communicate(comms); + int rhs(BoutReal t) override { + // Perform communications + mesh->communicate(comms); - Coordinates* metric = mesh->getCoordinates(); + Coordinates *metric = mesh->getCoordinates(); - auto B0 = tokamak_coordinates.Bxy; + auto B0 = tokamak_options.Bxy; - //////////////////////////////////////////// - // Transitions from 0 in core to 1 in vacuum - if (nonlinear) { - vac_mask = (1.0 - tanh(((P0 + P) - vacuum_pressure) / vacuum_trans)) / 2.0; + //////////////////////////////////////////// + // Transitions from 0 in core to 1 in vacuum + if (nonlinear) { + vac_mask = (1.0 - tanh(((P0 + P) - vacuum_pressure) / vacuum_trans)) / 2.0; - // Update resistivity - if (spitzer_resist) { - // Use Spitzer formula - Field3D Te; - Te = (P0 + P) * Bbar * Bbar / (4. * MU0) / (density * 1.602e-19); // eV + // Update resistivity + if (spitzer_resist) { + // Use Spitzer formula + Field3D Te; + Te = (P0 + P) * Bbar * Bbar / (4. * MU0) / (density * 1.602e-19); // eV - // eta in Ohm-m. ln(Lambda) = 20 - eta = interp_to(0.51 * 1.03e-4 * Zeff * 20. * pow(Te, -1.5), loc); + // eta in Ohm-m. ln(Lambda) = 20 + eta = interp_to(0.51 * 1.03e-4 * Zeff * 20. * pow(Te, -1.5), loc); - // Normalised eta - eta /= MU0 * Va * Lbar; - } else { - // Use specified core and vacuum Lundquist numbers - eta = core_resist + (vac_resist - core_resist) * vac_mask; - } - eta = interp_to(eta, loc); - } + // Normalised eta + eta /= MU0 * Va * Lbar; + } else { + // Use specified core and vacuum Lundquist numbers + eta = core_resist + (vac_resist - core_resist) * vac_mask; + } + eta = interp_to(eta, loc); + } - //////////////////////////////////////////// - // Resonant Magnetic Perturbation code + //////////////////////////////////////////// + // Resonant Magnetic Perturbation code - if (include_rmp) { + if (include_rmp) { - if ((rmp_ramp > 0.0) || (rmp_freq > 0.0) || (rmp_rotate != 0.0)) { - // Need to update the RMP terms + if ((rmp_ramp > 0.0) || (rmp_freq > 0.0) || (rmp_rotate != 0.0)) { + // Need to update the RMP terms - if ((rmp_ramp > 0.0) && (t < rmp_ramp)) { - // Still in ramp phase + if ((rmp_ramp > 0.0) && (t < rmp_ramp)) { + // Still in ramp phase - rmp_Psi = (t / rmp_ramp) * rmp_Psi0; // Linear ramp + rmp_Psi = (t / rmp_ramp) * rmp_Psi0; // Linear ramp - rmp_dApdt = rmp_Psi0 / rmp_ramp; - } else { + rmp_dApdt = rmp_Psi0 / rmp_ramp; + } else { rmp_Psi = rmp_Psi0; rmp_dApdt = 0.0; } @@ -1806,7 +1806,7 @@ class ELMpb : public PhysicsModel { Field3D U1 = ddt(U); - auto B0 = tokamak_coordinates.Bxy; + auto B0 = tokamak_options.Bxy; U1 += (gamma * B0 * B0) * Grad_par(Jrhs, CELL_CENTRE) + (gamma * b0xcv) * Grad(P); @@ -1860,7 +1860,7 @@ class ELMpb : public PhysicsModel { JP.setBoundary("P"); JP.applyBoundary(); - auto B0 = tokamak_coordinates.Bxy; + auto B0 = tokamak_options.Bxy; Field3D B0phi = B0 * phi; mesh->communicate(B0phi); diff --git a/examples/gyro-gem/gem.cxx b/examples/gyro-gem/gem.cxx index 9930f99b5f..c3023b9e2e 100644 --- a/examples/gyro-gem/gem.cxx +++ b/examples/gyro-gem/gem.cxx @@ -242,7 +242,7 @@ class GEM : public PhysicsModel { Tbar = options["Tbar"].withDefault(Tbar); // Override in options file SAVE_ONCE(Tbar); // Timescale in seconds - auto tokamak_coordinates = TokamakCoordinates(*mesh); + auto tokamak_options = TokamakOptions(*mesh); if (mesh->get(Bbar, "Bbar")) { if (mesh->get(Bbar, "bmag")) { @@ -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(tokamak_coordinates, *mesh, true, Lbar, Bbar); + set_tokamak_coordinates_on_mesh(tokamak_options, *mesh, true, Lbar, Bbar); beta_e = 4.e-7 * PI * max(p_e, true) / (Bbar * Bbar); SAVE_ONCE(beta_e); @@ -350,7 +350,7 @@ class GEM : public PhysicsModel { B0vec.covariant = false; B0vec.x = 0.; - B0vec.y = tokamak_coordinates.Bpxy / tokamak_coordinates.hthe; + B0vec.y = tokamak_options.Bpxy / tokamak_options.hthe; B0vec.z = 0.; // Precompute this for use in RHS diff --git a/examples/laplacexy/alfven-wave/alfven.cxx b/examples/laplacexy/alfven-wave/alfven.cxx index 5df141cede..b71699ae14 100644 --- a/examples/laplacexy/alfven-wave/alfven.cxx +++ b/examples/laplacexy/alfven-wave/alfven.cxx @@ -171,8 +171,8 @@ class Alfven : public PhysicsModel { void LoadMetric(BoutReal Lnorm, BoutReal Bnorm) { - auto tokamak_coordinates = TokamakCoordinates(*mesh); - set_tokamak_coordinates_on_mesh(tokamak_coordinates, *mesh, true, Lnorm, Bnorm); + auto tokamak_options = TokamakOptions(*mesh); + set_tokamak_coordinates_on_mesh(tokamak_options, *mesh, true, Lnorm, Bnorm); Coordinates* coord = mesh->getCoordinates(); // Metric tensor } }; diff --git a/examples/laplacexy/laplace_perp/test.cxx b/examples/laplacexy/laplace_perp/test.cxx index c0aabc1f01..3079d7ca9a 100644 --- a/examples/laplacexy/laplace_perp/test.cxx +++ b/examples/laplacexy/laplace_perp/test.cxx @@ -14,8 +14,8 @@ int main(int argc, char** argv) { bool calc_metric; calc_metric = Options::root()["calc_metric"].withDefault(false); if (calc_metric) { - auto tokamak_coordinates = TokamakCoordinates(*mesh); - set_tokamak_coordinates_on_mesh(tokamak_coordinates, *mesh, true, 1.0, 1.0); + auto tokamak_options = TokamakOptions(*mesh); + set_tokamak_coordinates_on_mesh(tokamak_options, *mesh, true, 1.0, 1.0); } Coordinates* coord = mesh->getCoordinates(); diff --git a/examples/wave-slab/wave_slab.cxx b/examples/wave-slab/wave_slab.cxx index 1ff52a926b..b7277e0b6c 100644 --- a/examples/wave-slab/wave_slab.cxx +++ b/examples/wave-slab/wave_slab.cxx @@ -17,8 +17,8 @@ class WaveTest : public PhysicsModel { public: int init(bool UNUSED(restarting)) { - auto tokamak_coordinates = TokamakCoordinates(*mesh); - set_tokamak_coordinates_on_mesh(tokamak_coordinates, *mesh, true, 1.0, 1.0); + auto tokamak_options = TokamakOptions(*mesh); + set_tokamak_coordinates_on_mesh(tokamak_options, *mesh, true, 1.0, 1.0); auto* coords = mesh->getCoordinates(); diff --git a/include/bout/coordinates.hxx b/include/bout/coordinates.hxx index 954f65d272..4ae3ac0740 100644 --- a/include/bout/coordinates.hxx +++ b/include/bout/coordinates.hxx @@ -500,9 +500,9 @@ private: /* /// Standard coordinate system for tokamak simulations -class TokamakCoordinates : public Coordinates { +class TokamakOptions : public Coordinates { public: - TokamakCoordinates(Mesh *mesh) : Coordinates(mesh) { + TokamakOptions(Mesh *mesh) : Coordinates(mesh) { } private: diff --git a/include/bout/tokamak_coordinates.hxx b/include/bout/tokamak_coordinates.hxx index 1c40d8f4ef..85f6d3a48a 100644 --- a/include/bout/tokamak_coordinates.hxx +++ b/include/bout/tokamak_coordinates.hxx @@ -10,7 +10,7 @@ #include "bout/utils.hxx" #include "bout/vector2d.hxx" -struct TokamakCoordinates { +struct TokamakOptions { Field2D Rxy; Field2D Bpxy; Field2D Btxy; @@ -19,7 +19,7 @@ struct TokamakCoordinates { FieldMetric ShearFactor; FieldMetric dx; - TokamakCoordinates(Mesh &mesh) { + TokamakOptions(Mesh& mesh) { mesh.get(Rxy, "Rxy"); // mesh->get(Zxy, "Zxy"); mesh.get(Bpxy, "Bpxy"); @@ -48,12 +48,12 @@ BoutReal get_sign_of_bp(Field2D Bpxy) { return 1.0; } -void set_tokamak_coordinates_on_mesh(TokamakCoordinates& tokamakCoordinates, Mesh& mesh, const bool noshear, - BoutReal Lbar, BoutReal Bbar, BoutReal ShearFactor = 1.0) { +void set_tokamak_coordinates_on_mesh(TokamakOptions& tokamak_options, Mesh& mesh, const bool noshear, BoutReal Lbar, + BoutReal Bbar, BoutReal ShearFactor = 1.0) { - tokamakCoordinates.normalise(Lbar, Bbar, ShearFactor); + tokamak_options.normalise(Lbar, Bbar, ShearFactor); - const BoutReal sign_of_bp = get_sign_of_bp(tokamakCoordinates.Bpxy); + const BoutReal sign_of_bp = get_sign_of_bp(tokamak_options.Bpxy); if (noshear) { ShearFactor = 0.0; @@ -61,31 +61,31 @@ void set_tokamak_coordinates_on_mesh(TokamakCoordinates& tokamakCoordinates, Mes auto *coord = mesh.getCoordinates(); - const auto g11 = SQ(tokamakCoordinates.Rxy * tokamakCoordinates.Bpxy); - const auto g22 = 1.0 / SQ(tokamakCoordinates.hthe); - const auto g33 = SQ(ShearFactor) * g11 + SQ(tokamakCoordinates.Bxy) / g11; + const auto g11 = SQ(tokamak_options.Rxy * tokamak_options.Bpxy); + const auto g22 = 1.0 / SQ(tokamak_options.hthe); + const auto g33 = SQ(ShearFactor) * g11 + SQ(tokamak_options.Bxy) / g11; const auto g12 = 0.0; const auto g13 = -ShearFactor * g11; - const auto g23 = -sign_of_bp * tokamakCoordinates.Btxy / - (tokamakCoordinates.hthe * tokamakCoordinates.Bpxy * tokamakCoordinates.Rxy); + const auto g23 = -sign_of_bp * tokamak_options.Btxy / + (tokamak_options.hthe * tokamak_options.Bpxy * tokamak_options.Rxy); - const auto g_11 = 1.0 / g11 + SQ(ShearFactor * tokamakCoordinates.Rxy); - const auto g_22 = SQ(tokamakCoordinates.Bxy * tokamakCoordinates.hthe / tokamakCoordinates.Bpxy); - const auto g_33 = tokamakCoordinates.Rxy * tokamakCoordinates.Rxy; + const auto g_11 = 1.0 / g11 + SQ(ShearFactor * tokamak_options.Rxy); + const auto g_22 = SQ(tokamak_options.Bxy * tokamak_options.hthe / tokamak_options.Bpxy); + const auto g_33 = tokamak_options.Rxy * tokamak_options.Rxy; const auto g_12 = - sign_of_bp * tokamakCoordinates.Btxy * tokamakCoordinates.hthe * ShearFactor * tokamakCoordinates.Rxy / - tokamakCoordinates.Bpxy; - const auto g_13 = ShearFactor * tokamakCoordinates.Rxy * tokamakCoordinates.Rxy; - const auto g_23 = sign_of_bp * tokamakCoordinates.Btxy * tokamakCoordinates.hthe * tokamakCoordinates.Rxy / - tokamakCoordinates.Bpxy; + sign_of_bp * tokamak_options.Btxy * tokamak_options.hthe * ShearFactor * tokamak_options.Rxy / + tokamak_options.Bpxy; + const auto g_13 = ShearFactor * tokamak_options.Rxy * tokamak_options.Rxy; + const auto g_23 = sign_of_bp * tokamak_options.Btxy * tokamak_options.hthe * tokamak_options.Rxy / + tokamak_options.Bpxy; coord->setMetricTensor(ContravariantMetricTensor(g11, g22, g33, g12, g13, g23), CovariantMetricTensor(g_11, g_22, g_33, g_12, g_13, g_23)); - coord->setJ(tokamakCoordinates.hthe / tokamakCoordinates.Bpxy); - coord->setBxy(tokamakCoordinates.Bxy); - coord->setDx(tokamakCoordinates.dx); + coord->setJ(tokamak_options.hthe / tokamak_options.Bpxy); + coord->setBxy(tokamak_options.Bxy); + coord->setDx(tokamak_options.dx); } #endif //BOUT_TOKAMAK_COORDINATES_HXX diff --git a/tests/MMS/GBS/gbs.cxx b/tests/MMS/GBS/gbs.cxx index b480bce11d..e5ebf2fa92 100644 --- a/tests/MMS/GBS/gbs.cxx +++ b/tests/MMS/GBS/gbs.cxx @@ -315,8 +315,8 @@ int GBS::init(bool restarting) { void GBS::LoadMetric(BoutReal Lnorm, BoutReal Bnorm) { - auto tokamak_coordinates = TokamakCoordinates(*mesh); - set_tokamak_coordinates_on_mesh(tokamak_coordinates, *mesh, true, Lnorm, Bnorm); + auto tokamak_options = TokamakOptions(*mesh); + set_tokamak_coordinates_on_mesh(tokamak_options, *mesh, true, Lnorm, Bnorm); // just define a macro for V_E dot Grad #define vE_Grad(f, p) (bracket(p, f, bm_exb)) diff --git a/tests/MMS/elm-pb/elm_pb.cxx b/tests/MMS/elm-pb/elm_pb.cxx index 70c0d65112..845542d9bd 100644 --- a/tests/MMS/elm-pb/elm_pb.cxx +++ b/tests/MMS/elm-pb/elm_pb.cxx @@ -122,7 +122,7 @@ class ELMpb : public PhysicsModel { // Communication objects FieldGroup comms; - TokamakCoordinates tokamak_coordinates = TokamakCoordinates(*mesh); + TokamakOptions tokamak_options = TokamakOptions(*mesh); // Parallel gradient along perturbed field-line const Field3D Grad_parP(const Field3D& f, CELL_LOC loc = CELL_DEFAULT) { @@ -296,7 +296,7 @@ class ELMpb : public PhysicsModel { if (not mesh->IncIntShear) { // Dimits style, using local coordinate system if (include_curvature) { - b0xcv.z += tokamak_coordinates.get_ShearFactor() * b0xcv.x; + b0xcv.z += tokamak_options.get_ShearFactor() * b0xcv.x; } } } @@ -389,7 +389,7 @@ class ELMpb : public PhysicsModel { noshear = true; } - set_tokamak_coordinates_on_mesh(tokamak_coordinates, *mesh, true, Lbar, Bbar); + set_tokamak_coordinates_on_mesh(tokamak_options, *mesh, true, Lbar, Bbar); ////////////////////////////////////////////////////////////// // SHIFTED RADIAL COORDINATES diff --git a/tests/MMS/tokamak/tokamak.cxx b/tests/MMS/tokamak/tokamak.cxx index 5ee1e1b865..b80f18d863 100644 --- a/tests/MMS/tokamak/tokamak.cxx +++ b/tests/MMS/tokamak/tokamak.cxx @@ -45,8 +45,8 @@ class TokamakMMS : public PhysicsModel { } void LoadMetric(BoutReal Lnorm, BoutReal Bnorm) { - auto tokamak_coordinates = TokamakCoordinates(*mesh); - set_tokamak_coordinates_on_mesh(tokamak_coordinates, *mesh, true, Lnorm, Bnorm); + auto tokamak_options = TokamakOptions(*mesh); + set_tokamak_coordinates_on_mesh(tokamak_options, *mesh, true, Lnorm, Bnorm); Coordinates* coords = mesh->getCoordinates(); } diff --git a/tests/integrated/test-drift-instability/2fluid.cxx b/tests/integrated/test-drift-instability/2fluid.cxx index c564cac2eb..427ec14981 100644 --- a/tests/integrated/test-drift-instability/2fluid.cxx +++ b/tests/integrated/test-drift-instability/2fluid.cxx @@ -59,7 +59,7 @@ class TwoFluid : public PhysicsModel { FieldGroup comms; // Group of variables for communications - TokamakCoordinates tokamak_coordinates = TokamakCoordinates(*mesh); + TokamakOptions tokamak_options = TokamakOptions(*mesh); Coordinates* coord; // Coordinate system @@ -135,7 +135,7 @@ class TwoFluid : public PhysicsModel { const bool ShiftXderivs = (*globalOptions)["ShiftXderivs"].withDefault(false); if (ShiftXderivs) { ShearFactor = 0.0; // I disappears from metric - b0xcv.z += tokamak_coordinates.ShearFactor * b0xcv.x; + b0xcv.z += tokamak_options.ShearFactor * b0xcv.x; noshear = true; } @@ -194,7 +194,7 @@ class TwoFluid : public PhysicsModel { pei0 = (Ti0 + Te0) * Ni0; pe0 = Te0 * Ni0; - set_tokamak_coordinates_on_mesh(tokamak_coordinates, *mesh, noshear, rho_s, bmag / 1e4, ShearFactor); + set_tokamak_coordinates_on_mesh(tokamak_options, *mesh, noshear, rho_s, bmag / 1e4, ShearFactor); /**************** SET EVOLVING VARIABLES *************/ diff --git a/tests/integrated/test-interchange-instability/2fluid.cxx b/tests/integrated/test-interchange-instability/2fluid.cxx index b5327b73bb..884333faa1 100644 --- a/tests/integrated/test-interchange-instability/2fluid.cxx +++ b/tests/integrated/test-interchange-instability/2fluid.cxx @@ -34,7 +34,7 @@ class Interchange : public PhysicsModel { Coordinates* coord; - TokamakCoordinates tokamak_coordinates = TokamakCoordinates(*mesh); + TokamakOptions tokamak_options = TokamakOptions(*mesh); protected: int init(bool UNUSED(restarting)) override { @@ -101,10 +101,10 @@ class Interchange : public PhysicsModel { hthe0 / rho_s); } - set_tokamak_coordinates_on_mesh(tokamak_coordinates, *mesh, noshear, rho_s, bmag / 1e4, ShearFactor); + set_tokamak_coordinates_on_mesh(tokamak_options, *mesh, noshear, rho_s, bmag / 1e4, ShearFactor); if (ShiftXderivs) { - b0xcv.z += tokamak_coordinates.ShearFactor * b0xcv.x; + b0xcv.z += tokamak_options.ShearFactor * b0xcv.x; } /************** NORMALISE QUANTITIES *****************/ diff --git a/tests/integrated/test-laplacexy/loadmetric.cxx b/tests/integrated/test-laplacexy/loadmetric.cxx index d34209f998..addbd6ec54 100644 --- a/tests/integrated/test-laplacexy/loadmetric.cxx +++ b/tests/integrated/test-laplacexy/loadmetric.cxx @@ -18,6 +18,6 @@ void LoadMetric(BoutReal Lnorm, BoutReal Bnorm) { noshear = true; } - auto tokamak_coordinates = TokamakCoordinates(*mesh); - set_tokamak_coordinates_on_mesh(tokamak_coordinates, *mesh, true, Lnorm, Bnorm); + auto tokamak_options = TokamakOptions(*mesh); + set_tokamak_coordinates_on_mesh(tokamak_options, *mesh, true, Lnorm, Bnorm); }