OGS 6.2.1-599-g427777a38.dirty.20191113164234
CreateProperty.cpp
Go to the documentation of this file.
1 
13 #include "CreateProperty.h"
14 
15 #include <string>
16 #include <vector>
17 #include "BaseLib/ConfigTree.h"
18 
20 
21 #include "Properties/Properties.h"
22 
23 #include "Component.h"
24 #include "Medium.h"
25 #include "Phase.h"
26 
27 namespace
28 {
29 std::unique_ptr<MaterialPropertyLib::Property> createProperty(
30  BaseLib::ConfigTree const& config,
31  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters)
32 {
33  using namespace MaterialPropertyLib;
34  // Parsing the property type:
36  auto const property_type = config.peekConfigParameter<std::string>("type");
37 
38  if (property_type == "Constant")
39  {
40  return createConstant(config);
41  }
42  if (property_type == "Linear")
43  {
44  return createLinearProperty(config);
45  }
46 
47  if (property_type == "Exponential")
48  {
49  return createExponentialProperty(config);
50  }
51 
52  if (property_type == "Parameter")
53  {
54  return createParameterProperty(config, parameters);
55  }
56 
57  if (boost::iequals(property_type, "IdealGasLaw"))
58  {
59  return createIdealGasLaw(config);
60  }
61 
62  if (boost::iequals(property_type, "SaturationBrooksCorey"))
63  {
64  return createSaturationBrooksCorey(config);
65  }
66 
67  if (boost::iequals(property_type, "RelPermBrooksCorey"))
68  {
69  return createRelPermBrooksCorey(config);
70  }
71 
72  if (boost::iequals(property_type, "SaturationLiakopoulos"))
73  {
74  return createSaturationLiakopoulos(config);
75  }
76 
77  if (boost::iequals(property_type, "RelPermLiakopoulos"))
78  {
79  return createRelPermLiakopoulos(config);
80  }
81 
82  // If none of the above property types are found, OGS throws an error.
83  OGS_FATAL("The specified component property type '%s' was not recognized",
84  property_type.c_str());
85 }
86 } // namespace
87 
88 namespace MaterialPropertyLib
89 {
90 std::unique_ptr<PropertyArray> createProperties(
91  boost::optional<BaseLib::ConfigTree> const& config,
92  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters)
93 {
94  if (!config)
95  {
96  return nullptr;
97  }
98 
100  auto const& property_configs = config->getConfigSubtreeList("property");
101  if (property_configs.empty())
102  {
103  return nullptr;
104  }
105 
106  auto properties = std::make_unique<PropertyArray>();
107 
108  for (auto property_config : property_configs)
109  {
110  // Parsing the property name:
111  auto const property_name =
113  property_config.getConfigParameter<std::string>("name");
114  // Create a new property based on the configuration subtree:
115  auto property = createProperty(property_config, parameters);
116 
117  // Insert the new property at the right position into the components
118  // private PropertyArray:
119  (*properties)[convertStringToProperty(property_name)] =
120  std::move(property);
121  }
122  return properties;
123 }
124 
125 } // namespace MaterialPropertyLib
std::unique_ptr< ExponentialProperty > createExponentialProperty(BaseLib::ConfigTree const &config)
std::unique_ptr< ParameterProperty > createParameterProperty(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters)
std::unique_ptr< LinearProperty > createLinearProperty(BaseLib::ConfigTree const &config)
std::unique_ptr< SaturationBrooksCorey > createSaturationBrooksCorey(BaseLib::ConfigTree const &config)
std::unique_ptr< Constant > createConstant(BaseLib::ConfigTree const &config)
std::unique_ptr< PropertyArray > createProperties(boost::optional< BaseLib::ConfigTree > const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters)
std::unique_ptr< MaterialPropertyLib::Property > createProperty(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters)
std::unique_ptr< SaturationLiakopoulos > createSaturationLiakopoulos(BaseLib::ConfigTree const &config)
std::unique_ptr< RelPermBrooksCorey > createRelPermBrooksCorey(BaseLib::ConfigTree const &config)
std::unique_ptr< RelPermLiakopoulos > createRelPermLiakopoulos(BaseLib::ConfigTree const &config)
T peekConfigParameter(std::string const &param) const
PropertyType convertStringToProperty(std::string const &inString)
Definition: PropertyType.h:89
std::unique_ptr< IdealGasLaw > createIdealGasLaw(BaseLib::ConfigTree const &config)
#define OGS_FATAL(fmt,...)
Definition: Error.h:64