Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions include/bout/sys/expressionparser.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ public:
return nullptr;
}

[[deprecated("This will be removed in a future version. Implementations should "
"override the Context version of this function.")]] virtual double
generate(BoutReal x, BoutReal y, BoutReal z, BoutReal t) {
return generate(bout::generator::Context().set("x", x, "y", y, "z", z, "t", t));
}

/// Generate a value at the given coordinates (x,y,z,t)
/// This should be deterministic, always returning the same value given the same inputs
///
Expand All @@ -78,7 +72,7 @@ public:
/// them or an infinite recursion results. This is for backward
/// compatibility for users and implementors. In a future version
/// this function will be made pure virtual.
virtual double generate(const bout::generator::Context& ctx);
virtual double generate(const bout::generator::Context& ctx) = 0;

/// Create a string representation of the generator, for debugging output
virtual std::string str() const { return std::string("?"); }
Expand Down
79 changes: 41 additions & 38 deletions src/mesh/boundary_standard.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <bout/mesh.hxx>
#include <bout/msg_stack.hxx>
#include <bout/output.hxx>
#include <bout/sys/generator_context.hxx>
#include <bout/utils.hxx>

using bout::generator::Context;
Expand Down Expand Up @@ -460,18 +461,18 @@ void BoundaryDirichlet::apply(Field3D& f, BoutReal t) {

for (; !bndry->isDone(); bndry->next1d()) {
// Calculate the X and Y normalised values half-way between the guard cell and grid cell
BoutReal xnorm = 0.5
* (mesh->GlobalX(bndry->x) // In the guard cell
+ mesh->GlobalX(bndry->x - bndry->bx)); // the grid cell
const BoutReal xnorm = 0.5
* (mesh->GlobalX(bndry->x) // In the guard cell
+ mesh->GlobalX(bndry->x - bndry->bx)); // the grid cell

BoutReal ynorm = 0.5
* (mesh->GlobalY(bndry->y) // In the guard cell
+ mesh->GlobalY(bndry->y - bndry->by)); // the grid cell
const BoutReal ynorm = TWOPI * 0.5
* (mesh->GlobalY(bndry->y) // In the guard cell
+ mesh->GlobalY(bndry->y - bndry->by)); // the grid cell

for (int zk = 0; zk < mesh->LocalNz; zk++) {
if (fg) {
val = fg->generate(xnorm, TWOPI * ynorm, TWOPI * (zk - 0.5) / (mesh->LocalNz),
t);
val = fg->generate(
Context(bndry, zk, loc, t, mesh).set("x", xnorm, "y", ynorm));
}
f(bndry->x, bndry->y, zk) =
2 * val - f(bndry->x - bndry->bx, bndry->y - bndry->by, zk);
Expand Down Expand Up @@ -508,14 +509,14 @@ void BoundaryDirichlet::apply(Field3D& f, BoutReal t) {
// can help with the stability of higher order methods.
for (int i = 1; i < bndry->width; i++) {
// Set any other guard cells using the values on the cells
int xi = bndry->x + i * bndry->bx;
int yi = bndry->y + i * bndry->by;
xnorm = mesh->GlobalX(xi);
ynorm = mesh->GlobalY(yi);
const int xi = bndry->x + (i * bndry->bx);
const int yi = bndry->y + (i * bndry->by);
const auto xnorm = mesh->GlobalX(xi);
const auto ynorm = mesh->GlobalY(yi) * TWOPI;
for (int zk = 0; zk < mesh->LocalNz; zk++) {
if (fg) {
val = fg->generate(xnorm, TWOPI * ynorm,
TWOPI * (zk - 0.5) / (mesh->LocalNz), t);
val = fg->generate(
Context(bndry, zk, loc, t, mesh).set("x", xnorm, "y", ynorm));
}
f(xi, yi, zk) = val;
}
Expand Down Expand Up @@ -965,18 +966,18 @@ void BoundaryDirichlet_O3::apply(Field3D& f, BoutReal t) {

for (; !bndry->isDone(); bndry->next1d()) {
// Calculate the X and Y normalised values half-way between the guard cell and grid cell
BoutReal xnorm = 0.5
* (mesh->GlobalX(bndry->x) // In the guard cell
+ mesh->GlobalX(bndry->x - bndry->bx)); // the grid cell
const BoutReal xnorm = 0.5
* (mesh->GlobalX(bndry->x) // In the guard cell
+ mesh->GlobalX(bndry->x - bndry->bx)); // the grid cell

BoutReal ynorm = 0.5
* (mesh->GlobalY(bndry->y) // In the guard cell
+ mesh->GlobalY(bndry->y - bndry->by)); // the grid cell
const BoutReal ynorm = TWOPI * 0.5
* (mesh->GlobalY(bndry->y) // In the guard cell
+ mesh->GlobalY(bndry->y - bndry->by)); // the grid cell

for (int zk = 0; zk < mesh->LocalNz; zk++) {
if (fg) {
val = fg->generate(xnorm, TWOPI * ynorm, TWOPI * (zk - 0.5) / (mesh->LocalNz),
t);
val = fg->generate(
Context(bndry, zk, loc, t, mesh).set("x", xnorm, "y", ynorm));
}

f(bndry->x, bndry->y, zk) =
Expand Down Expand Up @@ -1431,18 +1432,18 @@ void BoundaryDirichlet_O4::apply(Field3D& f, BoutReal t) {
// Shifted in Z
for (; !bndry->isDone(); bndry->next1d()) {
// Calculate the X and Y normalised values half-way between the guard cell and grid cell
BoutReal xnorm = 0.5
* (mesh->GlobalX(bndry->x) // In the guard cell
+ mesh->GlobalX(bndry->x - bndry->bx)); // the grid cell
const BoutReal xnorm = 0.5
* (mesh->GlobalX(bndry->x) // In the guard cell
+ mesh->GlobalX(bndry->x - bndry->bx)); // the grid cell

BoutReal ynorm = 0.5
* (mesh->GlobalY(bndry->y) // In the guard cell
+ mesh->GlobalY(bndry->y - bndry->by)); // the grid cell
const BoutReal ynorm = TWOPI * 0.5
* (mesh->GlobalY(bndry->y) // In the guard cell
+ mesh->GlobalY(bndry->y - bndry->by)); // the grid cell

for (int zk = 0; zk < mesh->LocalNz; zk++) {
if (fg) {
val = fg->generate(xnorm, TWOPI * ynorm, TWOPI * (zk - 0.5) / (mesh->LocalNz),
t);
val = fg->generate(
Context(bndry, zk, loc, t, mesh).set("x", xnorm, "y", ynorm));
}

f(bndry->x, bndry->y, zk) =
Expand Down Expand Up @@ -2137,20 +2138,22 @@ void BoundaryNeumann_NonOrthogonal::apply(Field3D& f) {
for (; !bndry->isDone(); bndry->next1d()) {
// Calculate the X and Y normalised values half-way between the guard cell and
// grid cell
BoutReal xnorm = 0.5
* (mesh->GlobalX(bndry->x) // In the guard cell
+ mesh->GlobalX(bndry->x - bndry->bx)); // the grid cell
const BoutReal xnorm =
0.5
* (mesh->GlobalX(bndry->x) // In the guard cell
+ mesh->GlobalX(bndry->x - bndry->bx)); // the grid cell

BoutReal ynorm = 0.5
* (mesh->GlobalY(bndry->y) // In the guard cell
+ mesh->GlobalY(bndry->y - bndry->by)); // the grid cell
const BoutReal ynorm =
TWOPI * 0.5
* (mesh->GlobalY(bndry->y) // In the guard cell
+ mesh->GlobalY(bndry->y - bndry->by)); // the grid cell

for (int zk = 0; zk < mesh->LocalNz; zk++) {
BoutReal delta = bndry->bx * metric->dx(bndry->x, bndry->y, zk)
+ bndry->by * metric->dy(bndry->x, bndry->y, zk);
if (fg) {
val = fg->generate(xnorm, TWOPI * ynorm,
TWOPI * (zk - 0.5) / (mesh->LocalNz), t);
val = fg->generate(
Context(bndry, zk, loc, t, mesh).set("x", xnorm, "y", ynorm));
}
f(bndry->x, bndry->y, zk) =
f(bndry->x - bndry->bx, bndry->y - bndry->by, zk) + delta * val;
Expand Down
6 changes: 0 additions & 6 deletions src/sys/expressionparser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ using namespace std::string_literals;

using bout::generator::Context;

// Note: Here rather than in header to avoid many deprecated warnings
// Remove in future and make this function pure virtual
double FieldGenerator::generate(const Context& ctx) {
return generate(ctx.x(), ctx.y(), ctx.z(), ctx.t());
}

/////////////////////////////////////////////
namespace { // These classes only visible in this file

Expand Down
Loading