OGS
CreateRelativePermeabilityModel.cpp
Go to the documentation of this file.
1
14
15#include <array>
16#include <memory>
17#include <string>
18#include <vector>
19
20#include "BaseLib/ConfigTree.h"
21#include "BaseLib/Error.h"
30
31namespace MaterialLib
32{
33namespace PorousMedium
34{
40std::unique_ptr<RelativePermeability> createWettingPhaseVanGenuchten(
41 BaseLib::ConfigTree const& config)
42{
44 config.checkConfigParameter("type", "WettingPhaseVanGenuchten");
45
47 const auto Sr = config.getConfigParameter<double>("sr");
48
50 const auto Smax = config.getConfigParameter<double>("smax");
51
53 const auto m = config.getConfigParameter<double>("m");
54 if (m < 0. || m > 1.0)
55 {
57 "The exponent parameter of WettingPhaseVanGenuchten relative\n"
58 " permeability model, m, must be in an interval of [0, 1]");
59 }
61 const auto krel_min = config.getConfigParameter<double>("krel_min");
62
63 return std::make_unique<WettingPhaseVanGenuchten>(Sr, Smax, m, krel_min);
64}
65
71std::unique_ptr<RelativePermeability> createNonWettingPhaseVanGenuchten(
72 BaseLib::ConfigTree const& config)
73{
75 config.checkConfigParameter("type", "NonWettingPhaseVanGenuchten");
76
78 const auto Sr = config.getConfigParameter<double>("sr");
79
81 const auto Smax = config.getConfigParameter<double>("smax");
82
84 const auto m = config.getConfigParameter<double>("m");
85 if (m < 0. || m > 1.0)
86 {
88 "The exponent parameter of NonWettingPhaseVanGenuchten relative\n"
89 " permeability model, m, must be in an interval of [0, 1]");
90 }
91
93 const auto krel_min = config.getConfigParameter<double>("krel_min");
94
95 return std::make_unique<NonWettingPhaseVanGenuchten>(Sr, Smax, m, krel_min);
96}
97
103std::unique_ptr<RelativePermeability> createWettingPhaseBrooksCoreyOilGas(
104 BaseLib::ConfigTree const& config)
105{
107 config.checkConfigParameter("type", "WettingPhaseBrooksCoreyOilGas");
108
110 const auto Sr = config.getConfigParameter<double>("sr");
111
113 const auto Smax = config.getConfigParameter<double>("smax");
114
116 const auto m = config.getConfigParameter<double>("m");
117 if (m < 1.0) // m >= 1
118 {
119 OGS_FATAL(
120 "The exponent parameter of WettingPhaseBrooksCoreyOilGas\n"
121 "relative permeability model, m, must not be smaller than 1");
122 }
123
125 const auto krel_min = config.getConfigParameter<double>("krel_min");
126
127 return std::make_unique<WettingPhaseBrooksCoreyOilGas>(
128 Sr, Smax, m, krel_min);
129}
130
136std::unique_ptr<RelativePermeability> createNonWettingPhaseBrooksCoreyOilGas(
137 BaseLib::ConfigTree const& config)
138{
140 config.checkConfigParameter("type", "NonWettingPhaseBrooksCoreyOilGas");
141
143 const auto Sr = config.getConfigParameter<double>("sr");
144
146 const auto Smax = config.getConfigParameter<double>("smax");
147
149 const auto m = config.getConfigParameter<double>("m");
150 if (m < 1.0) // m >= 1
151 {
152 OGS_FATAL(
153 "The exponent parameter of NonWettingPhaseBrooksCoreyOilGas\n"
154 "relative permeability model, m, must not be smaller than 1");
155 }
156
158 const auto krel_min = config.getConfigParameter<double>("krel_min");
159
160 return std::make_unique<NonWettingPhaseBrooksCoreyOilGas>(
161 Sr, Smax, m, krel_min);
162}
163
164std::unique_ptr<RelativePermeability> createRelativePermeabilityModel(
165 BaseLib::ConfigTree const& config)
166{
168 auto const type = config.peekConfigParameter<std::string>("type");
169
170 if (type == "WettingPhaseVanGenuchten")
171 {
172 return createWettingPhaseVanGenuchten(config);
173 }
174 if (type == "NonWettingPhaseVanGenuchten")
175 {
177 }
178 if (type == "WettingPhaseBrooksCoreyOilGas")
179 {
181 }
182 if (type == "NonWettingPhaseBrooksCoreyOilGas")
183 {
185 }
186 if (type == "Curve")
187 {
189 config.checkConfigParameter("type", "Curve");
190
192 auto const& curve_config = config.getConfigSubtree("curve");
193
195 MathLib ::PiecewiseLinearInterpolation>(curve_config);
196 return std::make_unique<RelativePermeabilityCurve>(std::move(curve));
197 }
198
199 OGS_FATAL(
200 "The relative permeability model {:s} is unavailable.\n"
201 "The available models are:"
202 "\n\tWettingPhaseVanGenuchten,"
203 "\n\tNonWettingPhaseVanGenuchten,"
204 "\n\tWettingPhaseBrooksCoreyOilGas,"
205 "\n\tNonWettingPhaseBrooksCoreyOilGas,",
206 "\n\tCurve.\n",
207 type.data());
208}
209
210} // namespace PorousMedium
211} // namespace MaterialLib
#define OGS_FATAL(...)
Definition Error.h:26
Definition of the PiecewiseLinearInterpolation class.
T peekConfigParameter(std::string const &param) const
T getConfigParameter(std::string const &param) const
ConfigTree getConfigSubtree(std::string const &root) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
std::unique_ptr< RelativePermeability > createRelativePermeabilityModel(BaseLib::ConfigTree const &config)
std::unique_ptr< RelativePermeability > createWettingPhaseVanGenuchten(BaseLib::ConfigTree const &config)
std::unique_ptr< RelativePermeability > createNonWettingPhaseBrooksCoreyOilGas(BaseLib::ConfigTree const &config)
std::unique_ptr< RelativePermeability > createNonWettingPhaseVanGenuchten(BaseLib::ConfigTree const &config)
std::unique_ptr< RelativePermeability > createWettingPhaseBrooksCoreyOilGas(BaseLib::ConfigTree const &config)
std::unique_ptr< CurveType > createPiecewiseLinearCurve(BaseLib::ConfigTree const &config)