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 > > const &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 > > const & 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 24 of file CreateComponent.cpp.

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

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