OGS 6.2.0-97-g4a610c866
CreateHydroMechanicsProcess.cpp
Go to the documentation of this file.
1 
11 
12 #include <cassert>
13 
16 #include "ParameterLib/Utils.h"
19 
20 #include "HydroMechanicsProcess.h"
22 
23 namespace ProcessLib
24 {
25 namespace HydroMechanics
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<ParameterLib::ParameterBase>> const& parameters,
33  boost::optional<ParameterLib::CoordinateSystem> const&
34  local_coordinate_system,
35  unsigned const integration_order,
36  BaseLib::ConfigTree const& config)
37 {
39  config.checkConfigParameter("type", "HYDRO_MECHANICS");
40  DBUG("Create HydroMechanicsProcess.");
41 
42  auto const staggered_scheme =
44  config.getConfigParameterOptional<std::string>("coupling_scheme");
45  const bool use_monolithic_scheme =
46  !(staggered_scheme && (*staggered_scheme == "staggered"));
47 
48  // Process variable.
49 
51  auto const pv_config = config.getConfigSubtree("process_variables");
52 
53  ProcessVariable* variable_p;
54  ProcessVariable* variable_u;
55  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
56  process_variables;
57  if (use_monolithic_scheme) // monolithic scheme.
58  {
59  auto per_process_variables = findProcessVariables(
60  variables, pv_config,
61  {
62  "pressure",
64  "displacement"});
65  variable_p = &per_process_variables[0].get();
66  variable_u = &per_process_variables[1].get();
67  process_variables.push_back(std::move(per_process_variables));
68  }
69  else // staggered scheme.
70  {
71  using namespace std::string_literals;
72  for (auto const& variable_name : {"pressure"s, "displacement"s})
73  {
74  auto per_process_variables =
75  findProcessVariables(variables, pv_config, {variable_name});
76  process_variables.push_back(std::move(per_process_variables));
77  }
78  variable_p = &process_variables[0][0].get();
79  variable_u = &process_variables[1][0].get();
80  }
81 
82  DBUG("Associate displacement with process variable '%s'.",
83  variable_u->getName().c_str());
84 
85  if (variable_u->getNumberOfComponents() != DisplacementDim)
86  {
87  OGS_FATAL(
88  "Number of components of the process variable '%s' is different "
89  "from the displacement dimension: got %d, expected %d",
90  variable_u->getName().c_str(),
91  variable_u->getNumberOfComponents(),
92  DisplacementDim);
93  }
94 
95  DBUG("Associate pressure with process variable '%s'.",
96  variable_p->getName().c_str());
97  if (variable_p->getNumberOfComponents() != 1)
98  {
99  OGS_FATAL(
100  "Pressure process variable '%s' is not a scalar variable but has "
101  "%d components.",
102  variable_p->getName().c_str(),
103  variable_p->getNumberOfComponents());
104  }
105 
106  auto solid_constitutive_relations =
107  MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
108  parameters, local_coordinate_system, config);
109 
110  // Intrinsic permeability
111  auto& intrinsic_permeability = ParameterLib::findParameter<double>(
112  config,
114  "intrinsic_permeability", parameters, 1);
115 
116  DBUG("Use '%s' as intrinsic conductivity parameter.",
117  intrinsic_permeability.name.c_str());
118 
119  // Storage coefficient
120  auto& specific_storage = ParameterLib::findParameter<double>(
121  config,
123  "specific_storage", parameters, 1);
124 
125  DBUG("Use '%s' as storage coefficient parameter.",
126  specific_storage.name.c_str());
127 
128  // Fluid viscosity
129  auto& fluid_viscosity = ParameterLib::findParameter<double>(
130  config,
132  "fluid_viscosity", parameters, 1);
133  DBUG("Use '%s' as fluid viscosity parameter.",
134  fluid_viscosity.name.c_str());
135 
136  // Fluid density
137  auto& fluid_density = ParameterLib::findParameter<double>(
138  config,
140  "fluid_density", parameters, 1);
141  DBUG("Use '%s' as fluid density parameter.", fluid_density.name.c_str());
142 
143  // Biot coefficient
144  auto& biot_coefficient = ParameterLib::findParameter<double>(
145  config,
147  "biot_coefficient", parameters, 1);
148  DBUG("Use '%s' as Biot coefficient parameter.",
149  biot_coefficient.name.c_str());
150 
151  // Porosity
152  auto& porosity = ParameterLib::findParameter<double>(
153  config,
155  "porosity", parameters, 1);
156  DBUG("Use '%s' as porosity parameter.", porosity.name.c_str());
157 
158  // Solid density
159  auto& solid_density = ParameterLib::findParameter<double>(
160  config,
162  "solid_density", parameters, 1);
163  DBUG("Use '%s' as solid density parameter.", solid_density.name.c_str());
164 
165  // Specific body force
166  Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
167  {
168  std::vector<double> const b =
170  config.getConfigParameter<std::vector<double>>(
171  "specific_body_force");
172  if (b.size() != DisplacementDim)
173  {
174  OGS_FATAL(
175  "The size of the specific body force vector does not match the "
176  "displacement dimension. Vector size is %d, displacement "
177  "dimension is %d",
178  b.size(), DisplacementDim);
179  }
180 
181  std::copy_n(b.data(), b.size(), specific_body_force.data());
182  }
183 
184  // Reference temperature
185  const auto& reference_temperature =
187  config.getConfigParameter<double>(
188  "reference_temperature", std::numeric_limits<double>::quiet_NaN());
189 
191  materialIDs(mesh), std::move(solid_constitutive_relations),
192  intrinsic_permeability, specific_storage,
195  solid_density, specific_body_force,
196  reference_temperature};
197 
198  SecondaryVariableCollection secondary_variables;
199 
200  NumLib::NamedFunctionCaller named_function_caller(
201  {"HydroMechanics_displacement"});
202 
203  ProcessLib::createSecondaryVariables(config, secondary_variables,
204  named_function_caller);
205 
206  return std::make_unique<HydroMechanicsProcess<DisplacementDim>>(
207  mesh, std::move(jacobian_assembler), parameters, integration_order,
208  std::move(process_variables), std::move(process_data),
209  std::move(secondary_variables), std::move(named_function_caller),
210  use_monolithic_scheme);
211 }
212 
213 template std::unique_ptr<Process> createHydroMechanicsProcess<2>(
214  MeshLib::Mesh& mesh,
215  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
216  std::vector<ProcessVariable> const& variables,
217  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
218  boost::optional<ParameterLib::CoordinateSystem> const&
219  local_coordinate_system,
220  unsigned const integration_order,
221  BaseLib::ConfigTree const& config);
222 
223 template std::unique_ptr<Process> createHydroMechanicsProcess<3>(
224  MeshLib::Mesh& mesh,
225  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
226  std::vector<ProcessVariable> const& variables,
227  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
228  boost::optional<ParameterLib::CoordinateSystem> const&
229  local_coordinate_system,
230  unsigned const integration_order,
231  BaseLib::ConfigTree const& config);
232 
233 } // namespace HydroMechanics
234 } // namespace ProcessLib
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< ParameterLib::ParameterBase >> const &parameters, boost::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
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)
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:403
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:150
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< ParameterLib::ParameterBase >> const &parameters, boost::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
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:63
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< ParameterLib::ParameterBase >> const &parameters, boost::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)