OGS
CreateViscosityModel.cpp
Go to the documentation of this file.
1
14
15#include "BaseLib/ConfigTree.h"
16#include "BaseLib/Error.h"
21
22namespace MaterialLib
23{
24namespace Fluid
25{
31static std::unique_ptr<FluidProperty> createLinearPressureDependentViscosity(
32 BaseLib::ConfigTree const& config)
33{
35 config.checkConfigParameter("type", "LinearPressure");
36
38 const auto mu0 = config.getConfigParameter<double>("mu0");
39
41 const auto p0 = config.getConfigParameter<double>("p0");
42
44 const auto gamma = config.getConfigParameter<double>("gamma");
45
46 return std::make_unique<LinearPressureDependentViscosity>(mu0, p0, gamma);
47}
48
54static std::unique_ptr<FluidProperty> createTemperatureDependentViscosity(
55 BaseLib::ConfigTree const& config)
56{
58 config.checkConfigParameter("type", "TemperatureDependent");
59
61 const auto mu0 = config.getConfigParameter<double>("mu0");
62
64 const auto Tc = config.getConfigParameter<double>("tc");
65
67 const auto Tv = config.getConfigParameter<double>("tv");
68
69 return std::make_unique<TemperatureDependentViscosity>(mu0, Tc, Tv);
70}
71
72std::unique_ptr<FluidProperty> createViscosityModel(
73 BaseLib::ConfigTree const& config)
74{
76 auto const type = config.peekConfigParameter<std::string>("type");
77
78 if (type == "Constant")
79 {
81 config.checkConfigParameter("type", "Constant");
82 return std::make_unique<ConstantFluidProperty>(
84 config.getConfigParameter<double>("value"));
85 }
86 if (type == "LinearPressure")
87 {
89 }
90 if (type == "TemperatureDependent")
91 {
93 }
94 if (type == "Vogels")
95 {
97 config.checkConfigParameter("type", "Vogels");
98
99 INFO("Using Vogels model, which gives viscosity in SI unit, Pa s");
100 auto const fluid_type =
102 config.peekConfigParameter<std::string>("liquid_type");
103 if (fluid_type == "Water")
104 {
106 config.checkConfigParameter("liquid_type", "Water");
107
108 const VogelsViscosityConstantsWater constants;
109 return std::make_unique<
111 constants);
112 }
113 if (fluid_type == "CO2")
114 {
116 config.checkConfigParameter("liquid_type", "CO2");
117 const VogelsViscosityConstantsCO2 constants;
118 return std::make_unique<
120 constants);
121 }
122 if (fluid_type == "CH4")
123 {
125 config.checkConfigParameter("liquid_type", "CH4");
126 const VogelsViscosityConstantsCH4 constants;
127 return std::make_unique<
129 constants);
130 }
131
132 OGS_FATAL(
133 "The fluid type {:s} for Vogels model is unavailable.\n"
134 "The available fluid types are Water, CO2 and CH4\n",
135 fluid_type.data());
136 }
137
138 OGS_FATAL(
139 "The viscosity type {:s} is unavailable.\n"
140 "The available types are \n\tConstant, \n\tLinearPressure "
141 "\n\tTemperatureDependent, \n\tVogels\n",
142 type.data());
143}
144
145} // namespace Fluid
146} // namespace MaterialLib
A function for creating viscosity model.
#define OGS_FATAL(...)
Definition Error.h:26
Declaration of class for the pressure dependent viscosity model.
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
A linear temperature dependent viscosity model.
Declaration of class for the pressure dependent viscosity model.
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 > createLinearPressureDependentViscosity(BaseLib::ConfigTree const &config)
std::unique_ptr< FluidProperty > createViscosityModel(BaseLib::ConfigTree const &config)
static std::unique_ptr< FluidProperty > createTemperatureDependentViscosity(BaseLib::ConfigTree const &config)