OGS
CreateThermoRichardsMechanicsProcess.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
6#include <cassert>
7
10
11#ifdef OGS_USE_MFRONT
14#endif
15
19#include "ParameterLib/Utils.h"
25
26namespace ProcessLib
27{
29{
31 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
32{
33 std::array const required_medium_properties = {
37 std::array const required_liquid_properties = {
39 std::array const required_solid_properties = {MaterialPropertyLib::density};
40
41 // Thermal properties are not checked because they can be phase property or
42 // medium property (will be enabled later).
43 for (auto const& m : media)
44 {
45 checkRequiredProperties(*m.second, required_medium_properties);
46 checkRequiredProperties(m.second->phase("AqueousLiquid"),
47 required_liquid_properties);
48 checkRequiredProperties(m.second->phase("Solid"),
49 required_solid_properties);
50 }
51}
52
54 const int dim)
55{
56 DBUG("Associate displacement with process variable '{:s}'.",
57 variable.getName());
58
59 if (variable.getNumberOfGlobalComponents() != dim)
60 {
62 "Number of components of the process variable '{:s}' is different "
63 "from the displacement dimension: got {:d}, expected {:d}",
64 variable.getName(),
66 dim);
67 }
68}
69
70template <int DisplacementDim, typename ConstitutiveTraits,
71 typename CreateConstitutiveSetting>
73 std::string const& name, MeshLib::Mesh& mesh,
74 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
75 std::vector<ProcessVariable> const& variables,
76 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
77 std::optional<ParameterLib::CoordinateSystem> const&
78 local_coordinate_system,
79 unsigned const integration_order, BaseLib::ConfigTree const& config,
80 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media,
81 bool const mandatory_stress0_type)
82{
83 auto const coupling_scheme =
85 config.getConfigParameterOptional<std::string>("coupling_scheme");
86 const bool use_monolithic_scheme =
87 !(coupling_scheme && (*coupling_scheme == "staggered"));
88
90
92 auto const pv_config = config.getConfigSubtree("process_variables");
93
94 ProcessVariable* variable_T;
95 ProcessVariable* variable_p;
96 ProcessVariable* variable_u;
97 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
98 process_variables;
99 if (use_monolithic_scheme) // monolithic scheme.
100 {
103 auto per_process_variables = findProcessVariables(
104 variables, pv_config,
105 {
106 "temperature",
108 "pressure",
110 "displacement"});
111 variable_T = &per_process_variables[0].get();
112 variable_p = &per_process_variables[1].get();
113 variable_u = &per_process_variables[2].get();
114 process_variables.push_back(std::move(per_process_variables));
115 }
116 else // staggered scheme.
117 {
118 OGS_FATAL(
119 "So far, only the monolithic scheme is implemented for "
120 "THERMO_RICHARDS_MECHANICS");
121 }
122
123 checkProcessVariableComponents(*variable_T, 1);
124 checkProcessVariableComponents(*variable_p, 1);
125 checkProcessVariableComponents(*variable_u, DisplacementDim);
126
128
129 auto solid_constitutive_relations =
130 CreateConstitutiveSetting::createSolidConstitutiveRelations(
131 parameters, local_coordinate_system, materialIDs(mesh), config);
132
133 // Specific body force
134 Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
135 {
136 std::vector<double> const b =
138 config.getConfigParameter<std::vector<double>>(
139 "specific_body_force");
140 if (b.size() != DisplacementDim)
141 {
142 OGS_FATAL(
143 "The size of the specific body force vector does not match the "
144 "displacement dimension. Vector size is {:d}, displacement "
145 "dimension is {:d}",
146 b.size(), DisplacementDim);
147 }
148
149 std::copy_n(b.data(), b.size(), specific_body_force.data());
150 }
151
152 auto media_map =
154 DBUG(
155 "Check the media properties of ThermoRichardsMechanics process "
156 "...");
157 checkMPLProperties(media);
158 DBUG("Media properties verified.");
159
161 config, parameters, mesh, mandatory_stress0_type);
162
163 bool mass_lumping = false;
164 if (auto const mass_lumping_ptr =
166 config.getConfigParameterOptional<bool>("mass_lumping"))
167 {
168 DBUG("Using mass lumping for the Richards flow equation.");
169 mass_lumping = *mass_lumping_ptr;
170 }
171
172 bool const apply_body_force_for_deformation =
174 config.getConfigParameter<bool>("apply_body_force_for_deformation",
175 true);
176
177 bool const initialize_porosity_from_medium_property =
179 config.getConfigParameter("initialize_porosity_from_medium_property",
180 true);
181
182 auto const is_linear =
184 config.getConfigParameter("linear", false);
185
186 const bool use_TaylorHood_elements =
187 variable_p->getShapeFunctionOrder() !=
188 variable_u->getShapeFunctionOrder()
189 ? true
190 : false;
191
193 process_data{materialIDs(mesh),
194 std::move(media_map),
195 std::move(solid_constitutive_relations),
196 std::move(initial_stress),
197 specific_body_force,
198 mass_lumping,
199 use_TaylorHood_elements,
200 apply_body_force_for_deformation,
202 initialize_porosity_from_medium_property}};
203
204 SecondaryVariableCollection secondary_variables;
205
206 ProcessLib::createSecondaryVariables(config, secondary_variables);
207
208 return std::make_unique<
210 name, mesh, std::move(jacobian_assembler), parameters,
211 integration_order, std::move(process_variables),
212 std::move(process_data), std::move(secondary_variables),
213 use_monolithic_scheme, is_linear);
214}
215
216template <int DisplacementDim>
218 std::string const& name,
219 MeshLib::Mesh& mesh,
220 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
221 std::vector<ProcessVariable> const& variables,
222 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
223 std::optional<ParameterLib::CoordinateSystem> const&
224 local_coordinate_system,
225 unsigned const integration_order,
226 BaseLib::ConfigTree const& config,
227 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
228{
230 config.checkConfigParameter("type", "THERMO_RICHARDS_MECHANICS");
231 DBUG("Create ThermoRichardsMechanicsProcess.");
232
233 auto const subtype =
235 config.getConfigParameter<std::string>("subtype",
236 "Stress_StrainTemperature");
237 INFO("TRM process subtype is '{}'", subtype);
238
239 if (subtype == "Stress_StrainTemperature")
240 {
241 bool const mandatory_stress0_type = false;
243 DisplacementDim,
245 DisplacementDim>,
247 DisplacementDim>>(name, mesh, std::move(jacobian_assembler),
248 variables, parameters,
249 local_coordinate_system, integration_order,
250 config, media, mandatory_stress0_type);
251 }
252
253 if (subtype == "StressSaturation_StrainPressureTemperature")
254 {
255#ifdef OGS_USE_MFRONT
256 bool const mandatory_stress0_type = true;
258 DisplacementDim,
259 ConstitutiveStressSaturation_StrainPressureTemperature::
260 ConstitutiveTraits<DisplacementDim>,
261 ConstitutiveStressSaturation_StrainPressureTemperature::
262 CreateConstitutiveSetting<DisplacementDim>>(
263 name, mesh, std::move(jacobian_assembler), variables, parameters,
264 local_coordinate_system, integration_order, config, media,
265 mandatory_stress0_type);
266#else
267 OGS_FATAL(
268 "TRM process subtype 'StressSaturation_StrainPressureTemperature' "
269 "is not supported, because OGS has not been built with MFront.");
270#endif
271 }
272
273 OGS_FATAL("Unknown TRM process subtype '{}'.", subtype);
274}
275
276template std::unique_ptr<Process> createThermoRichardsMechanicsProcess<2>(
277 std::string const& name,
278 MeshLib::Mesh& mesh,
279 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
280 std::vector<ProcessVariable> const& variables,
281 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
282 std::optional<ParameterLib::CoordinateSystem> const&
283 local_coordinate_system,
284 unsigned const integration_order,
285 BaseLib::ConfigTree const& config,
286 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
287
288template std::unique_ptr<Process> createThermoRichardsMechanicsProcess<3>(
289 std::string const& name,
290 MeshLib::Mesh& mesh,
291 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
292 std::vector<ProcessVariable> const& variables,
293 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
294 std::optional<ParameterLib::CoordinateSystem> const&
295 local_coordinate_system,
296 unsigned const integration_order,
297 BaseLib::ConfigTree const& config,
298 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
299
300} // namespace ThermoRichardsMechanics
301} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:19
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
std::optional< T > getConfigParameterOptional(std::string const &param) const
T getConfigParameter(std::string const &param) const
ConfigTree getConfigSubtree(std::string const &root) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
unsigned getShapeFunctionOrder() const
std::string const & getName() const
int getNumberOfGlobalComponents() const
Returns the number of components of the process variable.
Handles configuration of several secondary variables from the project file.
Global assembler for the monolithic scheme of the non-isothermal Richards flow coupled with mechanics...
MaterialSpatialDistributionMap createMaterialSpatialDistributionMap(std::map< int, std::shared_ptr< Medium > > const &media, MeshLib::Mesh const &mesh)
void checkMPLProperties(std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::unique_ptr< Process > createThermoRichardsMechanicsProcessStage2(std::string const &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, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media, bool const mandatory_stress0_type)
void checkProcessVariableComponents(ProcessVariable const &variable, const int dim)
template std::unique_ptr< Process > createThermoRichardsMechanicsProcess< 3 >(std::string const &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, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createThermoRichardsMechanicsProcess< 2 >(std::string const &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, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
BaseLib::StrongType< bool, struct InitializePorosityFromMediumPropertyTag > InitializePorosityFromMediumProperty
A type helping to avoid confusion of different boolean values.
std::unique_ptr< Process > createThermoRichardsMechanicsProcess(std::string const &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, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::vector< std::reference_wrapper< ProcessVariable > > findProcessVariables(std::vector< ProcessVariable > const &variables, BaseLib::ConfigTree const &pv_config, std::initializer_list< std::string > tags)
InitialStress createInitialStress(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, MeshLib::Mesh const &mesh, bool const mandatory_stress_type)
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables)