File fieldgenerators.hxx#

These classes are used by FieldFactory

Typedefs

using single_arg_op = BoutReal (*)(BoutReal)#

Template class to define generators around a C function.

using double_arg_op = BoutReal (*)(BoutReal, BoutReal)#

Template for a FieldGenerator with two input arguments.

class FieldValuePtr : public FieldGenerator#
#include <fieldgenerators.hxx>

Creates a Field Generator using a pointer to value WARNING: The value pointed to must remain in scope until this generator is finished

Public Functions

inline FieldValuePtr(BoutReal *val)#
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

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.

Private Members

BoutReal *ptr#
template<single_arg_op Op>
class FieldGenOneArg : public FieldGenerator#

Public Functions

inline FieldGenOneArg(FieldGeneratorPtr g, const std::string &name = "function")#

< Template for single-argument function

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

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.

inline virtual std::string str() const override#

Create a string representation of the generator, for debugging output.

Private Members

FieldGeneratorPtr gen#
std::string name#

A string describing the function, to be printed in error messages.

template<double_arg_op Op>
class FieldGenTwoArg : public FieldGenerator#

Public Functions

inline FieldGenTwoArg(FieldGeneratorPtr a, FieldGeneratorPtr b, const std::string &name = "function")#

< Template for two-argument function

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

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.

inline virtual std::string str() const override#

Create a string representation of the generator, for debugging output.

Private Members

FieldGeneratorPtr A#
FieldGeneratorPtr B#
std::string name#

The name of the function, to be printed in error messages.

class FieldATan : public FieldGenerator#
#include <fieldgenerators.hxx>

Arc (Inverse) tangent. Either one or two argument versions.

Public Functions

inline FieldATan(FieldGeneratorPtr a, FieldGeneratorPtr b = nullptr)#
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

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.

class FieldGaussian : public FieldGenerator#
#include <fieldgenerators.hxx>

Gaussian distribution, taking mean and width arguments.

Public Functions

inline FieldGaussian(FieldGeneratorPtr xin, FieldGeneratorPtr sin)#
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

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.

class FieldHeaviside : public FieldGenerator#
#include <fieldgenerators.hxx>

Heaviside function, switches between 0 and 1.

Public Functions

inline FieldHeaviside(FieldGeneratorPtr g)#
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

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.

inline virtual std::string str() const override#

Create a string representation of the generator, for debugging output.

Private Members

FieldGeneratorPtr gen#
class FieldMin : public FieldGenerator#
#include <fieldgenerators.hxx>

Minimum.

Public Functions

FieldMin() = default#
inline FieldMin(const std::list<FieldGeneratorPtr> args)#
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

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.

Private Members

std::list<FieldGeneratorPtr> input#
class FieldMax : public FieldGenerator#
#include <fieldgenerators.hxx>

Maximum.

Public Functions

FieldMax() = default#
inline FieldMax(const std::list<FieldGeneratorPtr> args)#
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

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.

Private Members

std::list<FieldGeneratorPtr> input#
class FieldClamp : public FieldGenerator#
#include <fieldgenerators.hxx>

Clamp

Force a value to be in specified range Also called clip e.g. in NumPy, but in C++17 std::clamp is in <algorithm>

Note that the result is not well defined if low > high

Public Functions

FieldClamp() = default#
inline FieldClamp(FieldGeneratorPtr value, FieldGeneratorPtr low, FieldGeneratorPtr high)#
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

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.

Private Members

FieldGeneratorPtr value#

The value to be clamped.

FieldGeneratorPtr low#
FieldGeneratorPtr high#

The range within which the result will be.

class FieldRound : public FieldGenerator#
#include <fieldgenerators.hxx>

Generator to round to the nearest integer.

Public Functions

inline FieldRound(FieldGeneratorPtr g)#
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

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.

Private Members

FieldGeneratorPtr gen#
class FieldBallooning : public FieldGenerator#

Public Functions

inline FieldBallooning(Mesh *m, FieldGeneratorPtr a = nullptr, int n = 3)#
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

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.

Private Members

Mesh *mesh#
FieldGeneratorPtr arg#
int ball_n#
class FieldMixmode : public FieldGenerator#

Public Functions

FieldMixmode(FieldGeneratorPtr a = nullptr, BoutReal seed = 0.5)#
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

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.

Private Functions

BoutReal genRand(BoutReal seed)#

Generate a random number between 0 and 1 (exclusive) given an arbitrary seed value

This PRNG has no memory, i.e. you need to call it with a different seed each time.

Private Members

FieldGeneratorPtr arg#
BoutReal phase[14]#
class FieldTanhHat : public FieldGenerator#

Public Functions

inline FieldTanhHat(FieldGeneratorPtr xin, FieldGeneratorPtr widthin, FieldGeneratorPtr centerin, FieldGeneratorPtr steepnessin)#
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

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.

class FieldWhere : public FieldGenerator#

Public Functions

inline FieldWhere(FieldGeneratorPtr test, FieldGeneratorPtr gt0, FieldGeneratorPtr lt0)#
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

inline virtual double 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.

inline virtual std::string str() const override#

Create a string representation of the generator, for debugging output.