File field_data.hxx#

Class inherited by any field wanting to use Communicator or Solver objects.

Copyright 2010 B.D.Dudson, S.Farley, M.V.Umansky, X.Q.Xu

Contact: Ben Dudson,

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


class FieldData#
#include <field_data.hxx>

Base class for both scalar and vector fields, holds common information about the grid, coordinates, and boundaries

Subclassed by Field, Vector2D, Vector3D

Public Functions

FieldData() = default#
FieldData(const FieldData &other)#
FieldData(FieldData &&other) = default#
FieldData &operator=(const FieldData &other)#
FieldData &operator=(FieldData &&other) noexcept#
virtual ~FieldData()#
FieldData(Mesh *localmesh, CELL_LOC location_in = CELL_LOC::centre)#
virtual FieldData &setLocation(CELL_LOC new_location)#

Set variable location for staggered grids to


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.

virtual CELL_LOC getLocation() const#

Get variable location.

virtual bool is3D() const = 0#

True if variable is 3D.

inline virtual int elementSize() const#

Number of BoutReals in one element.

inline virtual void doneComms()#
void setBoundary(const std::string &name)#

Set the boundary conditions.

void copyBoundary(const FieldData &f)#

Copy the boundary conditions from another field.

inline virtual void applyBoundary(bool init = false)#
inline virtual void applyTDerivBoundary()#
inline virtual void applyParallelBoundary()#
inline virtual void applyParallelBoundary(BoutReal t)#
inline virtual void applyParallelBoundary(const std::string &condition)#
inline virtual void applyParallelBoundary(const std::string &region, const std::string &condition)#
void addBndryFunction(FuncPtr userfunc, BndryLoc location)#
void addBndryGenerator(FieldGeneratorPtr gen, BndryLoc location)#
FieldGeneratorPtr getBndryGenerator(BndryLoc location)#
Mesh *getMesh() const#

Returns a pointer to the Mesh object used by this field.

Coordinates *getCoordinates() const#

Returns a pointer to the Coordinates object at this field’s location from the mesh this field is on.

Coordinates *getCoordinates(CELL_LOC loc) const#

Returns a pointer to the Coordinates object at the requested location from the mesh this field is on. If loc is CELL_DEFAULT then return coordinates at field location

inline bool isBoundarySet() const#

Has setBoundary been called?

inline std::vector<BoundaryOp*> getBoundaryOps() const#

Get boundary conditions.

inline std::vector<BoundaryOpPar*> getBoundaryOpPars() const#

Get parallel boundary conditions.

Protected Attributes

Mesh *fieldmesh = {nullptr}#

Grid information, etc. Owned by the simulation or global object.

Private Members

std::vector<BoundaryOp*> bndry_op#

Boundary conditions.

bool boundaryIsCopy = {false}#

True if bndry_op is a copy.

bool boundaryIsSet = {false}#

Set to true when setBoundary called.

std::vector<BoundaryOpPar*> bndry_op_par#

Boundary conditions.

std::map<BndryLoc, FieldGeneratorPtr> bndry_generator#
mutable std::weak_ptr<Coordinates> fieldCoordinates = {}#

Coordinates used by this field, owned by fieldmesh

CELL_LOC location = {CELL_CENTRE}#

Location of the variable in the cell.


friend void swap(FieldData &first, FieldData &second) noexcept#