OGS 6.2.1-97-g73d1aeda3
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  std::string name,
31  MeshLib::Mesh& mesh,
32  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
33  std::vector<ProcessVariable> const& variables,
34  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
35  boost::optional<ParameterLib::CoordinateSystem> const&
36  local_coordinate_system,
37  unsigned const integration_order,
38  BaseLib::ConfigTree const& config)
39 {
41  config.checkConfigParameter("type", "RICHARDS_MECHANICS");
42  DBUG("Create RichardsMechanicsProcess.");
43 
44  auto const staggered_scheme =
46  config.getConfigParameterOptional<std::string>("coupling_scheme");
47  const bool use_monolithic_scheme =
48  !(staggered_scheme && (*staggered_scheme == "staggered"));
49 
50  // Process variable.
51 
53  auto const pv_config = config.getConfigSubtree("process_variables");
54 
55  ProcessVariable* variable_p;
56  ProcessVariable* variable_u;
57  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
58  process_variables;
59  if (use_monolithic_scheme) // monolithic scheme.
60  {
61  auto per_process_variables = findProcessVariables(
62  variables, pv_config,
63  {
64  "pressure",
66  "displacement"});
67  variable_p = &per_process_variables[0].get();
68  variable_u = &per_process_variables[1].get();
69  process_variables.push_back(std::move(per_process_variables));
70  }
71  else // staggered scheme.
72  {
73  using namespace std::string_literals;
74  for (auto const& variable_name : {"pressure"s, "displacement"s})
75  {
76  auto per_process_variables =
77  findProcessVariables(variables, pv_config, {variable_name});
78  process_variables.push_back(std::move(per_process_variables));
79  }
80  variable_p = &process_variables[0][0].get();
81  variable_u = &process_variables[1][0].get();
82  }
83 
84  DBUG("Associate displacement with process variable '%s'.",
85  variable_u->getName().c_str());
86 
87  if (variable_u->getNumberOfComponents() != DisplacementDim)
88  {
89  OGS_FATAL(
90  "Number of components of the process variable '%s' is different "
91  "from the displacement dimension: got %d, expected %d",
92  variable_u->getName().c_str(),
93  variable_u->getNumberOfComponents(),
94  DisplacementDim);
95  }
96 
97  DBUG("Associate pressure with process variable '%s'.",
98  variable_p->getName().c_str());
99  if (variable_p->getNumberOfComponents() != 1)
100  {
101  OGS_FATAL(
102  "Pressure process variable '%s' is not a scalar variable but has "
103  "%d components.",
104  variable_p->getName().c_str(),
105  variable_p->getNumberOfComponents());
106  }
107 
108  auto solid_constitutive_relations =
109  MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
110  parameters, local_coordinate_system, config);
111 
112  // Fluid bulk modulus
113  auto& fluid_bulk_modulus = ParameterLib::findParameter<double>(
114  config,
116  "fluid_bulk_modulus", parameters, 1, &mesh);
117  DBUG("Use '%s' as fluid bulk modulus parameter.",
118  fluid_bulk_modulus.name.c_str());
119 
120  // Biot coefficient
121  auto& biot_coefficient = ParameterLib::findParameter<double>(
122  config,
124  "biot_coefficient", parameters, 1, &mesh);
125  DBUG("Use '%s' as Biot coefficient parameter.",
126  biot_coefficient.name.c_str());
127 
128  // Solid density
129  auto& solid_density = ParameterLib::findParameter<double>(
130  config,
132  "solid_density", parameters, 1, &mesh);
133  DBUG("Use '%s' as solid density parameter.", solid_density.name.c_str());
134 
135  // Solid bulk modulus
136  auto& solid_bulk_modulus = ParameterLib::findParameter<double>(
137  config,
139  "solid_bulk_modulus", parameters, 1, &mesh);
140  DBUG("Use '%s' as solid bulk modulus parameter.",
141  solid_bulk_modulus.name.c_str());
142 
143  // Specific body force
144  Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
145  {
146  std::vector<double> const b =
148  config.getConfigParameter<std::vector<double>>(
149  "specific_body_force");
150  if (b.size() != DisplacementDim)
151  {
152  OGS_FATAL(
153  "The size of the specific body force vector does not match the "
154  "displacement dimension. Vector size is %d, displacement "
155  "dimension is %d",
156  b.size(), DisplacementDim);
157  }
158 
159  std::copy_n(b.data(), b.size(), specific_body_force.data());
160  }
161 
162  auto& temperature = ParameterLib::findParameter<double>(
163  config,
165  "temperature", parameters, 1, &mesh);
166 
167  auto const& flow_material_config =
169  config.getConfigSubtree("material_property");
170 
171  auto const material_ids =
172  mesh.getProperties().existsPropertyVector<int>("MaterialIDs")
173  ? mesh.getProperties().getPropertyVector<int>("MaterialIDs")
174  : nullptr;
175  if (material_ids != nullptr)
176  {
177  INFO(
178  "MaterialIDs vector found; the Richards flow is in heterogeneous "
179  "porous media.");
180  }
181  else
182  {
183  INFO(
184  "MaterialIDs vector not found; the Richards flow is in homogeneous "
185  "porous media.");
186  }
187  auto flow_material =
189  flow_material_config, material_ids, parameters);
190 
191  auto const mass_lumping =
193  config.getConfigParameter<bool>("mass_lumping", false);
194 
196  material_ids,
197  std::move(flow_material),
198  std::move(solid_constitutive_relations),
199  fluid_bulk_modulus,
201  solid_density,
202  solid_bulk_modulus,
203  temperature,
204  specific_body_force,
205  mass_lumping};
206 
207  SecondaryVariableCollection secondary_variables;
208 
209  NumLib::NamedFunctionCaller named_function_caller(
210  {"RichardsMechanics_displacement"});
211 
212  ProcessLib::createSecondaryVariables(config, secondary_variables,
213  named_function_caller);
214 
215  return std::make_unique<RichardsMechanicsProcess<DisplacementDim>>(
216  std::move(name), mesh, std::move(jacobian_assembler), parameters,
217  integration_order, std::move(process_variables),
218  std::move(process_data), std::move(secondary_variables),
219  std::move(named_function_caller), use_monolithic_scheme);
220 }
221 
222 template std::unique_ptr<Process> createRichardsMechanicsProcess<2>(
223  std::string name,
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 template std::unique_ptr<Process> createRichardsMechanicsProcess<3>(
234  std::string name,
235  MeshLib::Mesh& mesh,
236  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
237  std::vector<ProcessVariable> const& variables,
238  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
239  boost::optional<ParameterLib::CoordinateSystem> const&
240  local_coordinate_system,
241  unsigned const integration_order,
242  BaseLib::ConfigTree const& config);
243 
244 } // namespace RichardsMechanics
245 } // namespace ProcessLib
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables, NumLib::NamedFunctionCaller &named_function_caller)
MeshLib::Properties & getProperties()
Definition: Mesh.h:134
template std::unique_ptr< Process > createRichardsMechanicsProcess< 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)
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::unique_ptr< Process > createRichardsMechanicsProcess(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::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< 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)