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(Mesh *mesh = nullptr, Options *opt = nullptr)
~FieldFactory()
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 Mesh m at time t. The resulting field is at cell location loc.

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 Mesh m at time t. The resulting field is at cell location loc.

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 Mesh m at time t. The resulting field is at cell location loc.

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

FieldFactory *get()

Get the Singleton object.

Protected Functions

FieldGeneratorPtr resolve(std::string &name) const

These functions called by the parser to resolve unknown symbols. This is used to enable options to be referred to in expressions.

Private Functions

const Options *findOption(const Options *opt, const std::string &name, std::string &val) const

Find an Options object which contains the given name.

Private Members

Mesh *fieldmesh

The default mesh for create functions.

bool transform_from_field_aligned = {true}

Should we transform input from field-aligned coordinates (if possible)?

const Options *options

The default options used in resolve(), can be temporarily overridden in parse()/create2D()/create3D()

std::list<std::string> lookup

Names currently being parsed.

std::map<std::string, FieldGeneratorPtr> cache

Cache parsed strings so repeated evaluations don’t result in allocating more generators.

class FieldFunction : public FieldGenerator

Public Functions

FieldFunction()
FieldFunction(FuncPtr userfunc)
BoutReal generate(BoutReal x, BoutReal y, BoutReal z, BoutReal t)

Generate a value at the given coordinates (x,y,z,t) This should be deterministic, always returning the same value given the same inputs

Private Members

FuncPtr func
class FieldNull : public FieldGenerator

Public Functions

FieldNull()
BoutReal generate(BoutReal x, BoutReal y, BoutReal z, BoutReal t)

Generate a value at the given coordinates (x,y,z,t) This should be deterministic, always returning the same value given the same inputs

FieldGeneratorPtr clone(const std::list<FieldGeneratorPtr> args)

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: A (possibly empty) list of arguments to the generator function

Public Static Functions

static FieldGeneratorPtr get()

Singeton.