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