Skip to content

Commit

Permalink
Add overloaded getter for zlength() that gives the value at a particu…
Browse files Browse the repository at this point in the history
…lar x, y (or x, y, z) position
  • Loading branch information
tomchapman committed Oct 1, 2024
1 parent f49eb92 commit 8ad42cc
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions include/bout/coordinates.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ public:
/// Length of the Z domain. Used for FFTs
const Field2D& zlength() const;

const BoutReal& zlength(int x, int y) const {
return zlength()(x, y); }

/// True if corrections for non-uniform mesh spacing should be included in operators
bool non_uniform() const { return non_uniform_; }
void setNon_uniform(bool non_uniform) { non_uniform_ = non_uniform; }
Expand Down
2 changes: 1 addition & 1 deletion src/field/field3d.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ void shiftZ(Field3D& var, int jx, int jy, double zangle) {

rfft(&(var(jx, jy, 0)), ncz, v.begin()); // Forward FFT

BoutReal zlength = var.getCoordinates()->zlength()(jx, jy);
BoutReal zlength = var.getCoordinates()->zlength(jx, jy);

// Apply phase shift
for (int jz = 1; jz <= ncz / 2; jz++) {
Expand Down
2 changes: 1 addition & 1 deletion src/invert/laplace/invert_laplace.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void Laplacian::tridagCoefs(int jx, int jy, int jz, dcomplex& a, dcomplex& b, dc

ASSERT1(ccoef == nullptr || ccoef->getLocation() == loc);
ASSERT1(d == nullptr || d->getLocation() == loc);
BoutReal kwave = jz * 2.0 * PI / coords->zlength()(jx, jy); // wave number is 1/[rad]
BoutReal kwave = jz * 2.0 * PI / coords->zlength(jx, jy); // wave number is 1/[rad]

tridagCoefs(jx, jy, kwave, a, b, c, ccoef, d, loc);
}
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/boundary_standard.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2669,7 +2669,7 @@ void BoundaryNeumann_NonOrthogonal::apply(Field3D& f) {
-1.0 * sqrt(metric->g33(x, y) / metric->g11(x, y)) * metric->dx(x, y);
for (int jz = 1; jz <= ncz / 2; jz++) {
BoutReal kwave =
jz * 2.0 * PI / metric->zlength()(x, y); // wavenumber in [rad^-1]
jz * 2.0 * PI / metric->zlength(x, y); // wavenumber in [rad^-1]
c0[jz] *= exp(coef * kwave); // The decaying solution only
}
// Reverse FFT
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/mesh/parallel/test_shiftedmetric.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ShiftedMetricTest : public ::testing::Test {

auto coords = mesh->getCoordinates();
coords->setParallelTransform(bout::utils::make_unique<ShiftedMetric>(
*mesh, CELL_CENTRE, zShift, coords->zlength()(0, 0)));
*mesh, CELL_CENTRE, zShift, coords->zlength(0, 0)));

Field3D input_temp{mesh};

Expand Down

0 comments on commit 8ad42cc

Please sign in to comment.