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 18 of file CreatePhase.cpp.

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