OGS 6.2.1-97-g73d1aeda3
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"
22 
25 
28 #include "RelativePermeability.h"
32 
33 namespace MaterialLib
34 {
35 namespace PorousMedium
36 {
42 std::unique_ptr<RelativePermeability> createWettingPhaseVanGenuchten(
43  BaseLib::ConfigTree const& config)
44 {
46  config.checkConfigParameter("type", "WettingPhaseVanGenuchten");
47 
49  const auto Sr = config.getConfigParameter<double>("sr");
50 
52  const auto Smax = config.getConfigParameter<double>("smax");
53 
55  const auto m = config.getConfigParameter<double>("m");
56  if (m < 0. || m > 1.0)
57  {
58  OGS_FATAL(
59  "The exponent parameter of WettingPhaseVanGenuchten relative\n"
60  " permeability model, m, must be in an interval of [0, 1]");
61  }
63  const auto krel_min = config.getConfigParameter<double>("krel_min");
64 
65  return std::make_unique<WettingPhaseVanGenuchten>(Sr, Smax, m, krel_min);
66 }
67 
73 std::unique_ptr<RelativePermeability> createNonWettingPhaseVanGenuchten(
74  BaseLib::ConfigTree const& config)
75 {
77  config.checkConfigParameter("type", "NonWettingPhaseVanGenuchten");
78 
80  const auto Sr = config.getConfigParameter<double>("sr");
81 
83  const auto Smax = config.getConfigParameter<double>("smax");
84 
86  const auto m = config.getConfigParameter<double>("m");
87  if (m < 0. || m > 1.0)
88  {
89  OGS_FATAL(
90  "The exponent parameter of NonWettingPhaseVanGenuchten relative\n"
91  " permeability model, m, must be in an interval of [0, 1]");
92  }
93 
95  const auto krel_min = config.getConfigParameter<double>("krel_min");
96 
97  return std::make_unique<NonWettingPhaseVanGenuchten>(Sr, Smax, m, krel_min);
98 }
99 
105 std::unique_ptr<RelativePermeability> createWettingPhaseBrooksCoreyOilGas(
106  BaseLib::ConfigTree const& config)
107 {
109  config.checkConfigParameter("type", "WettingPhaseBrooksCoreyOilGas");
110 
112  const auto Sr = config.getConfigParameter<double>("sr");
113 
115  const auto Smax = config.getConfigParameter<double>("smax");
116 
118  const auto m = config.getConfigParameter<double>("m");
119  if (m < 1.0) // m >= 1
120  {
121  OGS_FATAL(
122  "The exponent parameter of WettingPhaseBrooksCoreyOilGas\n"
123  "relative permeability model, m, must not be smaller than 1");
124  }
125 
127  const auto krel_min = config.getConfigParameter<double>("krel_min");
128 
129  return std::make_unique<WettingPhaseBrooksCoreyOilGas>(
130  Sr, Smax, m, krel_min);
131 }
132 
138 std::unique_ptr<RelativePermeability> createNonWettingPhaseBrooksCoreyOilGas(
139  BaseLib::ConfigTree const& config)
140 {
142  config.checkConfigParameter("type", "NonWettingPhaseBrooksCoreyOilGas");
143 
145  const auto Sr = config.getConfigParameter<double>("sr");
146 
148  const auto Smax = config.getConfigParameter<double>("smax");
149 
151  const auto m = config.getConfigParameter<double>("m");
152  if (m < 1.0) // m >= 1
153  {
154  OGS_FATAL(
155  "The exponent parameter of NonWettingPhaseBrooksCoreyOilGas\n"
156  "relative permeability model, m, must not be smaller than 1");
157  }
158 
160  const auto krel_min = config.getConfigParameter<double>("krel_min");
161 
162  return std::make_unique<NonWettingPhaseBrooksCoreyOilGas>(
163  Sr, Smax, m, krel_min);
164 }
165 
166 std::unique_ptr<RelativePermeability> createRelativePermeabilityModel(
167  BaseLib::ConfigTree const& config)
168 {
170  auto const type = config.peekConfigParameter<std::string>("type");
171 
172  if (type == "WettingPhaseVanGenuchten")
173  {
174  return createWettingPhaseVanGenuchten(config);
175  }
176  if (type == "NonWettingPhaseVanGenuchten")
177  {
178  return createNonWettingPhaseVanGenuchten(config);
179  }
180  if (type == "WettingPhaseBrooksCoreyOilGas")
181  {
183  }
184  if (type == "NonWettingPhaseBrooksCoreyOilGas")
185  {
187  }
188  if (type == "Curve")
189  {
191  config.checkConfigParameter("type", "Curve");
192 
194  auto const& curve_config = config.getConfigSubtree("curve");
195 
196  auto curve = MathLib::createPiecewiseLinearCurve<MathLib
197  ::PiecewiseLinearInterpolation>(curve_config);
198  return std::make_unique<RelativePermeabilityCurve>(std::move(curve));
199  }
200 
201  OGS_FATAL(
202  "The relative permeability model %s is unavailable.\n"
203  "The available models are:"
204  "\n\tWettingPhaseVanGenuchten,"
205  "\n\tNonWettingPhaseVanGenuchten,"
206  "\n\tWettingPhaseBrooksCoreyOilGas,"
207  "\n\tNonWettingPhaseBrooksCoreyOilGas,",
208  "\n\tCurve.\n",
209  type.data());
210 }
211 
212 } // namespace PorousMedium
213 } // namespace MaterialLib
std::unique_ptr< RelativePermeability > createNonWettingPhaseBrooksCoreyOilGas(BaseLib::ConfigTree const &config)
Definition of the PiecewiseLinearInterpolation class.
std::unique_ptr< RelativePermeability > createRelativePermeabilityModel(BaseLib::ConfigTree const &config)
T getConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, T const &value) const
T peekConfigParameter(std::string const &param) const
std::unique_ptr< RelativePermeability > createWettingPhaseVanGenuchten(BaseLib::ConfigTree const &config)
std::unique_ptr< RelativePermeability > createWettingPhaseBrooksCoreyOilGas(BaseLib::ConfigTree const &config)
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:150
#define OGS_FATAL(fmt,...)
Definition: Error.h:63
std::unique_ptr< RelativePermeability > createNonWettingPhaseVanGenuchten(BaseLib::ConfigTree const &config)
std::unique_ptr< CurveType > createPiecewiseLinearCurve(BaseLib::ConfigTree const &config)