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