File field_factory.hxx#
Functions
-
FieldGeneratorPtr generator(BoutReal value)
Helper function to create a FieldValue generator from a BoutReal.
-
FieldGeneratorPtr generator(BoutReal *ptr)
Helper function to create a FieldValuePtr from a pointer to BoutReal.
-
class FieldFactory : public ExpressionParser#
Public Functions
-
~FieldFactory() override = default#
-
Field2D create2D(const std::string &value, const Options *opt = nullptr, Mesh *m = nullptr, CELL_LOC loc = CELL_CENTRE, BoutReal t = 0.0) const#
Create a 2D field by parsing a string and evaluating the expression using the given options
opt
, over Meshm
at timet
. The resulting field is at cell locationloc
.
-
Field3D create3D(const std::string &value, const Options *opt = nullptr, Mesh *m = nullptr, CELL_LOC loc = CELL_CENTRE, BoutReal t = 0.0) const#
Create a 3D field by parsing a string and evaluating the expression using the given options
opt
, over Meshm
at timet
. The resulting field is at cell locationloc
.
-
FieldPerp createPerp(const std::string &value, const Options *opt = nullptr, Mesh *m = nullptr, CELL_LOC loc = CELL_CENTRE, BoutReal t = 0.0) const#
Create a FieldPerp by parsing a string and evaluating the expression using the given options
opt
, over Meshm
at timet
. The resulting field is at cell locationloc
.
-
FieldGeneratorPtr parse(const std::string &input, const Options *opt = nullptr) const#
Parse a string into a tree of generators.
-
Field2D create2D(FieldGeneratorPtr generator, Mesh *m = nullptr, CELL_LOC loc = CELL_CENTRE, BoutReal t = 0.0) const#
Create a 2D field from a generator, over a given mesh at a given cell location and time.
-
Field3D create3D(FieldGeneratorPtr generator, Mesh *m = nullptr, CELL_LOC loc = CELL_CENTRE, BoutReal t = 0.0) const#
Create a 3D field from a generator, over a given mesh at a given cell location and time.
-
FieldPerp createPerp(FieldGeneratorPtr generator, Mesh *m = nullptr, CELL_LOC loc = CELL_CENTRE, BoutReal t = 0.0) const#
Create a FieldPerp from a generator, over a given mesh at a given cell location and time.
-
void cleanCache()#
clean the cache of parsed strings
Public Static Functions
-
static FieldFactory *get()#
Get the Singleton object.
Protected Functions
-
virtual FieldGeneratorPtr resolve(const std::string &name) const override#
These functions called by the parser to resolve unknown symbols. This is used to enable options to be referred to in expressions.
-
virtual std::multiset<ExpressionParser::FuzzyMatch> fuzzyFind(const std::string &name, std::string::size_type max_distance = 2) const override#
Find approximate matches for
name
in the known generators.max_distance
controls the similarity of results.Returns a set of possible matches ordered by similarity to
name
. Adistance
of 1 means: a single insertion, deletion, substitution, or transposition; that the case differs, for example, “key” and “KEY” match with distance 1
Private Functions
Private Members
-
bool transform_from_field_aligned = {true}#
Should we transform input from field-aligned coordinates (if possible)?
-
int max_recursion_depth = {0}#
-
mutable const Options *options#
The default options used in resolve(), can be temporarily overridden in parse()/create2D()/create3D()
-
mutable std::map<std::string, FieldGeneratorPtr> cache#
Cache parsed strings so repeated evaluations don’t result in allocating more generators.
-
~FieldFactory() override = default#
-
class FieldFunction : public FieldGenerator#
Public Functions
-
FieldFunction() = delete#
-
inline virtual BoutReal generate(const bout::generator::Context &pos) override#
Generate a value at the given coordinates (x,y,z,t) This should be deterministic, always returning the same value given the same inputs
Note: The default implementations of generate call each other; the implementor of a FieldGenerator type must implement one of them or an infinite recursion results. This is for backward compatibility for users and implementors. In a future version this function will be made pure virtual.
-
FieldFunction() = delete#
-
class FieldNull : public FieldGenerator#
Public Functions
-
FieldNull() = default#
-
inline virtual BoutReal generate(const bout::generator::Context&) override#
Generate a value at the given coordinates (x,y,z,t) This should be deterministic, always returning the same value given the same inputs
Note: The default implementations of generate call each other; the implementor of a FieldGenerator type must implement one of them or an infinite recursion results. This is for backward compatibility for users and implementors. In a future version this function will be made pure virtual.
-
inline virtual FieldGeneratorPtr clone(const std::list<FieldGeneratorPtr> args) override#
Virtual constructor. Makes a copy of this FieldGenerator, initialised with the given list of arguments. It is up to the implementations to test whether the correct number of arguments is passed.
- Parameters:
args – [in] A (possibly empty) list of arguments to the generator function
Public Static Functions
-
static inline FieldGeneratorPtr get()#
Singeton.
-
FieldNull() = default#