ProcessLib::SecondaryVariableCollection Class Referencefinal

Detailed Description

Handles configuration of several secondary variables from the project file.

Definition at line 113 of file SecondaryVariable.h.

#include <SecondaryVariable.h>

Public Member Functions

void addNameMapping (std::string const &internal_name, std::string const &external_name)
 Register a variable with the given internal and external names. More...
void addSecondaryVariable (std::string const &internal_name, SecondaryVariableFunctions &&fcts)
SecondaryVariable const & get (std::string const &external_name) const
 Returns the secondary variable with the given external name. More...
std::map< std::string, std::string >::const_iterator begin () const
std::map< std::string, std::string >::const_iterator end () const

Private Attributes

std::map< std::string, std::string > _map_external_to_internal
std::map< std::string, SecondaryVariable_configured_secondary_variables

Member Function Documentation

◆ addNameMapping()

void ProcessLib::SecondaryVariableCollection::addNameMapping ( std::string const &  internal_name,
std::string const &  external_name 

Register a variable with the given internal and external names.

Definition at line 15 of file SecondaryVariable.cpp.

17 {
18  // TODO check for missing secondary vars.
19  // TODO check primary vars, too
21  _map_external_to_internal, external_name, internal_name,
22  "Secondary variable names must be unique.");
23 }
std::map< std::string, std::string > _map_external_to_internal
void insertIfKeyUniqueElseError(Map &map, Key const &key, Value &&value, std::string const &error_message)
Definition: Algorithm.h:106

References _map_external_to_internal, and BaseLib::insertIfKeyUniqueElseError().

Referenced by ProcessLib::createSecondaryVariables().

◆ addSecondaryVariable()

void ProcessLib::SecondaryVariableCollection::addSecondaryVariable ( std::string const &  internal_name,
SecondaryVariableFunctions &&  fcts 

Set up a secondary variable.

internal_namethe tag in the project file associated with this secondary variable.
fctsfunctions that compute the variable.
Only variables requested by the user in the project file will be configured. All other variables are silently ignored.

Definition at line 25 of file SecondaryVariable.cpp.

27 {
29  .emplace(std::make_pair(
30  internal_name,
31  SecondaryVariable{internal_name /* TODO change */,
32  std::move(fcts)}))
33  .second)
34  {
36  "The secondary variable with internal name `{:s}' has already been "
37  "set up.",
38  internal_name);
39  }
40 }
#define OGS_FATAL(...)
Definition: Error.h:26
std::map< std::string, SecondaryVariable > _configured_secondary_variables

References _configured_secondary_variables, and OGS_FATAL.

Referenced by ProcessLib::ComponentTransport::ComponentTransportProcess::initializeConcreteProcess(), ProcessLib::HeatConduction::HeatConductionProcess::initializeConcreteProcess(), ProcessLib::HT::HTProcess::initializeConcreteProcess(), ProcessLib::LiquidFlow::LiquidFlowProcess::initializeConcreteProcess(), ProcessLib::RichardsComponentTransport::RichardsComponentTransportProcess::initializeConcreteProcess(), ProcessLib::RichardsFlow::RichardsFlowProcess::initializeConcreteProcess(), ProcessLib::SmallDeformationNonlocal::SmallDeformationNonlocalProcess< DisplacementDim >::initializeConcreteProcess(), ProcessLib::SteadyStateDiffusion::SteadyStateDiffusion::initializeConcreteProcess(), ProcessLib::ThermalTwoPhaseFlowWithPP::ThermalTwoPhaseFlowWithPPProcess::initializeConcreteProcess(), ProcessLib::ThermoRichardsFlow::ThermoRichardsFlowProcess::initializeConcreteProcess(), ProcessLib::TwoPhaseFlowWithPP::TwoPhaseFlowWithPPProcess::initializeConcreteProcess(), ProcessLib::TwoPhaseFlowWithPrho::TwoPhaseFlowWithPrhoProcess::initializeConcreteProcess(), and ProcessLib::TES::TESProcess::initializeSecondaryVariables().

◆ begin()

std::map< std::string, std::string >::const_iterator ProcessLib::SecondaryVariableCollection::begin ( ) const

Definition at line 43 of file SecondaryVariable.cpp.

44 {
45  return _map_external_to_internal.cbegin();
46 }

References _map_external_to_internal.

◆ end()

std::map< std::string, std::string >::const_iterator ProcessLib::SecondaryVariableCollection::end ( ) const

Definition at line 49 of file SecondaryVariable.cpp.

50 {
51  return _map_external_to_internal.cend();
52 }

References _map_external_to_internal.

◆ get()

SecondaryVariable const & ProcessLib::SecondaryVariableCollection::get ( std::string const &  external_name) const

Returns the secondary variable with the given external name.

Definition at line 54 of file SecondaryVariable.cpp.

56 {
57  auto const it = _map_external_to_internal.find(external_name);
59  if (it == _map_external_to_internal.cend())
60  {
62  "A secondary variable with external name '{:s}' has not been set "
63  "up.",
64  external_name);
65  }
67  auto const& internal_name = it->second;
68  auto const it2 = _configured_secondary_variables.find(internal_name);
70  if (it2 == _configured_secondary_variables.end())
71  {
73  "A secondary variable with internal name '{:s}' has not been set "
74  "up.",
75  internal_name);
76  }
78  return it2->second;
79 }

References _configured_secondary_variables, _map_external_to_internal, and OGS_FATAL.

Referenced by addSecondaryVariablesToMesh().

Member Data Documentation

◆ _configured_secondary_variables

std::map<std::string, SecondaryVariable> ProcessLib::SecondaryVariableCollection::_configured_secondary_variables

Collection of all configured secondary variables. Maps the internal variable name to the corresponding SecondaryVariable instance.

Definition at line 148 of file SecondaryVariable.h.

Referenced by addSecondaryVariable(), and get().

◆ _map_external_to_internal

std::map<std::string, std::string> ProcessLib::SecondaryVariableCollection::_map_external_to_internal

Maps external variable names to internal ones. The external variable names are used, e.g., for output.

Definition at line 143 of file SecondaryVariable.h.

Referenced by addNameMapping(), begin(), end(), and get().

The documentation for this class was generated from the following files: