OGS 6.1.0-1721-g6382411ad
CreateHydroMechanicsProcess.cpp
Go to the documentation of this file.
1 
11 
12 #include <cassert>
13 
18 
19 #include "HydroMechanicsProcess.h"
21 
22 namespace ProcessLib
23 {
24 namespace HydroMechanics
25 {
26 
27 template <int DisplacementDim>
28 std::unique_ptr<Process> createHydroMechanicsProcess(
29  MeshLib::Mesh& mesh,
30  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
31  std::vector<ProcessVariable> const& variables,
32  std::vector<std::unique_ptr<ParameterBase>> const& parameters,
33  unsigned const integration_order,
34  BaseLib::ConfigTree const& config)
35 {
37  config.checkConfigParameter("type", "HYDRO_MECHANICS");
38  DBUG("Create HydroMechanicsProcess.");
39 
40  auto const staggered_scheme =
42  config.getConfigParameterOptional<std::string>("coupling_scheme");
43  const bool use_monolithic_scheme =
44  !(staggered_scheme && (*staggered_scheme == "staggered"));
45 
46  // Process variable.
47 
49  auto const pv_config = config.getConfigSubtree("process_variables");
50 
51  ProcessVariable* variable_p;
52  ProcessVariable* variable_u;
53  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
54  process_variables;
55  if (use_monolithic_scheme) // monolithic scheme.
56  {
57  auto per_process_variables = findProcessVariables(
58  variables, pv_config,
59  {
60  "pressure",
62  "displacement"});
63  variable_p = &per_process_variables[0].get();
64  variable_u = &per_process_variables[1].get();
65  process_variables.push_back(std::move(per_process_variables));
66  }
67  else // staggered scheme.
68  {
69  using namespace std::string_literals;
70  for (auto const& variable_name : {"pressure"s, "displacement"s})
71  {
72  auto per_process_variables =
73  findProcessVariables(variables, pv_config, {variable_name});
74  process_variables.push_back(std::move(per_process_variables));
75  }
76  variable_p = &process_variables[0][0].get();
77  variable_u = &process_variables[1][0].get();
78  }
79 
80  DBUG("Associate displacement with process variable '%s'.",
81  variable_u->getName().c_str());
82 
83  if (variable_u->getNumberOfComponents() != DisplacementDim)
84  {
85  OGS_FATAL(
86  "Number of components of the process variable '%s' is different "
87  "from the displacement dimension: got %d, expected %d",
88  variable_u->getName().c_str(),
89  variable_u->getNumberOfComponents(),
90  DisplacementDim);
91  }
92 
93  DBUG("Associate pressure with process variable '%s'.",
94  variable_p->getName().c_str());
95  if (variable_p->getNumberOfComponents() != 1)
96  {
97  OGS_FATAL(
98  "Pressure process variable '%s' is not a scalar variable but has "
99  "%d components.",
100  variable_p->getName().c_str(),
101  variable_p->getNumberOfComponents());
102  }
103 
104  auto solid_constitutive_relations =
105  MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
106  parameters, config);
107 
108  // Intrinsic permeability
109  auto& intrinsic_permeability = findParameter<double>(
110  config,
112  "intrinsic_permeability", parameters, 1);
113 
114  DBUG("Use '%s' as intrinsic conductivity parameter.",
115  intrinsic_permeability.name.c_str());
116 
117  // Storage coefficient
118  auto& specific_storage = findParameter<double>(
119  config,
121  "specific_storage", parameters, 1);
122 
123  DBUG("Use '%s' as storage coefficient parameter.",
124  specific_storage.name.c_str());
125 
126  // Fluid viscosity
127  auto& fluid_viscosity = findParameter<double>(
128  config,
130  "fluid_viscosity", parameters, 1);
131  DBUG("Use '%s' as fluid viscosity parameter.",
132  fluid_viscosity.name.c_str());
133 
134  // Fluid density
135  auto& fluid_density = findParameter<double>(
136  config,
138  "fluid_density", parameters, 1);
139  DBUG("Use '%s' as fluid density parameter.", fluid_density.name.c_str());
140 
141  // Biot coefficient
142  auto& biot_coefficient = findParameter<double>(
143  config,
145  "biot_coefficient", parameters, 1);
146  DBUG("Use '%s' as Biot coefficient parameter.",
147  biot_coefficient.name.c_str());
148 
149  // Porosity
150  auto& porosity = findParameter<double>(
151  config,
153  "porosity", parameters, 1);
154  DBUG("Use '%s' as porosity parameter.", porosity.name.c_str());
155 
156  // Solid density
157  auto& solid_density = findParameter<double>(
158  config,
160  "solid_density", parameters, 1);
161  DBUG("Use '%s' as solid density parameter.", solid_density.name.c_str());
162 
163  // Specific body force
164  Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
165  {
166  std::vector<double> const b =
168  config.getConfigParameter<std::vector<double>>(
169  "specific_body_force");
170  if (b.size() != DisplacementDim)
171  {
172  OGS_FATAL(
173  "The size of the specific body force vector does not match the "
174  "displacement dimension. Vector size is %d, displacement "
175  "dimension is %d",
176  b.size(), DisplacementDim);
177  }
178 
179  std::copy_n(b.data(), b.size(), specific_body_force.data());
180  }
181 
182  // Reference temperature
183  const auto& reference_temperature =
185  config.getConfigParameter<double>(
186  "reference_temperature", std::numeric_limits<double>::quiet_NaN());
187 
189  materialIDs(mesh), std::move(solid_constitutive_relations),
190  intrinsic_permeability, specific_storage,
193  solid_density, specific_body_force,
194  reference_temperature};
195 
196  SecondaryVariableCollection secondary_variables;
197 
198  NumLib::NamedFunctionCaller named_function_caller(
199  {"HydroMechanics_displacement"});
200 
201  ProcessLib::createSecondaryVariables(config, secondary_variables,
202  named_function_caller);
203 
204  return std::make_unique<HydroMechanicsProcess<DisplacementDim>>(
205  mesh, std::move(jacobian_assembler), parameters, integration_order,
206  std::move(process_variables), std::move(process_data),
207  std::move(secondary_variables), std::move(named_function_caller),
208  use_monolithic_scheme);
209 }
210 
211 template std::unique_ptr<Process> createHydroMechanicsProcess<2>(
212  MeshLib::Mesh& mesh,
213  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
214  std::vector<ProcessVariable> const& variables,
215  std::vector<std::unique_ptr<ParameterBase>> const& parameters,
216  unsigned const integration_order,
217  BaseLib::ConfigTree const& config);
218 
219 template std::unique_ptr<Process> createHydroMechanicsProcess<3>(
220  MeshLib::Mesh& mesh,
221  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
222  std::vector<ProcessVariable> const& variables,
223  std::vector<std::unique_ptr<ParameterBase>> const& parameters,
224  unsigned const integration_order,
225  BaseLib::ConfigTree const& config);
226 
227 } // namespace HydroMechanics
228 } // namespace ProcessLib
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables, NumLib::NamedFunctionCaller &named_function_caller)
double fluid_viscosity(const double p, const double T, const double x)
template std::unique_ptr< Process > createHydroMechanicsProcess< 3 >(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config)
std::vector< std::reference_wrapper< ProcessVariable > > findProcessVariables(std::vector< ProcessVariable > const &variables, BaseLib::ConfigTree const &pv_config, std::initializer_list< std::string > tags)
Builds expression trees of named functions dynamically at runtime.
void checkConfigParameter(std::string const &param, T const &value) const
double fluid_density(const double p, const double T, const double x)
std::string const & getName() const
int getNumberOfComponents() const
Returns the number of components of the process variable.
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition: Mesh.cpp:352
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:146
Handles configuration of several secondary variables from the project file.
boost::optional< T > getConfigParameterOptional(std::string const &param) const
#define OGS_FATAL(fmt,...)
Definition: Error.h:71
template std::unique_ptr< Process > createHydroMechanicsProcess< 2 >(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config)
std::unique_ptr< Process > createHydroMechanicsProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config)