OGS 6.2.0-97-g4a610c866
CreateRichardsMechanicsProcess.cpp
Go to the documentation of this file.
1 
11 
12 #include <cassert>
13 
16 #include "ParameterLib/Utils.h"
20 
23 
24 namespace ProcessLib
25 {
26 namespace RichardsMechanics
27 {
28 template <int DisplacementDim>
29 std::unique_ptr<Process> createRichardsMechanicsProcess(
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", "RICHARDS_MECHANICS");
41  DBUG("Create RichardsMechanicsProcess.");
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  // Fluid bulk modulus
112  auto& fluid_bulk_modulus = ParameterLib::findParameter<double>(
113  config,
115  "fluid_bulk_modulus", parameters, 1);
116  DBUG("Use '%s' as fluid bulk modulus parameter.",
117  fluid_bulk_modulus.name.c_str());
118 
119  // Biot coefficient
120  auto& biot_coefficient = ParameterLib::findParameter<double>(
121  config,
123  "biot_coefficient", parameters, 1);
124  DBUG("Use '%s' as Biot coefficient parameter.",
125  biot_coefficient.name.c_str());
126 
127  // Solid density
128  auto& solid_density = ParameterLib::findParameter<double>(
129  config,
131  "solid_density", parameters, 1);
132  DBUG("Use '%s' as solid density parameter.", solid_density.name.c_str());
133 
134  // Solid bulk modulus
135  auto& solid_bulk_modulus = ParameterLib::findParameter<double>(
136  config,
138  "solid_bulk_modulus", parameters, 1);
139  DBUG("Use '%s' as solid bulk modulus parameter.",
140  solid_bulk_modulus.name.c_str());
141 
142  // Specific body force
143  Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
144  {
145  std::vector<double> const b =
147  config.getConfigParameter<std::vector<double>>(
148  "specific_body_force");
149  if (b.size() != DisplacementDim)
150  {
151  OGS_FATAL(
152  "The size of the specific body force vector does not match the "
153  "displacement dimension. Vector size is %d, displacement "
154  "dimension is %d",
155  b.size(), DisplacementDim);
156  }
157 
158  std::copy_n(b.data(), b.size(), specific_body_force.data());
159  }
160 
161  auto& temperature = ParameterLib::findParameter<double>(
162  config,
164  "temperature", parameters, 1);
165 
166  auto const& flow_material_config =
168  config.getConfigSubtree("material_property");
169 
170  auto const material_ids =
171  mesh.getProperties().existsPropertyVector<int>("MaterialIDs")
172  ? mesh.getProperties().getPropertyVector<int>("MaterialIDs")
173  : nullptr;
174  if (material_ids != nullptr)
175  {
176  INFO(
177  "MaterialIDs vector found; the Richards flow is in heterogeneous "
178  "porous media.");
179  }
180  else
181  {
182  INFO(
183  "MaterialIDs vector not found; the Richards flow is in homogeneous "
184  "porous media.");
185  }
186  auto flow_material =
188  flow_material_config, material_ids, parameters);
189 
191  material_ids,
192  std::move(flow_material),
193  std::move(solid_constitutive_relations),
194  fluid_bulk_modulus,
196  solid_density,
197  solid_bulk_modulus,
198  temperature,
199  specific_body_force};
200 
201  SecondaryVariableCollection secondary_variables;
202 
203  NumLib::NamedFunctionCaller named_function_caller(
204  {"RichardsMechanics_displacement"});
205 
206  ProcessLib::createSecondaryVariables(config, secondary_variables,
207  named_function_caller);
208 
209  return std::make_unique<RichardsMechanicsProcess<DisplacementDim>>(
210  mesh, std::move(jacobian_assembler), parameters, integration_order,
211  std::move(process_variables), std::move(process_data),
212  std::move(secondary_variables), std::move(named_function_caller),
213  use_monolithic_scheme);
214 }
215 
216 template std::unique_ptr<Process> createRichardsMechanicsProcess<2>(
217  MeshLib::Mesh& mesh,
218  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
219  std::vector<ProcessVariable> const& variables,
220  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
221  boost::optional<ParameterLib::CoordinateSystem> const&
222  local_coordinate_system,
223  unsigned const integration_order,
224  BaseLib::ConfigTree const& config);
225 
226 template std::unique_ptr<Process> createRichardsMechanicsProcess<3>(
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 RichardsMechanics
237 } // namespace ProcessLib
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables, NumLib::NamedFunctionCaller &named_function_caller)
template std::unique_ptr< Process > createRichardsMechanicsProcess< 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)
std::unique_ptr< Process > createRichardsMechanicsProcess(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)
MeshLib::Properties & getProperties()
Definition: Mesh.h:134
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.
std::unique_ptr< RichardsFlowMaterialProperties > createRichardsFlowMaterialProperties(BaseLib::ConfigTree const &config, MeshLib::PropertyVector< int > const *const material_ids, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters)
void checkConfigParameter(std::string const &param, T const &value) const
std::string const & getName() const
int getNumberOfComponents() const
Returns the number of components of the process variable.
PropertyVector< T > const * getPropertyVector(std::string const &name) const
Definition: Properties.h:119
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:150
bool existsPropertyVector(std::string const &name) const
Definition: Properties.h:79
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 > createRichardsMechanicsProcess< 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)