OGS 6.2.1-97-g73d1aeda3
CreateCapillaryPressureModel.cpp
Go to the documentation of this file.
1 
14 
15 #include "BaseLib/ConfigTree.h"
16 #include "BaseLib/Error.h"
17 
20 
25 
26 namespace MaterialLib
27 {
28 namespace PorousMedium
29 {
35 static std::unique_ptr<CapillaryPressureSaturation> createBrooksCorey(
36  BaseLib::ConfigTree const& config)
37 {
39  config.checkConfigParameter("type", "BrooksCorey");
40 
42  const auto pd = config.getConfigParameter<double>("pd");
43 
45  const auto Sr = config.getConfigParameter<double>("sr");
46 
47  double Sg_r = 0.0;
49  if (auto const Sg_r_ptr = config.getConfigParameterOptional<double>("sg_r"))
50  {
51  DBUG(
52  "Using value %g for nonwetting phase residual saturation in "
53  "capillary pressure model.",
54  (*Sg_r_ptr));
55  Sg_r = *Sg_r_ptr;
56  }
58  const auto Smax = config.getConfigParameter<double>("smax");
59 
61  const auto m = config.getConfigParameter<double>("m");
62  if (m < 1.0) // m >= 1
63  {
64  OGS_FATAL(
65  "The exponent parameter of BrooksCorey capillary pressure "
66  "saturation model, m, must not be smaller than 1");
67  }
69  const auto Pc_max = config.getConfigParameter<double>("pc_max");
70 
71  return std::make_unique<BrooksCoreyCapillaryPressureSaturation>(
72  pd, Sr, Sg_r, Smax, m, Pc_max);
73 }
74 
80 static std::unique_ptr<CapillaryPressureSaturation> createVanGenuchten(
81  BaseLib::ConfigTree const& config)
82 {
84  config.checkConfigParameter("type", "vanGenuchten");
85 
87  const auto pd = config.getConfigParameter<double>("pd");
88 
90  const auto Sr = config.getConfigParameter<double>("sr");
91 
92  double Sg_r = 0.0;
94  if (auto const Sg_r_ptr = config.getConfigParameterOptional<double>("sg_r"))
95  {
96  DBUG(
97  "Using value %g for nonwetting phase residual saturation in "
98  "capillary pressure model.",
99  (*Sg_r_ptr));
100  Sg_r = *Sg_r_ptr;
101  }
102 
104  const auto Smax = config.getConfigParameter<double>("smax");
105 
107  const auto m = config.getConfigParameter<double>("m");
108  if (m < 0. || m > 1.0)
109  {
110  OGS_FATAL(
111  "The exponent parameter of van Genuchten capillary pressure "
112  "saturation model, m, must be in an interval of [0, 1]");
113  }
115  const auto Pc_max = config.getConfigParameter<double>("pc_max");
116 
117  bool has_regularized = false;
118  if (auto const has_regularized_conf =
120  config.getConfigParameterOptional<bool>("has_regularized"))
121  {
122  DBUG("capillary pressure model: %s",
123  (*has_regularized_conf) ? "true" : "false");
124  has_regularized = *has_regularized_conf;
125  }
126  return std::make_unique<VanGenuchtenCapillaryPressureSaturation>(
127  pd, Sr, Sg_r, Smax, m, Pc_max, has_regularized);
128 }
129 
130 std::unique_ptr<CapillaryPressureSaturation> createCapillaryPressureModel(
131  BaseLib::ConfigTree const& config)
132 {
134  auto const type = config.peekConfigParameter<std::string>("type");
135 
136  if (type == "BrooksCorey")
137  {
138  return createBrooksCorey(config);
139  }
140  if (type == "vanGenuchten")
141  {
142  return createVanGenuchten(config);
143  }
144  if (type == "Curve")
145  {
147  config.checkConfigParameter("type", "Curve");
148 
150  auto const& curve_config = config.getConfigSubtree("curve");
151 
154 
155  return std::make_unique<CapillaryPressureSaturationCurve>(
156  std::move(curve));
157  }
158 
159  OGS_FATAL(
160  "The capillary pressure saturation models %s are unavailable.\n"
161  "The available types are: \n\tBrooksCorey, \n\tvanGenuchten,",
162  "\n\tCurve.\n",
163  type.data());
164 }
165 
166 } // namespace PorousMedium
167 } // namespace MaterialLib
static std::unique_ptr< CapillaryPressureSaturation > createVanGenuchten(BaseLib::ConfigTree const &config)
static std::unique_ptr< CapillaryPressureSaturation > createBrooksCorey(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< CapillaryPressureSaturation > createCapillaryPressureModel(BaseLib::ConfigTree const &config)
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:150
boost::optional< T > getConfigParameterOptional(std::string const &param) const
#define OGS_FATAL(fmt,...)
Definition: Error.h:63
std::unique_ptr< CurveType > createPiecewiseLinearCurve(BaseLib::ConfigTree const &config)