OGS
anonymous_namespace{CreateComponent.cpp} Namespace Reference

Functions

std::unique_ptr< MaterialPropertyLib::ComponentcreateComponent (int const geometry_dimension, BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > &parameters, ParameterLib::CoordinateSystem const *const local_coordinate_system, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves)

Function Documentation

◆ createComponent()

std::unique_ptr< MaterialPropertyLib::Component > anonymous_namespace{CreateComponent.cpp}::createComponent ( int const geometry_dimension,
BaseLib::ConfigTree const & config,
std::vector< std::unique_ptr< ParameterLib::ParameterBase > > & parameters,
ParameterLib::CoordinateSystem const *const local_coordinate_system,
std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const & curves )
Input File Parameter
prj__media__medium__phases__phase__components__component__name
Input File Parameter
prj__media__medium__phases__phase__components__component__properties

Definition at line 16 of file CreateComponent.cpp.

24{
25 using namespace MaterialPropertyLib;
26 // Parsing the component name
28 auto const& component_name = config.getConfigParameter<std::string>("name");
29
30 // Check whether a name is given or not
31 if (component_name.empty())
32 {
33 OGS_FATAL("Component name is a mandatory field and cannot be empty.");
34 }
35
36 // Parsing component properties. If a component name is given and this
37 // component is predefined in the class implementation, properties
38 // become optional. The default values of properties will be overwritten
39 // if specified.
40 std::unique_ptr<PropertyArray> properties = createProperties(
41 geometry_dimension,
43 config.getConfigSubtreeOptional("properties"), parameters,
44 local_coordinate_system, curves);
45
46 // If a name is given, it must conform with one of the derived component
47 // names in the following list:
48 if (boost::iequals(component_name, "water"))
49 {
50 return std::make_unique<Water>(std::move(properties));
51 }
52
53 if (!properties)
54 {
55 // No component properties are provided. If the component is not
56 // specified, this results in a fatal error, since an unspecified
57 // component has no properties.
58 OGS_FATAL("No Properties defined for unspecified component");
59 }
60
61 return std::make_unique<Component>(component_name, std::move(properties));
62}
#define OGS_FATAL(...)
Definition Error.h:19
std::unique_ptr< PropertyArray > createProperties(int const geometry_dimension, std::optional< BaseLib::ConfigTree > const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > &parameters, ParameterLib::CoordinateSystem const *const local_coordinate_system, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves)

References MaterialPropertyLib::createProperties(), BaseLib::ConfigTree::getConfigParameter(), BaseLib::ConfigTree::getConfigSubtreeOptional(), and OGS_FATAL.