OGS
CreateCapillaryPressureModel.cpp
Go to the documentation of this file.
1 
14 
15 #include "BaseLib/ConfigTree.h"
16 #include "BaseLib/Error.h"
23 
24 namespace MaterialLib
25 {
26 namespace PorousMedium
27 {
33 static std::unique_ptr<CapillaryPressureSaturation> createBrooksCorey(
34  BaseLib::ConfigTree const& config)
35 {
37  config.checkConfigParameter("type", "BrooksCorey");
38 
40  const auto pd = config.getConfigParameter<double>("pd");
41 
43  const auto Sr = config.getConfigParameter<double>("sr");
44 
45  double Sg_r = 0.0;
47  if (auto const Sg_r_ptr = config.getConfigParameterOptional<double>("sg_r"))
48  {
49  DBUG(
50  "Using value {:g} for nonwetting phase residual saturation in "
51  "capillary pressure model.",
52  (*Sg_r_ptr));
53  Sg_r = *Sg_r_ptr;
54  }
56  const auto Smax = config.getConfigParameter<double>("smax");
57 
59  const auto m = config.getConfigParameter<double>("m");
60  if (m < 1.0) // m >= 1
61  {
62  OGS_FATAL(
63  "The exponent parameter of BrooksCorey capillary pressure "
64  "saturation model, m, must not be smaller than 1");
65  }
67  const auto Pc_max = config.getConfigParameter<double>("pc_max");
68 
69  return std::make_unique<BrooksCoreyCapillaryPressureSaturation>(
70  pd, Sr, Sg_r, Smax, m, Pc_max);
71 }
72 
78 static std::unique_ptr<CapillaryPressureSaturation> createVanGenuchten(
79  BaseLib::ConfigTree const& config)
80 {
82  config.checkConfigParameter("type", "vanGenuchten");
83 
85  const auto pd = config.getConfigParameter<double>("pd");
86 
88  const auto Sr = config.getConfigParameter<double>("sr");
89 
90  double Sg_r = 0.0;
92  if (auto const Sg_r_ptr = config.getConfigParameterOptional<double>("sg_r"))
93  {
94  DBUG(
95  "Using value {:g} for nonwetting phase residual saturation in "
96  "capillary pressure model.",
97  (*Sg_r_ptr));
98  Sg_r = *Sg_r_ptr;
99  }
100 
102  const auto Smax = config.getConfigParameter<double>("smax");
103 
105  const auto m = config.getConfigParameter<double>("m");
106  if (m < 0. || m > 1.0)
107  {
108  OGS_FATAL(
109  "The exponent parameter of van Genuchten capillary pressure "
110  "saturation model, m, must be in an interval of [0, 1]");
111  }
113  const auto Pc_max = config.getConfigParameter<double>("pc_max");
114 
115  bool has_regularized = false;
116  if (auto const has_regularized_conf =
118  config.getConfigParameterOptional<bool>("has_regularized"))
119  {
120  DBUG("capillary pressure model: {:s}",
121  (*has_regularized_conf) ? "true" : "false");
122  has_regularized = *has_regularized_conf;
123  }
124  return std::make_unique<VanGenuchtenCapillaryPressureSaturation>(
125  pd, Sr, Sg_r, Smax, m, Pc_max, has_regularized);
126 }
127 
128 std::unique_ptr<CapillaryPressureSaturation> createCapillaryPressureModel(
129  BaseLib::ConfigTree const& config)
130 {
132  auto const type = config.peekConfigParameter<std::string>("type");
133 
134  if (type == "BrooksCorey")
135  {
136  return createBrooksCorey(config);
137  }
138  if (type == "vanGenuchten")
139  {
140  return createVanGenuchten(config);
141  }
142  if (type == "Curve")
143  {
145  config.checkConfigParameter("type", "Curve");
146 
148  auto const& curve_config = config.getConfigSubtree("curve");
149 
152 
153  return std::make_unique<CapillaryPressureSaturationCurve>(
154  std::move(curve));
155  }
156 
157  OGS_FATAL(
158  "The capillary pressure saturation models {:s} are unavailable.\nThe "
159  "available types are: \n\tBrooksCorey, \n\tvanGenuchten,",
160  "\n\tCurve.\n",
161  type.data());
162 }
163 
164 } // namespace PorousMedium
165 } // namespace MaterialLib
#define OGS_FATAL(...)
Definition: Error.h:26
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition: Logging.h:29
T peekConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, T const &value) const
std::optional< T > getConfigParameterOptional(std::string const &param) const
T getConfigParameter(std::string const &param) const
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:150
std::unique_ptr< CapillaryPressureSaturation > createCapillaryPressureModel(BaseLib::ConfigTree const &config)
static std::unique_ptr< CapillaryPressureSaturation > createVanGenuchten(BaseLib::ConfigTree const &config)
static std::unique_ptr< CapillaryPressureSaturation > createBrooksCorey(BaseLib::ConfigTree const &config)
std::unique_ptr< CurveType > createPiecewiseLinearCurve(BaseLib::ConfigTree const &config)