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(
48 required_liquid_properties);
49 checkRequiredProperties(
51 required_solid_properties);
52 }
53}
54
56 const int dim)
57{
58 DBUG("Associate displacement with process variable '{:s}'.",
59 variable.getName());
60
61 if (variable.getNumberOfGlobalComponents() != dim)
62 {
64 "Number of components of the process variable '{:s}' is different "
65 "from the displacement dimension: got {:d}, expected {:d}",
66 variable.getName(),
68 dim);
69 }
70}
71
72template <int DisplacementDim, typename ConstitutiveTraits,
73 typename CreateConstitutiveSetting>
75 std::string const& name, MeshLib::Mesh& mesh,
76 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
77 std::vector<ProcessVariable> const& variables,
78 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
79 std::optional<ParameterLib::CoordinateSystem> const&
80 local_coordinate_system,
81 unsigned const integration_order, BaseLib::ConfigTree const& config,
82 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media,
83 bool const mandatory_stress0_type)
84{
85 auto const coupling_scheme =
87 config.getConfigParameterOptional<std::string>("coupling_scheme");
88 const bool use_monolithic_scheme =
89 !(coupling_scheme && (*coupling_scheme == "staggered"));
90
92
94 auto const pv_config = config.getConfigSubtree("process_variables");
95
96 ProcessVariable* variable_T;
97 ProcessVariable* variable_p;
98 ProcessVariable* variable_u;
99 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
100 process_variables;
101 if (use_monolithic_scheme) // monolithic scheme.
102 {
105 auto per_process_variables = findProcessVariables(
106 variables, pv_config,
107 {
108 "temperature",
110 "pressure",
112 "displacement"});
113 variable_T = &per_process_variables[0].get();
114 variable_p = &per_process_variables[1].get();
115 variable_u = &per_process_variables[2].get();
116 process_variables.push_back(std::move(per_process_variables));
117 }
118 else // staggered scheme.
119 {
120 OGS_FATAL(
121 "So far, only the monolithic scheme is implemented for "
122 "THERMO_RICHARDS_MECHANICS");
123 }
124
125 checkProcessVariableComponents(*variable_T, 1);
126 checkProcessVariableComponents(*variable_p, 1);
127 checkProcessVariableComponents(*variable_u, DisplacementDim);
128
130
131 auto solid_constitutive_relations =
132 CreateConstitutiveSetting::createSolidConstitutiveRelations(
133 parameters, local_coordinate_system, materialIDs(mesh), config);
134
135 // Specific body force
136 Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
137 {
138 std::vector<double> const b =
140 config.getConfigParameter<std::vector<double>>(
141 "specific_body_force");
142 if (b.size() != DisplacementDim)
143 {
144 OGS_FATAL(
145 "The size of the specific body force vector does not match the "
146 "displacement dimension. Vector size is {:d}, displacement "
147 "dimension is {:d}",
148 b.size(), DisplacementDim);
149 }
150
151 std::copy_n(b.data(), b.size(), specific_body_force.data());
152 }
153
154 auto media_map =
156 DBUG(
157 "Check the media properties of ThermoRichardsMechanics process "
158 "...");
159 checkMPLProperties(media);
160 DBUG("Media properties verified.");
161
163 config, parameters, mesh, mandatory_stress0_type);
164
165 bool mass_lumping = false;
166 if (auto const mass_lumping_ptr =
168 config.getConfigParameterOptional<bool>("mass_lumping"))
169 {
170 DBUG("Using mass lumping for the Richards flow equation.");
171 mass_lumping = *mass_lumping_ptr;
172 }
173
174 bool const apply_body_force_for_deformation =
176 config.getConfigParameter<bool>("apply_body_force_for_deformation",
177 true);
178
179 bool const initialize_porosity_from_medium_property =
181 config.getConfigParameter("initialize_porosity_from_medium_property",
182 true);
183
184 auto const is_linear =
186 config.getConfigParameter("linear", false);
187
188 const bool use_TaylorHood_elements =
189 variable_p->getShapeFunctionOrder() !=
190 variable_u->getShapeFunctionOrder()
191 ? true
192 : false;
193
195 process_data{materialIDs(mesh),
196 std::move(media_map),
197 std::move(solid_constitutive_relations),
198 std::move(initial_stress),
199 specific_body_force,
200 mass_lumping,
201 use_TaylorHood_elements,
202 apply_body_force_for_deformation,
204 initialize_porosity_from_medium_property}};
205
206 SecondaryVariableCollection secondary_variables;
207
208 ProcessLib::createSecondaryVariables(config, secondary_variables);
209
210 return std::make_unique<
212 name, mesh, std::move(jacobian_assembler), parameters,
213 integration_order, std::move(process_variables),
214 std::move(process_data), std::move(secondary_variables),
215 use_monolithic_scheme, is_linear);
216}
217
218template <int DisplacementDim>
220 std::string const& name,
221 MeshLib::Mesh& mesh,
222 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
223 std::vector<ProcessVariable> const& variables,
224 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
225 std::optional<ParameterLib::CoordinateSystem> const&
226 local_coordinate_system,
227 unsigned const integration_order,
228 BaseLib::ConfigTree const& config,
229 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
230{
232 config.checkConfigParameter("type", "THERMO_RICHARDS_MECHANICS");
233 DBUG("Create ThermoRichardsMechanicsProcess.");
234
235 auto const subtype =
237 config.getConfigParameter<std::string>("subtype",
238 "Stress_StrainTemperature");
239 INFO("TRM process subtype is '{}'", subtype);
240
241 if (subtype == "Stress_StrainTemperature")
242 {
243 bool const mandatory_stress0_type = false;
245 DisplacementDim,
247 DisplacementDim>,
249 DisplacementDim>>(name, mesh, std::move(jacobian_assembler),
250 variables, parameters,
251 local_coordinate_system, integration_order,
252 config, media, mandatory_stress0_type);
253 }
254
255 if (subtype == "StressSaturation_StrainPressureTemperature")
256 {
257#ifdef OGS_USE_MFRONT
258 bool const mandatory_stress0_type = true;
260 DisplacementDim,
261 ConstitutiveStressSaturation_StrainPressureTemperature::
262 ConstitutiveTraits<DisplacementDim>,
263 ConstitutiveStressSaturation_StrainPressureTemperature::
264 CreateConstitutiveSetting<DisplacementDim>>(
265 name, mesh, std::move(jacobian_assembler), variables, parameters,
266 local_coordinate_system, integration_order, config, media,
267 mandatory_stress0_type);
268#else
269 OGS_FATAL(
270 "TRM process subtype 'StressSaturation_StrainPressureTemperature' "
271 "is not supported, because OGS has not been built with MFront.");
272#endif
273 }
274
275 OGS_FATAL("Unknown TRM process subtype '{}'.", subtype);
276}
277
278template std::unique_ptr<Process> createThermoRichardsMechanicsProcess<2>(
279 std::string const& name,
280 MeshLib::Mesh& mesh,
281 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
282 std::vector<ProcessVariable> const& variables,
283 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
284 std::optional<ParameterLib::CoordinateSystem> const&
285 local_coordinate_system,
286 unsigned const integration_order,
287 BaseLib::ConfigTree const& config,
288 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
289
290template std::unique_ptr<Process> createThermoRichardsMechanicsProcess<3>(
291 std::string const& name,
292 MeshLib::Mesh& mesh,
293 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
294 std::vector<ProcessVariable> const& variables,
295 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
296 std::optional<ParameterLib::CoordinateSystem> const&
297 local_coordinate_system,
298 unsigned const integration_order,
299 BaseLib::ConfigTree const& config,
300 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
301
302} // namespace ThermoRichardsMechanics
303} // 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)