File coordinates.hxx

Defines

DERIV_FUNC_REGION_ENUM_TO_STRING(func, T)
GRAD_FUNC_REGION_ENUM_TO_STRING(func, T)
class Coordinates
#include <coordinates.hxx>

Represents a coordinate system, and associated operators

This is a container for a collection of metric tensor components

Public Functions

Coordinates(Mesh *mesh, Options *options = nullptr)

Standard constructor from input.

Coordinates(Mesh *mesh, Options *options, const CELL_LOC loc, const Coordinates *coords_in, bool force_interpolate_from_centre = false)

Constructor interpolating from another Coordinates object By default attempts to read staggered Coordinates from grid data source, interpolating from CELL_CENTRE if not present. Set force_interpolate_from_centre argument to true to always interpolate (useful if CELL_CENTRE Coordinates have been changed, so reading from file would not be correct).

Coordinates(Mesh *mesh, Field2D dx, Field2D dy, BoutReal dz, Field2D J, Field2D Bxy, Field2D g11, Field2D g22, Field2D g33, Field2D g12, Field2D g13, Field2D g23, Field2D g_11, Field2D g_22, Field2D g_33, Field2D g_12, Field2D g_13, Field2D g_23, Field2D ShiftTorsion, Field2D IntShiftTorsion, bool calculate_geometry = true)

A constructor useful for testing purposes. To use it, inherit from Coordinates. If calculate_geometry is true (default), calculate the non-uniform variables, Christoffel symbols

Coordinates &operator=(Coordinates&&)
~Coordinates()
void outputVars(Datafile &file)

Adds variables to the output file, for post-processing

Must be a better way so that Coordinates doesn’t depend on Datafile

BoutReal zlength() const

Length of the Z domain. Used for FFTs.

int geometry(bool recalculate_staggered = true, bool force_interpolate_from_centre = false)

Calculate differential geometry quantities from the metric tensor.

int calcCovariant(const std::string &region = "RGN_ALL")

Invert contravatiant metric to get covariant components.

int calcContravariant(const std::string &region = "RGN_ALL")

Invert covariant metric to get contravariant components.

int jacobian()

Calculate J and Bxy.

void setParallelTransform(std::unique_ptr<ParallelTransform> pt)

Set the parallel (y) transform for this mesh. Mostly useful for tests.

ParallelTransform &getParallelTransform()

Return the parallel transform.

Field2D DDX(const Field2D &f, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT", const std::string &region = "RGN_NOBNDRY")
Field2D DDX(const Field2D &f, CELL_LOC outloc, const std::string &method, REGION region)
Field2D DDX(const Field2D &f, CELL_LOC outloc, DIFF_METHOD method, REGION region = RGN_NOBNDRY)
Field2D DDY(const Field2D &f, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT", const std::string &region = "RGN_NOBNDRY")
Field2D DDY(const Field2D &f, CELL_LOC outloc, const std::string &method, REGION region)
Field2D DDY(const Field2D &f, CELL_LOC outloc, DIFF_METHOD method, REGION region = RGN_NOBNDRY)
Field2D DDZ(const Field2D &f, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT", const std::string &region = "RGN_NOBNDRY")
Field2D DDZ(const Field2D &f, CELL_LOC outloc, const std::string &method, REGION region)
Field2D DDZ(const Field2D &f, CELL_LOC outloc, DIFF_METHOD method, REGION region = RGN_NOBNDRY)
Field2D Grad_par(const Field2D &var, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT")

Gradient along magnetic field b.Grad(f)

Field2D Grad_par(const Field2D &f, CELL_LOC outloc, DIFF_METHOD method)
Field3D Grad_par(const Field3D &var, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT")
Field3D Grad_par(const Field3D &f, CELL_LOC outloc, DIFF_METHOD method)
Field2D Vpar_Grad_par(const Field2D &v, const Field2D &f, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT")

Advection along magnetic field V*b.Grad(f)

Field2D Vpar_Grad_par(const Field2D &v, const Field2D &f, CELL_LOC outloc, DIFF_METHOD method)
Field3D Vpar_Grad_par(const Field3D &v, const Field3D &f, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT")
Field3D Vpar_Grad_par(const Field3D &v, const Field3D &f, CELL_LOC outloc, DIFF_METHOD method)
Field2D Div_par(const Field2D &f, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT")

Divergence along magnetic field Div(b*f) = B.Grad(f/B)

Field2D Div_par(const Field2D &f, CELL_LOC outloc, DIFF_METHOD method)
Field3D Div_par(const Field3D &f, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT")
Field3D Div_par(const Field3D &f, CELL_LOC outloc, DIFF_METHOD method)
Field2D Grad2_par2(const Field2D &f, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT")
Field2D Grad2_par2(const Field2D &f, CELL_LOC outloc, DIFF_METHOD method)
Field3D Grad2_par2(const Field3D &f, CELL_LOC outloc = CELL_DEFAULT, const std::string &method = "DEFAULT")
Field3D Grad2_par2(const Field3D &f, CELL_LOC outloc, DIFF_METHOD method)
Field2D Delp2(const Field2D &f, CELL_LOC outloc = CELL_DEFAULT, bool useFFT = true)
Field3D Delp2(const Field3D &f, CELL_LOC outloc = CELL_DEFAULT, bool useFFT = true)
FieldPerp Delp2(const FieldPerp &f, CELL_LOC outloc = CELL_DEFAULT, bool useFFT = true)
Field2D Laplace_par(const Field2D &f, CELL_LOC outloc = CELL_DEFAULT)
Field3D Laplace_par(const Field3D &f, CELL_LOC outloc = CELL_DEFAULT)
Field2D Laplace(const Field2D &f, CELL_LOC outloc = CELL_DEFAULT)
Field3D Laplace(const Field3D &f, CELL_LOC outloc = CELL_DEFAULT)

Public Members

Field2D dx
Field2D dy

Mesh spacing in x and y.

BoutReal dz

Mesh spacing in Z.

bool non_uniform

True if corrections for non-uniform mesh spacing should be included in operators.

Field2D d1_dx
Field2D d1_dy

2nd-order correction for non-uniform meshes d/di(1/dx) and d/di(1/dy)

Field2D J

Coordinate system Jacobian, so volume of cell is J*dx*dy*dz.

Field2D Bxy

Magnitude of B = nabla z times nabla x.

Field2D g11

Contravariant metric tensor (g^{ij})

Field2D g22
Field2D g33
Field2D g12
Field2D g13
Field2D g23
Field2D g_11

Covariant metric tensor.

Field2D g_22
Field2D g_33
Field2D g_12
Field2D g_13
Field2D g_23
Field2D G1_11

Christoffel symbol of the second kind (connection coefficients)

Field2D G1_22
Field2D G1_33
Field2D G1_12
Field2D G1_13
Field2D G1_23
Field2D G2_11
Field2D G2_22
Field2D G2_33
Field2D G2_12
Field2D G2_13
Field2D G2_23
Field2D G3_11
Field2D G3_22
Field2D G3_33
Field2D G3_12
Field2D G3_13
Field2D G3_23
Field2D G1
Field2D G2
Field2D G3
Field2D ShiftTorsion

d pitch angle / dx. Needed for vector differentials (Curl)

Field2D IntShiftTorsion

Integrated shear (I in BOUT notation)

Private Functions

void setParallelTransform(Options *options)

Set the parallel (y) transform from the options file. Used in the constructor to create the transform object.

Private Members

int nz
Mesh *localmesh
CELL_LOC location
std::unique_ptr<ParallelTransform> transform = {nullptr}

Handles calculation of yup and ydown.