OGS
anonymous_namespace{CreatePhase.cpp} Namespace Reference

Functions

std::unique_ptr< MaterialPropertyLib::PhasecreatePhase (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

◆ createPhase()

std::unique_ptr< MaterialPropertyLib::Phase > anonymous_namespace{CreatePhase.cpp}::createPhase ( 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__type
Input File Parameter
prj__media__medium__phases__phase__Solid
Input File Parameter
prj__media__medium__phases__phase__FrozenLiquid
Input File Parameter
prj__media__medium__phases__phase__AqueousLiquid
Input File Parameter
prj__media__medium__phases__phase__Gas
Input File Parameter
prj__media__medium__phases__phase__components
Input File Parameter
prj__media__medium__phases__phase__properties

Definition at line 27 of file CreatePhase.cpp.

35{
36 using namespace MaterialPropertyLib;
37
39 auto&& phase_type = config.getConfigParameter<std::string>("type");
40
41 if (phase_type.empty())
42 {
43 OGS_FATAL("Phase type is a mandatory field and cannot be empty.");
44 }
45
46 std::array<std::string, 5> const allowed_phase_types = {
47 {
48 "Solid",
50 "FrozenLiquid",
52 "AqueousLiquid",
54 "Gas"}};
55
56 if (std::none_of(allowed_phase_types.begin(),
57 allowed_phase_types.end(),
58 [&phase_type](std::string const& type)
59 { return phase_type == type; }))
60 {
61 ERR("Phase type should be one of:");
62 for (auto const& type : allowed_phase_types)
63 {
64 ERR("{:s}", type);
65 }
66 OGS_FATAL("Wrong phase type '{:s}' given.", phase_type);
67 }
68
69 // Parsing of optional components.
70 auto components = createComponents(
71 geometry_dimension,
73 config.getConfigSubtreeOptional("components"), parameters,
74 local_coordinate_system, curves);
75
76 // Properties of optional properties.
77 auto properties = createProperties(
78 geometry_dimension,
80 config.getConfigSubtreeOptional("properties"), parameters,
81 local_coordinate_system, curves);
82
83 if (components.empty() && !properties)
84 {
86 "Neither tag <components> nor tag <properties> has been set for "
87 "the phase '{:s}'.",
88 phase_type);
89 }
90
91 return std::make_unique<Phase>(std::move(phase_type), std::move(components),
92 std::move(properties));
93}
#define OGS_FATAL(...)
Definition Error.h:26
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:48
std::vector< std::unique_ptr< Component > > createComponents(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)
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::createComponents(), MaterialPropertyLib::createProperties(), ERR(), BaseLib::ConfigTree::getConfigParameter(), BaseLib::ConfigTree::getConfigSubtreeOptional(), and OGS_FATAL.