Field¶
Interface¶
-
class
FieldDeviceHandler
¶ a device-compatible structure that represents a scalar field
Subclassed by mirheo::Field
Public Functions
-
real
operator()
(real3 x) const¶ Evaluate the field at a given position.
Warning
The position must be inside the subdomain enlarged with a given margin (see c Field)
- Return
- The scalar value at
x
- Parameters
x
: The position, in local coordinates
-
real
-
class
Field
: public mirheo::FieldDeviceHandler, public mirheo::MirSimulationObject¶ Driver class used to create a FieldDeviceHandler.
Subclassed by mirheo::FieldFromFile, mirheo::FieldFromFunction
Public Functions
-
Field
(const MirState *state, std::string name, real3 h, real3 margin)¶ Construct a
Field
object.- Parameters
state
: The global state of the systemname
: The name of the field objecth
: the grid sizemargin
: Additional margin to store in each rank
-
const FieldDeviceHandler &
handler
() const¶ - Return
- The handler that can be used on the device
-
Derived classes¶
-
class
FieldFromFile
: public mirheo::Field¶ a
Field
that can be initialized from a filePublic Functions
-
FieldFromFile
(const MirState *state, std::string name, std::string fieldFileName, real3 h, real3 margin)¶ Construct a FieldFromFile object.
The format of the file is custom. It is a single file that contains a header followed by the data grid data in binary format. The header is composed of two lines in ASCII format:
- domain size (3 floating point numbers)
- number of grid points (3 integers)
- Parameters
state
: The global state of the systemname
: The name of the field objectfieldFileName
: The input file nameh
: the grid sizemargin
: Additional margin to store in each rank
The data is an array that contains all grid values (x is the fast running index).
-
FieldFromFile
(FieldFromFile&&)¶ move constructor
-
-
class
FieldFromFunction
: public mirheo::Field¶ a
Field
that can be initialized from FieldFunctionPublic Functions
-
FieldFromFunction
(const MirState *state, std::string name, FieldFunction func, real3 h, real3 margin)¶ Construct a FieldFromFunction object.
The scalar values will be discretized and stored on the grid. This can be useful as one can have a general scalar field configured on the host (e.g. from python) but usable on the device.
- Parameters
state
: The global state of the systemname
: The name of the field objectfunc
: The scalar field functionh
: the grid sizemargin
: Additional margin to store in each rank
-
FieldFromFunction
(FieldFromFunction&&)¶ move constructor
-
Utilities¶
-
template <typename FieldHandler>
real3mirheo
::
computeGradient
(const FieldHandler &field, real3 x, real h)¶ compute the gradient of a scalar field using finite differences on the device
- Return
- The approximation of the gradient of
field
atx
- Template Parameters
FieldHandler
: Type of device handler describing the field. Must contain parenthesis operator
- Parameters
field
: The functor that describes the continuous scalar fieldx
: The position at which to compute the gradienth
: The step size used to compute the gradient