Skip to content

Commit

Permalink
More fixes. Pass IntShiftTorsion to DifferentialOperators constructor.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchapman committed Nov 26, 2023
1 parent 4ff8508 commit 71aa857
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 130 deletions.
6 changes: 4 additions & 2 deletions include/bout/differential_operators.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public:
using FieldMetric = Field2D;
#endif

DifferentialOperators(Mesh* mesh, CELL_LOC& location, FieldMetric& dx, FieldMetric& dy,
DifferentialOperators(Mesh* mesh, FieldMetric& intShiftTorsion,
const CELL_LOC& location, FieldMetric& dx, FieldMetric& dy,
FieldMetric& dz);

FieldMetric DDX(const Field2D& f, CELL_LOC outloc = CELL_DEFAULT,
Expand Down Expand Up @@ -99,7 +100,8 @@ public:

private:
Mesh* mesh;
CELL_LOC& location;
FieldMetric& intShiftTorsion;
const CELL_LOC& location;
FieldMetric& dx;
FieldMetric& dy;
FieldMetric& dz;
Expand Down
7 changes: 5 additions & 2 deletions include/bout/geometry.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#define __GEOMETRY_H__

#include "coordinates.hxx"
#include "differential_operators.hxx"
#include "metricTensor.hxx"
#include "bout/field2d.hxx"
#include "bout/field3d.hxx"
Expand Down Expand Up @@ -62,9 +63,9 @@ public:
FieldMetric J, FieldMetric Bxy, FieldMetric g11, FieldMetric g22, FieldMetric g33,
FieldMetric g12, FieldMetric g13, FieldMetric g23, FieldMetric g_11,
FieldMetric g_22, FieldMetric g_33, FieldMetric g_12, FieldMetric g_13,
FieldMetric g_23);
FieldMetric g_23, DifferentialOperators differential_operators);

Geometry(Mesh* mesh, CELL_LOC cell_location);
Geometry(Mesh* mesh, DifferentialOperators differential_operators);

/// Christoffel symbol of the second kind (connection coefficients)
FieldMetric G1_11, G1_22, G1_33, G1_12, G1_13, G1_23;
Expand Down Expand Up @@ -145,6 +146,8 @@ private:
FieldMetric this_J;
FieldMetric this_Bxy; ///< Magnitude of B = nabla z times nabla x

DifferentialOperators differential_operators;

// template <typename T, typename... Ts>
// void communicate(T& t, Ts... ts);
};
Expand Down
8 changes: 5 additions & 3 deletions src/mesh/coordinates.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
#include "parallel/fci.hxx"
#include "parallel/shiftedmetricinterp.hxx"

#include "bout/geometry.hxx"
#include "bout/metricTensor.hxx"
#include "bout/differential_operators.hxx"
#include "bout/field2d.hxx"
#include "bout/field3d.hxx"
#include "bout/geometry.hxx"
#include "bout/metricTensor.hxx"
#include "bout/utils.hxx"
#include <bout/bout_types.hxx>

Expand Down Expand Up @@ -307,7 +308,8 @@ Coordinates::Coordinates(Mesh* mesh, Options* options, const CELL_LOC loc,
// G3_11(mesh), G3_22(mesh), G3_33(mesh), G3_12(mesh), G3_13(mesh), G3_23(mesh),
// G1(mesh), G2(mesh), G3(mesh),
ShiftTorsion(mesh), IntShiftTorsion(mesh), localmesh(mesh), location(loc),
geometry(Geometry(mesh, loc)) {
geometry(
Geometry(mesh, DifferentialOperators(mesh, IntShiftTorsion, loc, dx, dy, dz))) {

if (options == nullptr) {
options = Options::getRoot()->getSection("mesh");
Expand Down
12 changes: 7 additions & 5 deletions src/mesh/differential_operators.cxx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

#include "bout/differential_operators.hxx"
#include "bout/mesh.hxx"

DifferentialOperators::DifferentialOperators(Mesh* mesh, CELL_LOC& location,
FieldMetric& dx, FieldMetric& dy,
FieldMetric& dz)
: mesh(mesh), location(location), dx(dx), dy(dy), dz(dz) {}
DifferentialOperators::DifferentialOperators(Mesh* mesh, FieldMetric& intShiftTorsion,
const CELL_LOC& location, FieldMetric& dx,
FieldMetric& dy, FieldMetric& dz)
: mesh(mesh), intShiftTorsion(intShiftTorsion), location(location), dx(dx), dy(dy),
dz(dz) {}

DifferentialOperators::FieldMetric DifferentialOperators::DDX(const Field2D& f,
CELL_LOC loc,
Expand All @@ -20,7 +22,7 @@ Field3D DifferentialOperators::DDX(const Field3D& f, CELL_LOC outloc,

if (f.getMesh()->IncIntShear) {
// Using BOUT-06 style shifting
result += IntShiftTorsion * DDZ(f, outloc, method, region);
result += intShiftTorsion * DDZ(f, outloc, method, region);
}

return result;
Expand Down
Loading

0 comments on commit 71aa857

Please sign in to comment.