Skip to content

Commit

Permalink
Add overloaded getters for G1, G2, G3, that give the value at a parti…
Browse files Browse the repository at this point in the history
…cular x, y (or x, y, z) position
  • Loading branch information
tomchapman committed Oct 1, 2024
1 parent 8ad42cc commit 10bf54a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
16 changes: 16 additions & 0 deletions include/bout/coordinates.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,22 @@ public:
void setG2(const FieldMetric& G2) const { g_values().setG2(G2); }
void setG3(const FieldMetric& G3) const { g_values().setG3(G3); }

const BoutReal& G1(int x, int y, int z) const {
return G1()(x, y, z); }
const BoutReal& G2(int x, int y, int z) const {
return G2()(x, y, z); }
const BoutReal& G3(int x, int y, int z) const {
return G3()(x, y, z); }

#if not(BOUT_USE_METRIC_3D)
const BoutReal& G1(int x, int y) const {
return G1()(x, y); }
const BoutReal& G2(int x, int y) const {
return G2()(x, y); }
const BoutReal& G3(int x, int y) const {
return G3()(x, y); }
#endif

const FieldMetric& Grad2_par2_DDY_invSg(CELL_LOC outloc,
const std::string& method) const;

Expand Down
4 changes: 2 additions & 2 deletions src/invert/laplace/impls/multigrid/multigrid_laplace.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ void LaplaceMultigrid::generateMatrixF(int level) {
// if easier; then check this is true in constructor)

BoutReal dxd =
(D(i2, yindex, k2) * coords->G1()(i2, yindex)
(D(i2, yindex, k2) * coords->G1(i2, yindex)
+ coords->g11(i2, yindex) * ddx_C
+ coords->g13(i2, yindex)
* ddz_C // (could assume zero, at least initially, if easier; then check this is true in constructor)
Expand All @@ -628,7 +628,7 @@ void LaplaceMultigrid::generateMatrixF(int level) {
}

BoutReal dzd =
(D(i2, yindex, k2) * coords->G3()(i2, yindex)
(D(i2, yindex, k2) * coords->G3(i2, yindex)
+ coords->g33(i2, yindex) * ddz_C
+ coords->g13(i2, yindex)
* ddx_C // (could assume zero, at least initially, if easier; then check
Expand Down
4 changes: 2 additions & 2 deletions src/invert/laplace/impls/petsc/petsc_laplace.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -979,8 +979,8 @@ void LaplacePetsc::Coeffs(int x, int y, int z, BoutReal& coef1, BoutReal& coef2,
coef5 = 0.0;
// If global flag all_terms are set (true by default)
if (all_terms) {
coef4 = coords->G1()(x, y, z); // X 1st derivative
coef5 = coords->G3()(x, y, z); // Z 1st derivative
coef4 = coords->G1(x, y, z); // X 1st derivative
coef5 = coords->G3(x, y, z); // Z 1st derivative

ASSERT3(finite(coef4));
ASSERT3(finite(coef5));
Expand Down
4 changes: 2 additions & 2 deletions src/invert/laplace/impls/serial_band/serial_band.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ FieldPerp LaplaceSerialBand::solve(const FieldPerp& b, const FieldPerp& x0) {
coef3 *= Dcoef(ix, jy);

if (all_terms) {
coef4 = coords->G1()(ix, jy);
coef5 = coords->G3()(ix, jy);
coef4 = coords->G1(ix, jy);
coef5 = coords->G3(ix, jy);
}

if (nonuniform) {
Expand Down
4 changes: 2 additions & 2 deletions src/invert/laplace/invert_laplace.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ void Laplacian::tridagCoefs(int jx, int jy, BoutReal kwave, dcomplex& a, dcomple
coef5 = 0.0;
// If global flag all_terms are set (true by default)
if (all_terms) {
coef4 = localcoords->G1()(jx, jy); // X 1st derivative
coef5 = localcoords->G3()(jx, jy); // Z 1st derivative
coef4 = localcoords->G1(jx, jy); // X 1st derivative
coef5 = localcoords->G3(jx, jy); // Z 1st derivative
}

if (d != nullptr) {
Expand Down

0 comments on commit 10bf54a

Please sign in to comment.