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 > > const &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 > > 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__type
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 {"Solid", "FrozenLiquid", "AqueousLiquid", "NonAqueousLiquid", "Gas"}};
48
49 if (std::none_of(allowed_phase_types.begin(),
50 allowed_phase_types.end(),
51 [&phase_type](std::string const& type)
52 { return phase_type == type; }))
53 {
54 ERR("Phase type should be one of:");
55 for (auto const& type : allowed_phase_types)
56 {
57 ERR("{:s}", type);
58 }
59 OGS_FATAL("Wrong phase type '{:s}' given.", phase_type);
60 }
61
62 // Parsing of optional components.
63 auto components = createComponents(
64 geometry_dimension,
66 config.getConfigSubtreeOptional("components"), parameters,
67 local_coordinate_system, curves);
68
69 // Properties of optional properties.
70 auto properties = createProperties(
71 geometry_dimension,
73 config.getConfigSubtreeOptional("properties"), parameters,
74 local_coordinate_system, curves);
75
76 if (components.empty() && !properties)
77 {
79 "Neither tag <components> nor tag <properties> has been set for "
80 "the phase '{:s}'.",
81 phase_type);
82 }
83
84 return std::make_unique<Phase>(std::move(phase_type), std::move(components),
85 std::move(properties));
86}
#define OGS_FATAL(...)
Definition Error.h:26
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:45
std::unique_ptr< PropertyArray > createProperties(int const geometry_dimension, std::optional< 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)
std::vector< std::unique_ptr< Component > > createComponents(int const geometry_dimension, std::optional< 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)

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