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