Skip to content

Commit 62b923b

Browse files
committed
FCITransform: Save R and Z coordinates to output
Reads cell center coordinates from the mesh, and saves to the output. This is to facilitate code coupling and visualisation.
1 parent 679058c commit 62b923b

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/mesh/parallel/fci.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,3 +346,9 @@ void FCITransform::integrateParallelSlices(Field3D& f) {
346346
f.ynext(map.offset) = map.integrate(f);
347347
}
348348
}
349+
350+
void FCITransform::outputVars(Options& output_options) {
351+
// Real-space coordinates of grid points
352+
output_options["R"].force(R, "FCI");
353+
output_options["Z"].force(Z, "FCI");
354+
}

src/mesh/parallel/fci.hxx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,15 @@ public:
7373
FCITransform() = delete;
7474
FCITransform(Mesh& mesh, const Coordinates::FieldMetric& dy, bool zperiodic = true,
7575
Options* opt = nullptr)
76-
: ParallelTransform(mesh, opt) {
76+
: ParallelTransform(mesh, opt), R{&mesh}, Z{&mesh} {
7777

7878
// check the coordinate system used for the grid data source
7979
FCITransform::checkInputGrid();
8080

81+
// Real-space coordinates of grid cells
82+
mesh.get(R, "R", 0.0, false);
83+
mesh.get(Z, "Z", 0.0, false);
84+
8185
auto forward_boundary_xin =
8286
std::make_shared<BoundaryRegionPar>("FCI_forward", BNDRY_PAR_FWD_XIN, +1, &mesh);
8387
auto backward_boundary_xin = std::make_shared<BoundaryRegionPar>(
@@ -142,6 +146,10 @@ public:
142146

143147
bool canToFromFieldAligned() const override { return false; }
144148

149+
/// Save mesh variables to output
150+
/// If R and Z(x,y,z) coordinates are in the input then these are saved to output.
151+
void outputVars(Options& output_options) override;
152+
145153
bool requiresTwistShift(bool UNUSED(twist_shift_enabled),
146154
[[maybe_unused]] YDirectionType ytype) override {
147155
// No Field3Ds require twist-shift, because they cannot be field-aligned
@@ -156,6 +164,9 @@ protected:
156164
private:
157165
/// FCI maps for each of the parallel slices
158166
std::vector<FCIMap> field_line_maps;
167+
168+
/// Real-space coordinates of grid points
169+
Field3D R, Z;
159170
};
160171

161172
#endif // BOUT_FCITRANSFORM_H

0 commit comments

Comments
 (0)