File fieldperp.hxx

Functions

FieldPerp operator+(const FieldPerp &lhs, const FieldPerp &rhs)
FieldPerp operator+(const FieldPerp &lhs, const Field3D &rhs)
FieldPerp operator+(const FieldPerp &lhs, const Field2D &rhs)
FieldPerp operator+(const FieldPerp &lhs, BoutReal rhs)
FieldPerp operator+(BoutReal lhs, const FieldPerp &rhs)
FieldPerp operator-(const FieldPerp &lhs, const FieldPerp &rhs)
FieldPerp operator-(const FieldPerp &lhs, const Field3D &rhs)
FieldPerp operator-(const FieldPerp &lhs, const Field2D &rhs)
FieldPerp operator-(const FieldPerp &lhs, BoutReal rhs)
FieldPerp operator-(BoutReal lhs, const FieldPerp &rhs)
FieldPerp operator*(const FieldPerp &lhs, const FieldPerp &rhs)
FieldPerp operator*(const FieldPerp &lhs, const Field3D &rhs)
FieldPerp operator*(const FieldPerp &lhs, const Field2D &rhs)
FieldPerp operator*(const FieldPerp &lhs, BoutReal rhs)
FieldPerp operator*(BoutReal lhs, const FieldPerp &rhs)
FieldPerp operator/(const FieldPerp &lhs, const FieldPerp &rhs)
FieldPerp operator/(const FieldPerp &lhs, const Field3D &rhs)
FieldPerp operator/(const FieldPerp &lhs, const Field2D &rhs)
FieldPerp operator/(const FieldPerp &lhs, BoutReal rhs)
FieldPerp operator/(BoutReal lhs, const FieldPerp &rhs)
FieldPerp operator-(const FieldPerp &f)

Unary minus. Returns the negative of given field, iterates over whole domain including guard/boundary cells.

const FieldPerp sliceXZ(const Field3D &f, int y)

Create a FieldPerp by slicing a 3D field at a given y.

template<>
inline FieldPerp emptyFrom<FieldPerp>(const FieldPerp &f)

Return an empty shell field of some type derived from Field, with metadata copied and a data array that is allocated but not initialised.

void checkData(const FieldPerp &f, const std::string &region = "RGN_NOX")

Check if the data is valid.

inline void checkData(const FieldPerp &f, REGION region)
void invalidateGuards(FieldPerp &var)

Force guard cells of passed field var to NaN.

template<>
inline std::string toString(const FieldPerp &val)

toString template specialisation Defined in utils.hxx

bool operator==(const FieldPerp &a, const FieldPerp &b)

Test if two fields are the same, by checking that they are defined at the same y-index, and if the minimum absolute difference between them is less than 1e-10

std::ostream &operator<<(std::ostream &out, const FieldPerp &value)

Output a string describing a FieldPerp to a stream.

class FieldPerp : public Field
#include <fieldperp.hxx>

Represents a 2D field perpendicular to the magnetic field at a particular index in Y, which only varies in X-Z.

Primarily used inside field solvers

Public Types

using ind_type = IndPerp

Public Functions

FieldPerp(Mesh *fieldmesh = nullptr, CELL_LOC location_in = CELL_CENTRE, int yindex_in = -1, DirectionTypes directions_in = {YDirectionType::Standard, ZDirectionType::Standard})

Constructor

FieldPerp(const FieldPerp &f) = default

Copy constructor. After this the data will be shared (non unique)

FieldPerp(FieldPerp &&rhs) = default

Move constructor

FieldPerp(BoutReal val, Mesh *localmesh = nullptr)

Constructor. This creates a FieldPerp using the global Mesh pointer (mesh) allocates data, and assigns the value val to all points including boundary cells.

FieldPerp(Array<BoutReal> data, Mesh *fieldmesh, CELL_LOC location_in = CELL_CENTRE, int yindex_in = -1, DirectionTypes directions_in = {YDirectionType::Standard, ZDirectionType::Standard})

Constructor from Array and Mesh

~FieldPerp() override = default
FieldPerp &operator=(const FieldPerp &rhs)

Assignment operators

