File field2d.hxx#
Definition of 2D scalar field class.
Copyright 2010 B.D.Dudson, S.Farley, M.V.Umansky, X.Q.Xu
Contact: Ben Dudson, bd512@york.ac.uk
This file is part of BOUT++.
BOUT++ is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
BOUT++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with BOUT++. If not, see http://www.gnu.org/licenses/.
Defines
-
BOUT_FIELD2D_H#
Functions
-
Field2D operator-(const Field2D &f)
Unary minus. Returns the negative of given field, iterates over whole domain including guard/boundary cells.
-
void checkData(const Field2D &f, const std::string ®ion = "RGN_NOBNDRY")
Check if the data is valid.
Throw an exception if
f
is not allocated or if any elements are non-finite (for CHECK > 2). Loops over all points including the boundaries by default (can be changed using thergn
argument
-
void invalidateGuards(Field2D &var)
Force guard cells of passed field
var
to NaN.
-
inline Field2D DC(const Field2D &f)#
Average in the Z direction Field2D has no Z direction — return input
- Parameters:
f – [in] Variable to average
- inline BOUT_HOST_DEVICE Field2D & ddt (Field2D &f)
Returns a reference to the time-derivative of a field
f
Wrapper around member function f.timeDeriv()
-
template<>
inline std::string toString(const Field2D &val)# toString template specialisation Defined in utils.hxx
-
class Field2D : public Field#
- #include <field2d.hxx>
2D X-Y scalar fields
Handles data for axisymmetric quantities. Essentially the same as the Field3D class.
Public Functions
-
Field2D(Mesh *localmesh = nullptr, CELL_LOC location_in = CELL_CENTRE, DirectionTypes directions_in = {YDirectionType::Standard, ZDirectionType::Average})#
Constructor, taking an optional mesh pointer This mesh pointer is not used until the data is allocated, since Field2D objects can be globals, created before a mesh has been created.
By default the global Mesh pointer (mesh) is used.
- Parameters:
localmesh – [in] The mesh which defines the field size.
-
Field2D(const Field2D &f)#
Copy constructor. After this both fields will share the same underlying data.
-
Field2D(BoutReal val, Mesh *localmesh = nullptr)#
Constructor. This creates a Field2D using the global Mesh pointer (mesh) allocates data, and assigns the value
val
to all points including boundary cells.
-
Field2D(Array<BoutReal> data, Mesh *localmesh, CELL_LOC location = CELL_CENTRE, DirectionTypes directions_in = {YDirectionType::Standard, ZDirectionType::Average})#
-
~Field2D() override#
Destructor
-
inline bool isAllocated() const#
Test if data is allocated.
-
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 Field2D &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 toCELL_CENTRE
instead.
-
inline virtual Field2D &setDirectionY(YDirectionType d) override#
-
inline bool hasParallelSlices() const#
Check if this field has yup and ydown fields.
-
Field2D &operator=(const Field2D &rhs)#
Assignment from Field2D. After this both fields will share the same underlying data. To make a true copy, call .allocate() after assignment, or use the copy() function.
-
Field2D &operator=(BoutReal rhs)#
Allocates data if not already allocated, then sets all cells to
rhs
-
const Region<Ind2D> &getRegion(REGION region) const#
Return a Region<Ind2D> reference to use to iterate over this field.
- inline BoutReal &BOUT_HOST_DEVICE operator[] (const Ind2D &d)
- inline const BoutReal &BOUT_HOST_DEVICE operator[] (const Ind2D &d) const
- BoutReal &BOUT_HOST_DEVICE operator[] (const Ind3D &d)
- const BoutReal &BOUT_HOST_DEVICE operator[] (const Ind3D &d) const
- inline BOUT_HOST_DEVICE BoutReal & operator() (int jx, int jy)
Access to the underlying data array.
If CHECK <= 2 then no checks are performed
If CHECK > 2 then both
jx
andjy
are bounds checked. This will significantly reduce performance.
- inline BOUT_HOST_DEVICE const BoutReal & operator() (int jx, int jy) const
- inline BOUT_HOST_DEVICE BoutReal & operator() (int jx, int jy, int jz)
DIrect access to underlying array. This version is for compatibility with Field3D objects
- inline BOUT_HOST_DEVICE const BoutReal & operator() (int jx, int jy, int jz) const
-
Field2D &operator-=(const Field2D &rhs)#
In-place subtraction. Copy-on-write used if data is shared.
-
Field2D &operator*=(const Field2D &rhs)#
In-place multiplication. Copy-on-write used if data is shared.
-
inline virtual bool is3D() const override#
True if variable is 3D.
-
inline virtual void doneComms() override#
-
virtual void applyBoundary(bool init = false) override#
-
inline void applyBoundary(const char *condition)#
-
virtual void applyTDerivBoundary() override#
-
inline virtual int size() const override#
Get the total number of points.
Private Members
-
int ny = {-1}#
-
Field2D(Mesh *localmesh = nullptr, CELL_LOC location_in = CELL_CENTRE, DirectionTypes directions_in = {YDirectionType::Standard, ZDirectionType::Average})#