OGS
CreateThermoHydroMechanicsProcess.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
14#include "ParameterLib/Utils.h"
21
22namespace ProcessLib
23{
25{
26template <int DisplacementDim>
27std::unique_ptr<Process> createThermoHydroMechanicsProcess(
28 std::string const& name, MeshLib::Mesh& mesh,
29 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
30 std::vector<ProcessVariable> const& variables,
31 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
32 std::optional<ParameterLib::CoordinateSystem> const&
33 local_coordinate_system,
34 unsigned const integration_order, BaseLib::ConfigTree const& config,
35 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
36{
38 config.checkConfigParameter("type", "THERMO_HYDRO_MECHANICS");
39 DBUG("Create ThermoHydroMechanicsProcess.");
40
41 auto const coupling_scheme =
43 config.getConfigParameterOptional<std::string>("coupling_scheme");
44 const bool use_monolithic_scheme =
45 !(coupling_scheme && (*coupling_scheme == "staggered"));
46
48
50 auto const pv_config = config.getConfigSubtree("process_variables");
51
52 ProcessVariable* variable_T;
53 ProcessVariable* variable_p;
54 ProcessVariable* variable_u;
55 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
56 process_variables;
57 if (use_monolithic_scheme) // monolithic scheme.
58 {
61 auto per_process_variables = findProcessVariables(
62 variables, pv_config,
63 {
64 "temperature",
66 "pressure",
68 "displacement"});
69 variable_T = &per_process_variables[0].get();
70 variable_p = &per_process_variables[1].get();
71 variable_u = &per_process_variables[2].get();
72 process_variables.push_back(std::move(per_process_variables));
73 }
74 else // staggered scheme.
75 {
76 using namespace std::string_literals;
77 for (auto const& variable_name :
78 {"temperature"s, "pressure"s, "displacement"s})
79 {
80 auto per_process_variables =
81 findProcessVariables(variables, pv_config, {variable_name});
82 process_variables.push_back(std::move(per_process_variables));
83 }
84 variable_T = &process_variables[0][0].get();
85 variable_p = &process_variables[1][0].get();
86 variable_u = &process_variables[2][0].get();
87 }
88
89 if (variable_T->getShapeFunctionOrder() != 1)
90 {
92 "The shape function order of temperature must be 1 but its input "
93 "value in <process_variable><order> is {:d}. Please correct it.",
94 variable_T->getShapeFunctionOrder());
95 }
96 if (variable_p->getShapeFunctionOrder() != 1)
97 {
99 "The shape function order of pressure must be 1 but its input "
100 "value in <process_variable><order> is {:d}. Please correct it.",
101 variable_p->getShapeFunctionOrder());
102 }
103
104 DBUG("Associate displacement with process variable '{:s}'.",
105 variable_u->getName());
106
107 if (variable_u->getNumberOfGlobalComponents() != DisplacementDim)
108 {
109 OGS_FATAL(
110 "Number of components of the process variable '{:s}' is different "
111 "from the displacement dimension: got {:d}, expected {:d}",
112 variable_u->getName(),
113 variable_u->getNumberOfGlobalComponents(),
114 DisplacementDim);
115 }
116
117 DBUG("Associate pressure with process variable '{:s}'.",
118 variable_p->getName());
119 if (variable_p->getNumberOfGlobalComponents() != 1)
120 {
121 OGS_FATAL(
122 "Pressure process variable '{:s}' is not a scalar variable but has "
123 "{:d} components.",
124 variable_p->getName(),
125 variable_p->getNumberOfGlobalComponents());
126 }
127
128 DBUG("Associate temperature with process variable '{:s}'.",
129 variable_T->getName());
130 if (variable_T->getNumberOfGlobalComponents() != 1)
131 {
132 OGS_FATAL(
133 "temperature process variable '{:s}' is not a scalar variable but "
134 "has {:d} components.",
135 variable_T->getName(),
136 variable_T->getNumberOfGlobalComponents());
137 }
138
140 auto solid_constitutive_relations =
142 parameters, local_coordinate_system, materialIDs(mesh), config);
143
144 auto ice_constitutive_relation =
146 parameters, local_coordinate_system, config);
147
148 // Specific body force
149 Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
150 {
151 std::vector<double> const b =
153 config.getConfigParameter<std::vector<double>>(
154 "specific_body_force");
155 if (b.size() != DisplacementDim)
156 {
157 OGS_FATAL(
158 "The size of the specific body force vector does not match the "
159 "displacement dimension. Vector size is {:d}, displacement "
160 "dimension is {:d}",
161 b.size(), DisplacementDim);
162 }
163
164 std::copy_n(b.data(), b.size(), specific_body_force.data());
165 }
166
167 auto const is_linear =
169 config.getConfigParameter("linear", false);
170
171 auto media_map =
173
174 auto const equation_balance_type_str =
176 config.getConfigParameter<std::string>("equation_balance_type",
177 "volume");
178 if (equation_balance_type_str == "volume")
179 {
181 media_map);
182 }
183
184 // Initial stress conditions
185
187 config, parameters, mesh);
188
189 auto stabilizer = NumLib::createNumericalStabilization(mesh, config);
190
191 bool const is_volume_balance_equation_type =
192 equation_balance_type_str == "volume";
194 materialIDs(mesh),
195 std::move(media_map),
196 std::move(solid_constitutive_relations),
197 std::move(ice_constitutive_relation),
198 is_volume_balance_equation_type,
199 std::move(initial_stress),
200 specific_body_force,
201 std::move(stabilizer)};
202
203 SecondaryVariableCollection secondary_variables;
204
205 ProcessLib::createSecondaryVariables(config, secondary_variables);
206
207 return std::make_unique<ThermoHydroMechanicsProcess<DisplacementDim>>(
208 std::move(name), mesh, std::move(jacobian_assembler), parameters,
209 integration_order, std::move(process_variables),
210 std::move(process_data), std::move(secondary_variables),
211 use_monolithic_scheme, is_linear);
212}
213
214template std::unique_ptr<Process> createThermoHydroMechanicsProcess<2>(
215 std::string const& name,
216 MeshLib::Mesh& mesh,
217 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
218 std::vector<ProcessVariable> const& variables,
219 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
220 std::optional<ParameterLib::CoordinateSystem> const&
221 local_coordinate_system,
222 unsigned const integration_order,
223 BaseLib::ConfigTree const& config,
224 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
225
226template std::unique_ptr<Process> createThermoHydroMechanicsProcess<3>(
227 std::string const& name,
228 MeshLib::Mesh& mesh,
229 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
230 std::vector<ProcessVariable> const& variables,
231 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
232 std::optional<ParameterLib::CoordinateSystem> const&
233 local_coordinate_system,
234 unsigned const integration_order,
235 BaseLib::ConfigTree const& config,
236 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
237} // namespace ThermoHydroMechanics
238} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:19
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.
std::map< int, std::shared_ptr< MaterialLib::Solids::MechanicsBase< DisplacementDim > > > createConstitutiveRelations(std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, MeshLib::PropertyVector< int > const *const material_ids, BaseLib::ConfigTree const &config)
std::unique_ptr< MaterialLib::Solids::MechanicsBase< DisplacementDim > > createConstitutiveRelationIce(std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, BaseLib::ConfigTree const &config)
MaterialSpatialDistributionMap createMaterialSpatialDistributionMap(std::map< int, std::shared_ptr< Medium > > const &media, MeshLib::Mesh const &mesh)
NumericalStabilization createNumericalStabilization(MeshLib::Mesh const &mesh, BaseLib::ConfigTree const &config)
void checkVolumeBalanceEquationSetting(MaterialPropertyLib::MaterialSpatialDistributionMap const &media_map)
std::unique_ptr< Process > createThermoHydroMechanicsProcess(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 > createThermoHydroMechanicsProcess< 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)
template std::unique_ptr< Process > createThermoHydroMechanicsProcess< 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)
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)