Skip to content

Commit ab58ba5

Browse files
committed
Remove deprecated FieldGenerator::generate
1 parent 182975e commit ab58ba5

File tree

3 files changed

+42
-51
lines changed

3 files changed

+42
-51
lines changed

include/bout/sys/expressionparser.hxx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ public:
6464
return nullptr;
6565
}
6666

67-
[[deprecated("This will be removed in a future version. Implementations should "
68-
"override the Context version of this function.")]] virtual double
69-
generate(BoutReal x, BoutReal y, BoutReal z, BoutReal t) {
70-
return generate(bout::generator::Context().set("x", x, "y", y, "z", z, "t", t));
71-
}
72-
7367
/// Generate a value at the given coordinates (x,y,z,t)
7468
/// This should be deterministic, always returning the same value given the same inputs
7569
///
@@ -78,7 +72,7 @@ public:
7872
/// them or an infinite recursion results. This is for backward
7973
/// compatibility for users and implementors. In a future version
8074
/// this function will be made pure virtual.
81-
virtual double generate(const bout::generator::Context& ctx);
75+
virtual double generate(const bout::generator::Context& ctx) = 0;
8276

8377
/// Create a string representation of the generator, for debugging output
8478
virtual std::string str() const { return std::string("?"); }

src/mesh/boundary_standard.cxx

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <bout/mesh.hxx>
99
#include <bout/msg_stack.hxx>
1010
#include <bout/output.hxx>
11+
#include <bout/sys/generator_context.hxx>
1112
#include <bout/utils.hxx>
1213

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

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

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

471472
for (int zk = 0; zk < mesh->LocalNz; zk++) {
472473
if (fg) {
473-
val = fg->generate(xnorm, TWOPI * ynorm, TWOPI * (zk - 0.5) / (mesh->LocalNz),
474-
t);
474+
val = fg->generate(
475+
Context(bndry, zk, loc, t, mesh).set("x", xnorm, "y", ynorm));
475476
}
476477
f(bndry->x, bndry->y, zk) =
477478
2 * val - f(bndry->x - bndry->bx, bndry->y - bndry->by, zk);
@@ -508,14 +509,14 @@ void BoundaryDirichlet::apply(Field3D& f, BoutReal t) {
508509
// can help with the stability of higher order methods.
509510
for (int i = 1; i < bndry->width; i++) {
510511
// Set any other guard cells using the values on the cells
511-
int xi = bndry->x + i * bndry->bx;
512-
int yi = bndry->y + i * bndry->by;
513-
xnorm = mesh->GlobalX(xi);
514-
ynorm = mesh->GlobalY(yi);
512+
const int xi = bndry->x + (i * bndry->bx);
513+
const int yi = bndry->y + (i * bndry->by);
514+
const auto xnorm = mesh->GlobalX(xi);
515+
const auto ynorm = mesh->GlobalY(yi) * TWOPI;
515516
for (int zk = 0; zk < mesh->LocalNz; zk++) {
516517
if (fg) {
517-
val = fg->generate(xnorm, TWOPI * ynorm,
518-
TWOPI * (zk - 0.5) / (mesh->LocalNz), t);
518+
val = fg->generate(
519+
Context(bndry, zk, loc, t, mesh).set("x", xnorm, "y", ynorm));
519520
}
520521
f(xi, yi, zk) = val;
521522
}
@@ -965,18 +966,18 @@ void BoundaryDirichlet_O3::apply(Field3D& f, BoutReal t) {
965966

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

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

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

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

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

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

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

2144-
BoutReal ynorm = 0.5
2145-
* (mesh->GlobalY(bndry->y) // In the guard cell
2146-
+ mesh->GlobalY(bndry->y - bndry->by)); // the grid cell
2146+
const BoutReal ynorm =
2147+
TWOPI * 0.5
2148+
* (mesh->GlobalY(bndry->y) // In the guard cell
2149+
+ mesh->GlobalY(bndry->y - bndry->by)); // the grid cell
21472150

21482151
for (int zk = 0; zk < mesh->LocalNz; zk++) {
21492152
BoutReal delta = bndry->bx * metric->dx(bndry->x, bndry->y, zk)
21502153
+ bndry->by * metric->dy(bndry->x, bndry->y, zk);
21512154
if (fg) {
2152-
val = fg->generate(xnorm, TWOPI * ynorm,
2153-
TWOPI * (zk - 0.5) / (mesh->LocalNz), t);
2155+
val = fg->generate(
2156+
Context(bndry, zk, loc, t, mesh).set("x", xnorm, "y", ynorm));
21542157
}
21552158
f(bndry->x, bndry->y, zk) =
21562159
f(bndry->x - bndry->bx, bndry->y - bndry->by, zk) + delta * val;

src/sys/expressionparser.cxx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ using namespace std::string_literals;
3737

3838
using bout::generator::Context;
3939

40-
// Note: Here rather than in header to avoid many deprecated warnings
41-
// Remove in future and make this function pure virtual
42-
double FieldGenerator::generate(const Context& ctx) {
43-
return generate(ctx.x(), ctx.y(), ctx.z(), ctx.t());
44-
}
45-
4640
/////////////////////////////////////////////
4741
namespace { // These classes only visible in this file
4842

0 commit comments

Comments
 (0)