File field_accessor.hxx

Defines

FIELD_ACCESSOR_H__

FieldAccessor

Provides quick but unsafe access to field and coordinate system data

Typedefs

using Field2DAccessor = FieldAccessor<location, Field2D>

Define a shorthand for 2D fields.

Functions

template<CELL_LOC location, class FieldType>
inline BoutRealArray &ddt(const FieldAccessor<location, FieldType> &fa)

Syntactic sugar for time derivative of a field

Usage:

ddt(fa)[i] =

where fa is a FieldAccessor, and i is an int

struct BoutRealArray
#include <field_accessor.hxx>

Simple wrapper around a BoutReal* 1D array

This is used to provide subscript operator [] for Ind3D

Public Functions

BoutRealArray() = delete

No default constructor.

inline explicit BoutRealArray(BoutReal *data)

Wrap a BoutReal pointer. This does not take ownership

inline BoutReal &operator[](int ind)
inline BoutReal &operator[](const Ind3D &ind)
inline const BoutReal &operator[](int ind) const
inline const BoutReal &operator[](const Ind3D &ind) const
inline operator BoutReal*()

Cast operators, so can be assigned to a raw pointer Note: Not explicit, so can be cast implicitly

inline operator const BoutReal*() const

Public Members

BoutReal *data
template<CELL_LOC location = CELL_CENTRE, class FieldType = Field3D>
struct FieldAccessor
#include <field_accessor.hxx>

Thin wrapper around field data, for fast but unsafe access

Template Parameters
  • location – Cell location of the data. This will be checked on construction

  • FieldType – Either Field3D (default) or Field2D

Public Functions

FieldAccessor() = delete

Remove default constructor.

inline explicit FieldAccessor(FieldType &f)

Constructor from Field3D

Parameters

f[in] The field to access. Must already be allocated

inline const BoutReal &operator[](int ind) const

Provide shorthand for access to field data. Does not convert between 3D and 2D indices, so fa[i] is equivalent to fa.data[i].

inline const BoutReal &operator[](const Ind3D &ind) const

Public Members

BoutRealArray data = {nullptr}

Pointer to the Field data.

BoutRealArray ddt = {nullptr}

Time-derivative data.

BoutRealArray yup = {nullptr}

Pointer to the Field yup data.

BoutRealArray ydown = {nullptr}

Pointer to the Field ydown data.

CoordinatesAccessor coords

Provides access to Coordinates data.

int nx = 0
int ny = 0
int nz = 0
int mesh_nz