FieldPerp &operator=(FieldPerp &&rhs) = default
FieldPerp &operator=(BoutReal rhs)
const Region<IndPerp> &getRegion(REGION region) const

Return a Region<IndPerp> reference to use to iterate over this field.

const Region<IndPerp> &getRegion(const std::string &region_name) const
inline Region<IndPerp>::RegionIndices::const_iterator begin() const
inline Region<IndPerp>::RegionIndices::const_iterator end() const
inline BoutReal &operator[](const IndPerp &d)
inline const BoutReal &operator[](const IndPerp &d) const
inline BoutReal &operator[](const Ind3D &d)
inline const BoutReal &operator[](const Ind3D &d) const
inline int getIndex() const

Return the y index at which this field is defined. This value is local to each processor

int getGlobalIndex() const

Return the globally defined y index if it’s either an interior (grid) point, or a boundary point. Otherwise, return -1 to indicate a guard cell or an invalid value

inline FieldPerp &setIndex(int y)

Set the (local) y index at which this field is defined

This is used in arithmetic operations

FieldPerp &setIndexFromGlobal(int y_global)

Set the (local) y index at which this field is defined from a globally defined y index

Only use the global y index if it’s either an interior (grid) point, or a boundary point. Otherwise, sets yindex to -1 to indicate a guard cell or an invalid value

inline virtual FieldPerp &setLocation(CELL_LOC new_location) override

Set variable location for staggered grids to

Parameters

new_location – Throws BoutException if new_location is not CELL_CENTRE and staggered grids are turned off and checks are on. If checks are off, silently sets location to CELL_CENTRE instead.

inline virtual FieldPerp &setDirectionY(YDirectionType d) override
FieldPerp &allocate()

Ensure that data array is allocated and unique

inline bool isAllocated() const

True if the underlying data array is allocated.

inline const BoutReal *operator[](int jx) const
inline BoutReal *operator[](int jx)

Returns a C-style array (pointer to first element) in Z at a given X index. Used mainly for FFT routines

inline BoutReal &operator()(int jx, int jz)

Access to the underlying data array at a given x,z index

If CHECK > 2 then bounds checking is performed, otherwise no checks are performed

inline const BoutReal &operator()(int jx, int jz) const

Const (read-only) access to the underlying data array.

inline BoutReal &operator()(int jx, int jy, int jz)

Access to the underlying data array. (X,Y,Z) indices for consistency with other field types

inline const BoutReal &operator()(int jx, int jy, int jz) const
FieldPerp &operator+=(const FieldPerp &rhs)

Addition, modifying in-place. This loops over the entire domain, including guard/boundary cells

FieldPerp &operator+=(const Field3D &rhs)
FieldPerp &operator+=(const Field2D &rhs)
FieldPerp &operator+=(BoutReal rhs)
FieldPerp &operator-=(const FieldPerp &rhs)

Subtraction, modifying in place. This loops over the entire domain, including guard/boundary cells

FieldPerp &operator-=(const Field3D &rhs)
FieldPerp &operator-=(const Field2D &rhs)
FieldPerp &operator-=(BoutReal rhs)
FieldPerp &operator*=(const FieldPerp &rhs)

Multiplication, modifying in place. This loops over the entire domain, including guard/boundary cells

FieldPerp &operator*=(const Field3D &rhs)
FieldPerp &operator*=(const Field2D &rhs)
FieldPerp &operator*=(BoutReal rhs)
FieldPerp &operator/=(const FieldPerp &rhs)

Division, modifying in place. This loops over the entire domain, including guard/boundary cells

FieldPerp &operator/=(const Field3D &rhs)
FieldPerp &operator/=(const Field2D &rhs)
FieldPerp &operator/=(BoutReal rhs)
inline virtual int getNx() const override

Return the number of nx points

inline virtual int getNy() const override

Return the number of ny points

inline virtual int getNz() const override

Return the number of nz points

inline virtual bool is3D() const override

True if variable is 3D.

Private Members

int yindex = {-1}

The Y index at which this FieldPerp is defined.

int nx = {-1}

The size of the data array.

int nz = {-1}
Array<BoutReal> data

The underlying data array.

Friends

friend void swap(FieldPerp &first, FieldPerp &second) noexcept