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 getNonFinal(const GuardedOptions &option)#
-
template<typename T>
T get(const Options &option, [[maybe_unused]] 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
-
template<typename T>
T get(const GuardedOptions &option, const std::string &location = "")#
-
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 isSetFinal(const GuardedOptions &option, const std::string &location = "")
-
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
-
bool isSetFinalNoBoundary(const GuardedOptions &option, const std::string &location = "")
-
template<typename T>
T getNoBoundary(const Options &option, [[maybe_unused]] 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, class GO, typename = hermes::EnableIfGuardedOption<GO>>
T getNoBoundary(GO &&option, const std::string &location = "")#
-
template<typename T>
bool hermesDataInvalid([[maybe_unused]] 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<>
inline bool hermesDataInvalid(const Field2D &value)# Check Field2D 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, class GO, typename = hermes::EnableIfGuardedOption<GO>>
decltype(auto) set(GO &&option, T value)#
-
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, class GO, typename = hermes::EnableIfGuardedOption<GO>>
decltype(auto) setBoundary(GO &&option, T value)#
-
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, class GO, typename = hermes::EnableIfGuardedOption<GO>>
decltype(auto) add(GO &&option, T value)#
-
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, class GO, typename = hermes::EnableIfGuardedOption<GO>>
decltype(auto) subtract(GO &&option, T value)#
-
struct SpeciesInformation#
- #include <component.hxx>
Simple struct to store information on the different types of species present in a simulation
Public Functions
-
inline SpeciesInformation(const std::vector<std::string> &electrons, const std::vector<std::string> &neutrals, const std::vector<std::string> &positive_ions, const std::vector<std::string> &negative_ions)#
-
inline SpeciesInformation(const std::initializer_list<std::string> species)#
Public Members
-
std::vector<std::string> electrons#
-
std::vector<std::string> neutrals#
-
std::vector<std::string> positive_ions#
-
std::vector<std::string> negative_ions#
-
std::vector<std::string> ions#
-
std::vector<std::string> charged#
-
std::vector<std::string> non_electrons#
-
std::vector<std::string> all_species#
Private Functions
-
inline void finish_construction()#
-
inline SpeciesInformation(const std::vector<std::string> &electrons, const std::vector<std::string> &neutrals, const std::vector<std::string> &positive_ions, const std::vector<std::string> &negative_ions)#
-
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 AnomalousDiffusion, BinormalSTPM, BraginskiiCollisions, BraginskiiConduction, BraginskiiElectronViscosity, BraginskiiFriction, BraginskiiHeatExchange, BraginskiiIonViscosity, BraginskiiThermalForce, ClassicalDiffusion, DetachmentController, DiamagneticDrift, Electromagnetic, ElectronForceBalance, EvolveDensity, EvolveEnergy, EvolveMomentum, EvolvePressure, FixedDensity, FixedFractionIons, FixedFractionRadiation< CoolingCurve >, FixedTemperature, FixedVelocity, Ionisation, Isothermal, NeutralBoundary, NeutralFullVelocity, NeutralMixed, NeutralParallelDiffusion, NoFlowBoundary, PolarisationDrift, Quasineutral, Recycling, RelaxPotential, SNBConduction, SOLKITNeutralParallelDiffusion, ScaleTimeDerivs, SetTemperature, SheathBoundary, SheathBoundaryInsulating, SheathBoundarySimple, SheathClosure, SimpleConduction, SimplePump, SoundSpeed, TemperatureFeedback, Transform, UpstreamDensityFeedback, Vorticity, ZeroCurrent, hermes::ReactionBase
Public Functions
-
inline Component(Permissions &&access_permissions)#
Initialise the
state_variable_acceesspermissions. Note that{all_species}in any variable names will be replaced with the names of all species being simulated (by callingdeclareAllSpecies(), which is done after all components are created by a ComponentSchedular).
-
inline virtual ~Component()#
-
void transform(Options &state)#
Modify the given simulation state. This method will wrap the state in a GuardedOptions object and pass that to the private implementation of transform provided by each component.
-
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.
-
void declareAllSpecies(const SpeciesInformation &info)#
Tell the component the name of all species in the simulation, by type. It will use this information to substitute the following placeholders in
state_variable_access:electrons (any electron species)
electrons2 (same as above, used for Cartesian product)
neutrals (species with no charge)
neutrals2 (same as above, used for Cartesian product)
positive_ions (ions with a positive charge)
positive_ions2 (same as above, used for Cartesian product)
negative_ions (ions with a negative charge)
negative_ions2 (same as above, used for Cartesian product)
ions (all ions, regardless of sign of charge)
ions2 (same as above, used for Cartesian product)
charged (ions and electrons)
charged2 (same as above, used for Cartesian product)
non_electrons (ions and neutrals)
non_electrons2 (same as above, used for Cartesian product)
all_species (ions, neutrals, and electrons)
all_species2 (same as above, used for Cartesian product)
At the end of this function there is a call to Permissions::checkNoRemainingSubstitutions. All substitutions must be completed or else an exception will be thrown.
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.
options – Component settings: options[name] are specific to this component
solver – Time-integration solver
Protected Functions
-
inline void setPermissions(const std::string &variable, const Permissions::AccessRights &rights)#
Set the level of access needed by this component for a particular variable.
-
inline void setPermissions(const Permissions::VarRights &info)#
-
inline void substitutePermissions(const std::string &label, const std::vector<std::string> &substitution)#
Replace a placeholder in the name of variables stored in the access control information for this component.
Private Functions
-
virtual void transform_impl(GuardedOptions &state) = 0#
The implementation of the transform method. Modify the given simulation state. All components must implement this function. It will only allow the reading from/writing to state variables with the appropriate permissiosn in
state_variable_access.
Private Members
-
Permissions state_variable_access#
Information on which state variables the transform method will read and write.
-
inline Component(Permissions &&access_permissions)#
-
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.
-
namespace hermes
Typedefs
-
template<class T>
using EnableIfGuardedOption = std::enable_if_t<std::is_base_of_v<GuardedOptions, T>># Enable a function if and only if
Tis a (subclass of)GuardedOptions
-
template<class T>