OGS 6.2.1-97-g73d1aeda3
createPermeabilityModel.cpp
Go to the documentation of this file.
1 
14 
15 #include <cassert>
16 
17 #include "BaseLib/ConfigTree.h"
18 
19 #include "BaseLib/Error.h"
24 #include "ParameterLib/Utils.h"
25 
26 namespace MaterialLib
27 {
28 namespace PorousMedium
29 {
30 std::unique_ptr<Permeability> createPermeabilityModel(
31  BaseLib::ConfigTree const& config,
32  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters)
33 {
35  auto const type = config.getConfigParameter<std::string>("type");
36 
37  if (type == "Constant")
38  {
39  auto const& permeability_parameter = ParameterLib::findParameter<
40  double>(
41  config,
43  "permeability_tensor_entries", parameters, 0);
44 
45  int dimension = static_cast<int>(
46  std::sqrt(permeability_parameter.getNumberOfComponents()));
47  if (permeability_parameter.getNumberOfComponents() !=
48  dimension * dimension)
49  {
50  OGS_FATAL(
51  "The given parameter has %d components, but the permeability "
52  "tensor is defined for a %d dimensional problem.",
53  permeability_parameter.getNumberOfComponents(), dimension);
54  }
55 
56  return std::make_unique<Permeability>(
57  permeability_parameter, dimension);
58  }
59 
60  if (type == "Dupuit")
61  {
62  auto const& permeability_parameter = ParameterLib::findParameter<
63  double>(
64  config,
66  "permeability_tensor_entries", parameters, 0);
67 
68  int dimension = static_cast<int>(
69  std::sqrt(permeability_parameter.getNumberOfComponents()));
70  if (permeability_parameter.getNumberOfComponents() !=
71  dimension * dimension)
72  {
73  OGS_FATAL(
74  "The given parameter has %d components, but the permeability "
75  "tensor is defined for a %d dimensional problem.",
76  permeability_parameter.getNumberOfComponents(), dimension);
77  }
78 
79  return std::make_unique<DupuitPermeability>(permeability_parameter,
80  dimension);
81  }
82  OGS_FATAL("The permeability type '%s' is unavailable.\n",
83  "The available types are \n\tConstant.",
84  type.data());
85 }
86 
87 } // namespace PorousMedium
88 } // namespace MaterialLib
Parameter< ParameterDataType > & findParameter(std::string const &parameter_name, std::vector< std::unique_ptr< ParameterBase >> const &parameters, int const num_components, MeshLib::Mesh const *const mesh=nullptr)
Definition: Utils.h:101
T getConfigParameter(std::string const &param) const
std::unique_ptr< Permeability > createPermeabilityModel(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters)
#define OGS_FATAL(fmt,...)
Definition: Error.h:63