OGS 6.1.0-1721-g6382411ad
CreateRichardsMechanicsProcess.cpp
Go to the documentation of this file.
1 
11 
12 #include <cassert>
13 
19 
22 
23 namespace ProcessLib
24 {
25 namespace RichardsMechanics
26 {
27 template <int DisplacementDim>
28 std::unique_ptr<Process> createRichardsMechanicsProcess(
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", "RICHARDS_MECHANICS");
38  DBUG("Create RichardsMechanicsProcess.");
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  // Fluid bulk modulus
109  auto& fluid_bulk_modulus = findParameter<double>(
110  config,
112  "fluid_bulk_modulus", parameters, 1);
113  DBUG("Use '%s' as fluid bulk modulus parameter.",
114  fluid_bulk_modulus.name.c_str());
115 
116  // Biot coefficient
117  auto& biot_coefficient = findParameter<double>(
118  config,
120  "biot_coefficient", parameters, 1);
121  DBUG("Use '%s' as Biot coefficient parameter.",
122  biot_coefficient.name.c_str());
123 
124  // Solid density
125  auto& solid_density = findParameter<double>(
126  config,
128  "solid_density", parameters, 1);
129  DBUG("Use '%s' as solid density parameter.", solid_density.name.c_str());
130 
131  // Solid bulk modulus
132  auto& solid_bulk_modulus = findParameter<double>(
133  config,
135  "solid_bulk_modulus", parameters, 1);
136  DBUG("Use '%s' as solid bulk modulus parameter.",
137  solid_bulk_modulus.name.c_str());
138 
139  // Specific body force
140  Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
141  {
142  std::vector<double> const b =
144  config.getConfigParameter<std::vector<double>>(
145  "specific_body_force");
146  if (b.size() != DisplacementDim)
147  {
148  OGS_FATAL(
149  "The size of the specific body force vector does not match the "
150  "displacement dimension. Vector size is %d, displacement "
151  "dimension is %d",
152  b.size(), DisplacementDim);
153  }
154 
155  std::copy_n(b.data(), b.size(), specific_body_force.data());
156  }
157 
158  auto& temperature = findParameter<double>(
159  config,
161  "temperature", parameters, 1);
162 
163  auto const& flow_material_config =
165  config.getConfigSubtree("material_property");
166 
167  auto const material_ids =
168  mesh.getProperties().existsPropertyVector<int>("MaterialIDs")
169  ? mesh.getProperties().getPropertyVector<int>("MaterialIDs")
170  : nullptr;
171  if (material_ids != nullptr)
172  {
173  INFO(
174  "MaterialIDs vector found; the Richards flow is in heterogeneous "
175  "porous media.");
176  }
177  else
178  {
179  INFO(
180  "MaterialIDs vector not found; the Richards flow is in homogeneous "
181  "porous media.");
182  }
183  auto flow_material =
185  flow_material_config, material_ids, parameters);
186 
188  material_ids,
189  std::move(flow_material),
190  std::move(solid_constitutive_relations),
191  fluid_bulk_modulus,
193  solid_density,
194  solid_bulk_modulus,
195  temperature,
196  specific_body_force};
197 
198  SecondaryVariableCollection secondary_variables;
199 
200  NumLib::NamedFunctionCaller named_function_caller(
201  {"RichardsMechanics_displacement"});
202 
203  ProcessLib::createSecondaryVariables(config, secondary_variables,
204  named_function_caller);
205 
206  return std::make_unique<RichardsMechanicsProcess<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> createRichardsMechanicsProcess<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<ParameterBase>> const& parameters,
218  unsigned const integration_order,
219  BaseLib::ConfigTree const& config);
220 
221 template std::unique_ptr<Process> createRichardsMechanicsProcess<3>(
222  MeshLib::Mesh& mesh,
223  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
224  std::vector<ProcessVariable> const& variables,
225  std::vector<std::unique_ptr<ParameterBase>> const& parameters,
226  unsigned const integration_order,
227  BaseLib::ConfigTree const& config);
228 
229 } // namespace RichardsMechanics
230 } // 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< ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config)
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< ParameterBase >> const &parameters, 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.
void checkConfigParameter(std::string const &param, T const &value) const
std::unique_ptr< RichardsFlowMaterialProperties > createRichardsFlowMaterialProperties(BaseLib::ConfigTree const &config, MeshLib::PropertyVector< int > const *const material_ids, std::vector< std::unique_ptr< ParameterBase >> const &parameters)
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:146
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:71
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< ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config)