OGS 6.2.0-244-g47b8a9a9d
ProcessLib::SecondaryVariableCollection Class Referencefinal

Detailed Description

Handles configuration of several secondary variables from the project file.

Definition at line 109 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 14 of file SecondaryVariable.cpp.

References _map_external_to_internal, and BaseLib::insertIfKeyUniqueElseError().

Referenced by ProcessLib::createSecondaryVariables().

16 {
17  // TODO check for missing secondary vars.
18  // TODO check primary vars, too
20  _map_external_to_internal, external_name, internal_name,
21  "Secondary variable names must be unique.");
22 }
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:104

◆ addSecondaryVariable()

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

Set up a secondary variable.

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

Definition at line 24 of file SecondaryVariable.cpp.

References _configured_secondary_variables, and OGS_FATAL.

Referenced by ProcessLib::Process::finishNamedFunctionsInitialization(), ProcessLib::HeatConduction::HeatConductionProcess::initializeConcreteProcess(), ProcessLib::RichardsFlow::RichardsFlowProcess::initializeConcreteProcess(), ProcessLib::SmallDeformationNonlocal::SmallDeformationNonlocalProcess< DisplacementDim >::initializeConcreteProcess(), ProcessLib::TwoPhaseFlowWithPrho::TwoPhaseFlowWithPrhoProcess::initializeConcreteProcess(), ProcessLib::TwoPhaseFlowWithPP::TwoPhaseFlowWithPPProcess::initializeConcreteProcess(), ProcessLib::LIE::SmallDeformation::SmallDeformationProcess< DisplacementDim >::initializeConcreteProcess(), ProcessLib::ThermalTwoPhaseFlowWithPP::ThermalTwoPhaseFlowWithPPProcess::initializeConcreteProcess(), ProcessLib::HydroMechanics::HydroMechanicsProcess< DisplacementDim >::initializeConcreteProcess(), ProcessLib::RichardsMechanics::RichardsMechanicsProcess< DisplacementDim >::initializeConcreteProcess(), ProcessLib::ThermoHydroMechanics::ThermoHydroMechanicsProcess< DisplacementDim >::initializeConcreteProcess(), ProcessLib::SmallDeformation::SmallDeformationProcess< DisplacementDim >::initializeConcreteProcess(), ProcessLib::PhaseField::PhaseFieldProcess< DisplacementDim >::initializeConcreteProcess(), ProcessLib::ThermoMechanics::ThermoMechanicsProcess< DisplacementDim >::initializeConcreteProcess(), ProcessLib::GroundwaterFlow::GroundwaterFlowProcess::initializeConcreteProcess(), ProcessLib::HT::HTProcess::initializeConcreteProcess(), ProcessLib::ThermoMechanicalPhaseField::ThermoMechanicalPhaseFieldProcess< DisplacementDim >::initializeConcreteProcess(), ProcessLib::LiquidFlow::LiquidFlowProcess::initializeConcreteProcess(), ProcessLib::RichardsComponentTransport::RichardsComponentTransportProcess::initializeConcreteProcess(), ProcessLib::ComponentTransport::ComponentTransportProcess::initializeConcreteProcess(), and ProcessLib::TES::TESProcess::initializeSecondaryVariables().

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

◆ begin()

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

Definition at line 42 of file SecondaryVariable.cpp.

References _map_external_to_internal.

43 {
44  return _map_external_to_internal.cbegin();
45 }
std::map< std::string, std::string > _map_external_to_internal

◆ end()

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

Definition at line 48 of file SecondaryVariable.cpp.

References _map_external_to_internal.

49 {
50  return _map_external_to_internal.cend();
51 }
std::map< std::string, std::string > _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 53 of file SecondaryVariable.cpp.

References _configured_secondary_variables, _map_external_to_internal, and OGS_FATAL.

55 {
56  auto const it = _map_external_to_internal.find(external_name);
57 
58  if (it == _map_external_to_internal.cend())
59  {
60  OGS_FATAL(
61  "A secondary variable with external name '%s' has not been set up.",
62  external_name.c_str());
63  }
64 
65  auto const& internal_name = it->second;
66  auto const it2 = _configured_secondary_variables.find(internal_name);
67 
68  if (it2 == _configured_secondary_variables.end())
69  {
70  OGS_FATAL(
71  "A secondary variable with internal name '%s' has not been set up.",
72  internal_name.c_str());
73  }
74 
75  return it2->second;
76 }
std::map< std::string, std::string > _map_external_to_internal
#define OGS_FATAL(fmt,...)
Definition: Error.h:63
std::map< std::string, SecondaryVariable > _configured_secondary_variables

Member Data Documentation

◆ _configured_secondary_variables

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

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

Definition at line 144 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
private

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

Definition at line 139 of file SecondaryVariable.h.

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


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