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"
24
25namespace MaterialLib
26{
27namespace Fluid
28{
34static std::unique_ptr<FluidProperty> createLiquidDensity(
35 BaseLib::ConfigTree const& config)
36{
38 config.checkConfigParameter("type", "LiquidDensity");
39
41 const auto beta = config.getConfigParameter<double>("beta");
43 const auto rho0 = config.getConfigParameter<double>("rho0");
45 const auto T0 = config.getConfigParameter<double>("temperature0");
47 const auto p0 = config.getConfigParameter<double>("p0");
49 const auto E = config.getConfigParameter<double>("bulk_modulus");
50 return std::make_unique<LiquidDensity>(beta, rho0, T0, p0, E);
51}
52
58static std::unique_ptr<FluidProperty> createLinearTemperatureDependentDensity(
59 BaseLib::ConfigTree const& config)
60{
62 config.checkConfigParameter("type", "TemperatureDependent");
63
65 const auto rho0 = config.getConfigParameter<double>("rho0");
67 const auto T0 = config.getConfigParameter<double>("temperature0");
69 const auto beta = config.getConfigParameter<double>("beta");
70 return std::make_unique<LinearTemperatureDependentDensity>(rho0, T0, beta);
71}
72
73static std::unique_ptr<FluidProperty> createLinearConcentrationDependentDensity(
74 BaseLib::ConfigTree const& config)
75{
77 config.checkConfigParameter("type", "ConcentrationDependent");
78
79 const auto reference_density =
81 config.getConfigParameter<double>("reference_density");
82 const auto reference_concentration =
84 config.getConfigParameter<double>("reference_concentration");
85 const auto fluid_density_difference_ratio =
87 config.getConfigParameter<double>("fluid_density_difference_ratio");
88 return std::make_unique<LinearConcentrationDependentDensity>(
89 reference_density,
90 reference_concentration,
91 fluid_density_difference_ratio);
92}
93static std::unique_ptr<FluidProperty>
95 BaseLib::ConfigTree const& config)
96{
98 config.checkConfigParameter("type", "ConcentrationAndPressureDependent");
99
100 const auto reference_density =
102 config.getConfigParameter<double>("reference_density");
103 const auto reference_concentration =
105 config.getConfigParameter<double>("reference_concentration");
106 const auto fluid_density_concentration_difference_ratio =
108 config.getConfigParameter<double>(
109 "fluid_density_concentration_difference_ratio");
110 const auto reference_pressure =
112 config.getConfigParameter<double>("reference_pressure");
113 const auto fluid_density_pressure_difference_ratio =
115 config.getConfigParameter<double>(
116 "fluid_density_pressure_difference_ratio");
117 return std::make_unique<LinearConcentrationAndPressureDependentDensity>(
118 reference_density,
119 reference_concentration,
120 fluid_density_concentration_difference_ratio,
121 reference_pressure,
122 fluid_density_pressure_difference_ratio);
123}
124
125std::unique_ptr<FluidProperty> createFluidDensityModel(
126 BaseLib::ConfigTree const& config)
127{
129 auto const type = config.peekConfigParameter<std::string>("type");
130
131 if (type == "Constant")
132 {
134 config.checkConfigParameter("type", "Constant");
135 return std::make_unique<ConstantFluidProperty>(
137 config.getConfigParameter<double>("value"));
138 }
139 if (type == "LiquidDensity")
140 {
141 return createLiquidDensity(config);
142 }
143 if (type == "TemperatureDependent")
144 {
146 }
147 if (type == "ConcentrationDependent")
148 {
150 }
151 if (type == "ConcentrationAndPressureDependent")
152 {
154 }
155 if (type == "IdealGasLaw")
156 {
158 config.checkConfigParameter("type", "IdealGasLaw");
159 return std::make_unique<IdealGasLaw>(
161 config.getConfigParameter<double>("molar_mass"));
162 }
163
164 OGS_FATAL(
165 "The density type {:s} is unavailable.\n"
166 "The available types are: \n\tConstant, \n\tLiquidDensity, "
167 "\n\tTemperatureDependent, \n\tIdealGasLaw."
168 "\n\tWaterDensityIAPWSIF97Region1\n",
169 type.data());
170}
171
172} // namespace Fluid
173} // namespace MaterialLib
create an instance of a fluid density class.
#define OGS_FATAL(...)
Definition Error.h:26
Declaration of class IdealGasLow for fluid density by the ideal gas law depending on one variable lin...
T peekConfigParameter(std::string const &param) const
T getConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
static std::unique_ptr< FluidProperty > createLinearConcentrationDependentDensity(BaseLib::ConfigTree const &config)
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 > createLinearTemperatureDependentDensity(BaseLib::ConfigTree const &config)