File component.hxx

Defines

HERMES_COMPONENT_H
TOSTRING_(x)
TOSTRING(x)
IS_SET(option)
IS_SET_NOBOUNDARY(option)
GET_VALUE(Type, option)
GET_NOBOUNDARY(Type, option)

Typedefs

template<typename DerivedType>
using RegisterComponent = ComponentFactory::RegisterInFactory<DerivedType>

Simpler name for Factory registration helper class

Usage:

#include "component.hxx"
namespace {
RegisterComponent<MyComponent> registercomponentmine("mycomponent");
}

Functions

template<typename T>
T getNonFinal(const Options &option)

Faster non-printing getter for Options If this fails, it will throw BoutException

This version allows the value to be modified later i.e. the value returned is not the “final” value.

Template Parameters:

T – The type the option should be converted to

Parameters:

option – The Option whose value will be returned

template<typename T>
T get(const Options &option, const std::string &location = "")

Faster non-printing getter for Options If this fails, it will throw BoutException

This marks the value as final, both in the domain and the boundary. Subsequent calls to “set” this option will raise an exception.

Template Parameters:

T – The type the option should be converted to

Parameters:
  • option – The Option whose value will be returned

  • location – An optional string to indicate where this value is used

bool isSetFinal(const Options &option, const std::string &location = "")

Check if an option can be fetched Sets the final flag so setting the value afterwards will lead to an error

bool isSetFinalNoBoundary(const Options &option, const std::string &location = "")

Check if an option can be fetched Sets the final flag so setting the value in the domain afterwards will lead to an error

template<typename T>
T getNoBoundary(const Options &option, const std::string &location = "")

Faster non-printing getter for Options If this fails, it will throw BoutException

This marks the value as final in the domain. The caller is assuming that the boundary values are non-final or invalid. Subsequent calls to “set” this option will raise an exception, but calls to “setBoundary” will not.

Template Parameters:

T – The type the option should be converted to

Parameters:
  • option – The Option whose value will be returned

  • location – An optional string to indicate where this value is used

template<typename T>
bool hermesDataInvalid(const T &value)

Check whether value is valid, returning true if invalid i.e contains non-finite values

template<>
inline bool hermesDataInvalid(const Field3D &value)

Check Field3D values. Doesn’t check boundary cells

template<typename T>
Options &set(Options &option, T value)

Set values in an option. This could be optimised, but currently the is_value private variable would need to be modified.

If the value has been used then raise an exception (if CHECK >= 1) This is to prevent values being modified after use.

Template Parameters:

T – The type of the value to set. Usually this is inferred

template<typename T>
Options &setBoundary(Options &option, T value)

Set values in an option. This could be optimised, but currently the is_value private variable would need to be modified.

This version only checks that the boundary cells have not already been used by a call to get, not a call to getNoBoundary or getNonFinal.

Template Parameters:

T – The type of the value to set. Usually this is inferred

template<typename T>
Options &add(Options &option, T value)

Add value to a given option. If not already set, treats as zero and sets the option to the value.

Template Parameters:

T – The type of the value to add. The existing value will be casted to this type

Parameters:
  • option – The value to modify (or set if not already set)

  • value – The quantity to add.

template<typename T>
Options &subtract(Options &option, T value)

Add value to a given option. If not already set, treats as zero and sets the option to the value.

Parameters:
  • option – The value to modify (or set if not already set)

  • value – The quantity to add.

template<typename T>
void set_with_attrs(Options &option, T value, std::initializer_list<std::pair<std::string, Options::AttributeType>> attrs)
struct Component
#include <component.hxx>

Interface for a component of a simulation model

The constructor of derived types should have signature (std::string name, Options &options, Solver *solver)

Subclassed by AmjuelReaction, AnomalousDiffusion, BinormalSTPM, ClassicalDiffusion, Collisions, DetachmentController, DiamagneticDrift, Electromagnetic, ElectronForceBalance, ElectronViscosity, EvolveDensity, EvolveEnergy, EvolveMomentum, EvolvePressure, FixedDensity, FixedFractionIons, FixedFractionRadiation< CoolingCurve >, FixedTemperature, FixedVelocity, HydrogenChargeExchange, IonViscosity, Ionisation, Isothermal, NeutralBoundary, NeutralFullVelocity, NeutralMixed, NeutralParallelDiffusion, NoFlowBoundary, OpenADAS, OpenADASChargeExchange, PolarisationDrift, Quasineutral, Recycling, RelaxPotential, SNBConduction, SOLKITHydrogenChargeExchange, SOLKITNeutralParallelDiffusion, ScaleTimeDerivs, SetTemperature, SheathBoundary, SheathBoundaryInsulating, SheathBoundarySimple, SheathClosure, SimpleConduction, SimplePump, SoundSpeed, TemperatureFeedback, ThermalForce, Transform, UpstreamDensityFeedback, Vorticity, ZeroCurrent

Public Functions

inline virtual ~Component()
virtual void transform(Options &state) = 0

Modify the given simulation state All components must implement this function

inline virtual void finally(const Options &state)

Use the final simulation state to update internal state (e.g. time derivatives)

inline virtual void outputVars(Options &state)

Add extra fields for output, or set attributes e.g docstrings.

inline virtual void restartVars(Options &state)

Add extra fields to restart files.

inline virtual void precon(const Options &state, BoutReal gamma)

Preconditioning.

Public Static Functions

static std::unique_ptr<Component> create(const std::string &type, const std::string &name, Options &options, Solver *solver)

Create a Component

Parameters:
  • type – The name of the component type to create (e.g. “evolve_density”)

  • name – The species/name for this instance.

  • optionsComponent settings: options[name] are specific to this component

  • solver – Time-integration solver

class ComponentFactory : public Factory<Component, ComponentFactory, const std::string&, Options&, Solver*>
#include <component.hxx>

A factory for creating Components on demand, based on a string type name The template arguments after ComponentFactory are the types of the arguments to the Component constructor.

Public Static Attributes

static constexpr auto type_name = "Component"
static constexpr auto section_name = "component"
static constexpr auto option_name = "type"
static constexpr auto default_type = "none"