diff --git a/include/bout/coordinates.hxx b/include/bout/coordinates.hxx index 2c33701762..da9338ce33 100644 --- a/include/bout/coordinates.hxx +++ b/include/bout/coordinates.hxx @@ -103,11 +103,14 @@ public: /// Covariant metric tensor FieldMetric g_11, g_22, g_33, g_12, g_13, g_23; + /// Normalise metric for FCI + /// This normalises B by Bnorm and all lengths by rho_0 + void normaliseFCI(BoutReal Bnorm, BoutReal rho_0); + /// get g_22 at the cell faces; const FieldMetric& g_22_ylow() const; const FieldMetric& g_22_yhigh() const; - FieldMetric& g_22_ylow(); - FieldMetric& g_22_yhigh(); + // Cell Areas const FieldMetric& cell_area_xlow() const { if (_cell_area_xlow.has_value()) { diff --git a/src/mesh/coordinates.cxx b/src/mesh/coordinates.cxx index 3543995702..0111a986fa 100644 --- a/src/mesh/coordinates.cxx +++ b/src/mesh/coordinates.cxx @@ -1874,3 +1874,32 @@ void Coordinates::_compute_cell_volume() const { std::shared_ptr Coordinates::makeYBoundary(YBndryType type) const { return std::make_shared(type, localoptions, *localmesh); } + +void Coordinates::normaliseFCI(const BoutReal Bnorm, const BoutReal rho_0) { + g11 *= SQ(rho_s0); + g22 *= SQ(rho_s0); + g33 *= SQ(rho_s0); + g12 *= SQ(rho_s0); + g13 *= SQ(rho_s0); + g23 *= SQ(rho_s0); + + J /= rho_s0 * rho_s0 * rho_s0; + + g_11 /= SQ(rho_s0); + g_22 /= SQ(rho_s0); + g_33 /= SQ(rho_s0); + g_12 /= SQ(rho_s0); + g_13 /= SQ(rho_s0); + g_23 /= SQ(rho_s0); + + Bxy /= Bnorm; + + geometry(); // Calculate other metrics + + if (Bxy.isFci()) { + g_22_ylow(); + g_22_yhigh(); + (*_g_22_ylow) /= SQ(rho_s0); + (*_g_22_yhigh) /= SQ(rho_s0); + } +}