OGS 6.2.1-97-g73d1aeda3
CreateMedium.cpp
Go to the documentation of this file.
1 
14 #include "Medium.h"
15 
16 #include <string>
17 #include "BaseLib/ConfigTree.h"
18 #include "ParameterLib/Parameter.h"
19 
20 #include "Properties/Properties.h"
21 
22 #include "CreatePhase.h"
23 #include "CreateProperty.h"
24 
25 namespace MaterialPropertyLib
26 {
27 std::unique_ptr<Medium> createMedium(
28  BaseLib::ConfigTree const& config,
29  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters)
30 {
31  // Parsing the phases
32  // Properties of phases may be not required in all the cases.
33  auto&& phases =
35  createPhases(config.getConfigSubtreeOptional("phases"), parameters);
36 
37  // Parsing medium properties, overwriting the defaults.
38  auto&& properties =
40  createProperties(config.getConfigSubtreeOptional("properties"),
41  parameters);
42 
43  if (phases.empty() && !properties)
44  {
45  OGS_FATAL("Neither tag <phases> nor tag <properties> has been found.");
46  }
47 
48  return std::make_unique<Medium>(std::move(phases), std::move(properties));
49 }
50 
51 } // namespace MaterialPropertyLib
std::unique_ptr< PropertyArray > createProperties(boost::optional< BaseLib::ConfigTree > const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters)
std::unique_ptr< Medium > createMedium(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters)
std::vector< std::unique_ptr< Phase > > createPhases(boost::optional< BaseLib::ConfigTree > const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters)
Definition: CreatePhase.cpp:86
#define OGS_FATAL(fmt,...)
Definition: Error.h:63
boost::optional< ConfigTree > getConfigSubtreeOptional(std::string const &root) const
Definition: ConfigTree.cpp:160