OGS
CreateFluidDensityModel.cpp
Go to the documentation of this file.
1 
13 
14 #include <array>
15 
16 #include "BaseLib/ConfigTree.h"
17 #include "BaseLib/Error.h"
18 #include "IdealGasLaw.h"
22 #include "LiquidDensity.h"
25 
26 namespace MaterialLib
27 {
28 namespace Fluid
29 {
35 static std::unique_ptr<FluidProperty> createLiquidDensity(
36  BaseLib::ConfigTree const& config)
37 {
39  config.checkConfigParameter("type", "LiquidDensity");
40 
42  const auto beta = config.getConfigParameter<double>("beta");
44  const auto rho0 = config.getConfigParameter<double>("rho0");
46  const auto T0 = config.getConfigParameter<double>("temperature0");
48  const auto p0 = config.getConfigParameter<double>("p0");
50  const auto E = config.getConfigParameter<double>("bulk_modulus");
51  return std::make_unique<LiquidDensity>(beta, rho0, T0, p0, E);
52 }
53 
59 static std::unique_ptr<FluidProperty> createLinearTemperatureDependentDensity(
60  BaseLib::ConfigTree const& config)
61 {
63  config.checkConfigParameter("type", "TemperatureDependent");
64 
66  const auto rho0 = config.getConfigParameter<double>("rho0");
68  const auto T0 = config.getConfigParameter<double>("temperature0");
70  const auto beta = config.getConfigParameter<double>("beta");
71  return std::make_unique<LinearTemperatureDependentDensity>(rho0, T0, beta);
72 }
73 
74 static std::unique_ptr<FluidProperty> createLinearConcentrationDependentDensity(
75  BaseLib::ConfigTree const& config)
76 {
78  config.checkConfigParameter("type", "ConcentrationDependent");
79 
80  const auto reference_density =
82  config.getConfigParameter<double>("reference_density");
83  const auto reference_concentration =
85  config.getConfigParameter<double>("reference_concentration");
86  const auto fluid_density_difference_ratio =
88  config.getConfigParameter<double>("fluid_density_difference_ratio");
89  return std::make_unique<LinearConcentrationDependentDensity>(
91  reference_concentration,
92  fluid_density_difference_ratio);
93 }
94 static std::unique_ptr<FluidProperty>
96  BaseLib::ConfigTree const& config)
97 {
99  config.checkConfigParameter("type", "ConcentrationAndPressureDependent");
100 
101  const auto reference_density =
103  config.getConfigParameter<double>("reference_density");
104  const auto reference_concentration =
106  config.getConfigParameter<double>("reference_concentration");
107  const auto fluid_density_concentration_difference_ratio =
109  config.getConfigParameter<double>(
110  "fluid_density_concentration_difference_ratio");
111  const auto reference_pressure =
113  config.getConfigParameter<double>("reference_pressure");
114  const auto fluid_density_pressure_difference_ratio =
116  config.getConfigParameter<double>(
117  "fluid_density_pressure_difference_ratio");
118  return std::make_unique<LinearConcentrationAndPressureDependentDensity>(
120  reference_concentration,
121  fluid_density_concentration_difference_ratio,
123  fluid_density_pressure_difference_ratio);
124 }
125 
126 std::unique_ptr<FluidProperty> createFluidDensityModel(
127  BaseLib::ConfigTree const& config)
128 {
130  auto const type = config.peekConfigParameter<std::string>("type");
131 
132  if (type == "Constant")
133  {
135  config.checkConfigParameter("type", "Constant");
136  return std::make_unique<ConstantFluidProperty>(
138  config.getConfigParameter<double>("value"));
139  }
140  if (type == "LiquidDensity")
141  {
142  return createLiquidDensity(config);
143  }
144  if (type == "TemperatureDependent")
145  {
147  }
148  if (type == "ConcentrationDependent")
149  {
151  }
152  if (type == "ConcentrationAndPressureDependent")
153  {
155  }
156  if (type == "IdealGasLaw")
157  {
159  config.checkConfigParameter("type", "IdealGasLaw");
160  return std::make_unique<IdealGasLaw>(
162  config.getConfigParameter<double>("molar_mass"));
163  }
164  if (type == "WaterDensityIAPWSIF97Region1")
165  {
166  return std::make_unique<WaterDensityIAPWSIF97Region1>();
167  }
168 
169  OGS_FATAL(
170  "The density type {:s} is unavailable.\n"
171  "The available types are: \n\tConstant, \n\tLiquidDensity, "
172  "\n\tTemperatureDependent, \n\tIdealGasLaw."
173  "\n\tWaterDensityIAPWSIF97Region1\n",
174  type.data());
175 }
176 
177 } // namespace Fluid
178 } // namespace MaterialLib
create an instance of a fluid density class.
#define OGS_FATAL(...)
Definition: Error.h:26
T peekConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, T const &value) const
T getConfigParameter(std::string const &param) const
std::unique_ptr< FluidProperty > createFluidDensityModel(BaseLib::ConfigTree const &config)
static std::unique_ptr< FluidProperty > createLinearConcentrationAndPressureDependentDensity(BaseLib::ConfigTree const &config)
static std::unique_ptr< FluidProperty > createLiquidDensity(BaseLib::ConfigTree const &config)
static std::unique_ptr< FluidProperty > createLinearConcentrationDependentDensity(BaseLib::ConfigTree const &config)
static std::unique_ptr< FluidProperty > createLinearTemperatureDependentDensity(BaseLib::ConfigTree const &config)