OGS
CreateThermoMechanicalPhaseFieldProcess.cpp
Go to the documentation of this file.
1
12
13#include <cassert>
14
17#include "ParameterLib/Utils.h"
22
23namespace ProcessLib
24{
25namespace ThermoMechanicalPhaseField
26{
27template <int DisplacementDim>
29 std::string const& name,
30 MeshLib::Mesh& mesh,
31 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
32 std::vector<ProcessVariable> const& variables,
33 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
34 std::optional<ParameterLib::CoordinateSystem> const&
35 local_coordinate_system,
36 unsigned const integration_order,
37 BaseLib::ConfigTree const& config)
38{
40 config.checkConfigParameter("type", "THERMO_MECHANICAL_PHASE_FIELD");
41 DBUG("Create ThermoMechanicalPhaseFieldProcess.");
42
43 INFO(
44 "Solve the coupling with the staggered scheme,"
45 "which is the only option for TM-Phasefield in the current code");
46
48
50 auto const pv_config = config.getConfigSubtree("process_variables");
51 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
52 process_variables;
53 int heat_conduction_process_id = 0;
54 int mechanics_related_process_id = 1;
55 int phase_field_process_id = 2;
56
58 auto process_variable_T = findProcessVariables(
59 variables, pv_config,
60 {
61 "temperature"});
62 process_variables.push_back(std::move(process_variable_T));
63 ProcessVariable* variable_T =
64 &process_variables[process_variables.size() - 1][0].get();
65
66 auto process_variable_u = findProcessVariables(
67 variables, pv_config,
68 {
69 "displacement"});
70 process_variables.push_back(std::move(process_variable_u));
71 ProcessVariable* variable_u =
72 &process_variables[process_variables.size() - 1][0].get();
73 auto process_variable_ph = findProcessVariables(
74 variables, pv_config,
75 {
76 "phasefield"});
77 process_variables.push_back(std::move(process_variable_ph));
78 ProcessVariable* variable_ph =
79 &process_variables[process_variables.size() - 1][0].get();
80
81 DBUG("Associate displacement with process variable '{:s}'.",
82 variable_u->getName());
83
84 if (variable_u->getNumberOfGlobalComponents() != DisplacementDim)
85 {
87 "Number of components of the process variable '{:s}' is different "
88 "from the displacement dimension: got {:d}, expected {:d}",
89 variable_u->getName(),
90 variable_u->getNumberOfGlobalComponents(),
91 DisplacementDim);
92 }
93
94 DBUG("Associate phase field with process variable '{:s}'.",
95 variable_ph->getName());
96 if (variable_ph->getNumberOfGlobalComponents() != 1)
97 {
99 "Phasefield process variable '{:s}' is not a scalar variable but "
100 "has {:d} components.",
101 variable_ph->getName(),
102 variable_ph->getNumberOfGlobalComponents());
103 }
104
105 DBUG("Associate temperature with process variable '{:s}'.",
106 variable_T->getName());
107 if (variable_T->getNumberOfGlobalComponents() != 1)
108 {
109 OGS_FATAL(
110 "Temperature process variable '{:s}' is not a scalar variable but "
111 "has {:d} components.",
112 variable_T->getName(),
113 variable_T->getNumberOfGlobalComponents());
114 }
115
117 auto solid_constitutive_relations =
119 parameters, local_coordinate_system, materialIDs(mesh), config);
120
121 auto const phasefield_parameters_config =
123 config.getConfigSubtree("phasefield_parameters");
124
125 auto const thermal_parameters_config =
127 config.getConfigSubtree("thermal_parameters");
128
129 // Residual stiffness
130 auto const& residual_stiffness = ParameterLib::findParameter<double>(
131 phasefield_parameters_config,
133 "residual_stiffness", parameters, 1, &mesh);
134 DBUG("Use '{:s}' as residual stiffness.", residual_stiffness.name);
135
136 // Crack resistance
137 auto const& crack_resistance = ParameterLib::findParameter<double>(
138 phasefield_parameters_config,
140 "crack_resistance", parameters, 1, &mesh);
141 DBUG("Use '{:s}' as crack resistance.", crack_resistance.name);
142
143 // Crack length scale
144 auto const& crack_length_scale = ParameterLib::findParameter<double>(
145 phasefield_parameters_config,
147 "crack_length_scale", parameters, 1, &mesh);
148 DBUG("Use '{:s}' as crack length scale.", crack_length_scale.name);
149
150 // Kinetic coefficient
151 auto const& kinetic_coefficient = ParameterLib::findParameter<double>(
152 phasefield_parameters_config,
154 "kinetic_coefficient", parameters, 1, &mesh);
155 DBUG("Use '{:s}' as kinetic coefficient.", kinetic_coefficient.name);
156
157 // Solid density
158 auto const& solid_density = ParameterLib::findParameter<double>(
159 config,
161 "solid_density", parameters, 1, &mesh);
162 DBUG("Use '{:s}' as solid density parameter.", solid_density.name);
163
164 // Linear thermal expansion coefficient
165 auto const& linear_thermal_expansion_coefficient =
167 thermal_parameters_config,
169 "linear_thermal_expansion_coefficient", parameters, 1, &mesh);
170 DBUG("Use '{:s}' as linear thermal expansion coefficient.",
171 linear_thermal_expansion_coefficient.name);
172
173 // Specific heat capacity
174 auto const& specific_heat_capacity = ParameterLib::findParameter<double>(
175 thermal_parameters_config,
177 "specific_heat_capacity", parameters, 1, &mesh);
178 DBUG("Use '{:s}' as specific heat capacity.", specific_heat_capacity.name);
179
180 // Thermal conductivity
181 auto const& thermal_conductivity = ParameterLib::findParameter<double>(
182 thermal_parameters_config,
184 "thermal_conductivity", parameters, 1, &mesh);
185 DBUG("Use '{:s}' as thermal conductivity parameter.",
186 thermal_conductivity.name);
187 // Residual thermal conductivity
188 auto const& residual_thermal_conductivity = ParameterLib::findParameter<
189 double>(
190 thermal_parameters_config,
192 "residual_thermal_conductivity", parameters, 1, &mesh);
193 DBUG("Use '{:s}' as residual thermal conductivity parameter.",
194 residual_thermal_conductivity.name);
195 // Reference temperature
196 const auto reference_temperature =
198 config.getConfigParameter<double>("reference_temperature");
199
200 // Specific body force
201 Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
202 {
203 std::vector<double> const b =
205 config.getConfigParameter<std::vector<double>>(
206 "specific_body_force");
207 if (specific_body_force.size() != DisplacementDim)
208 {
209 OGS_FATAL(
210 "The size of the specific body force vector does not match the "
211 "displacement dimension. Vector size is {:d}, displacement "
212 "dimension is {:d}",
213 specific_body_force.size(), DisplacementDim);
214 }
215
216 std::copy_n(b.data(), b.size(), specific_body_force.data());
217 }
218
220 materialIDs(mesh),
221 std::move(solid_constitutive_relations),
222 residual_stiffness,
223 crack_resistance,
224 crack_length_scale,
225 kinetic_coefficient,
226 solid_density,
227 linear_thermal_expansion_coefficient,
228 specific_heat_capacity,
229 thermal_conductivity,
230 residual_thermal_conductivity,
231 specific_body_force,
232 reference_temperature};
233
234 SecondaryVariableCollection secondary_variables;
235
236 ProcessLib::createSecondaryVariables(config, secondary_variables);
237
238 return std::make_unique<ThermoMechanicalPhaseFieldProcess<DisplacementDim>>(
239 std::move(name), mesh, std::move(jacobian_assembler), parameters,
240 integration_order, std::move(process_variables),
241 std::move(process_data), std::move(secondary_variables),
242 mechanics_related_process_id, phase_field_process_id,
243 heat_conduction_process_id);
244}
245
246template std::unique_ptr<Process> createThermoMechanicalPhaseFieldProcess<2>(
247 std::string const& name,
248 MeshLib::Mesh& mesh,
249 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
250 std::vector<ProcessVariable> const& variables,
251 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
252 std::optional<ParameterLib::CoordinateSystem> const&
253 local_coordinate_system,
254 unsigned const integration_order,
255 BaseLib::ConfigTree const& config);
256
257template std::unique_ptr<Process> createThermoMechanicalPhaseFieldProcess<3>(
258 std::string const& name,
259 MeshLib::Mesh& mesh,
260 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
261 std::vector<ProcessVariable> const& variables,
262 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
263 std::optional<ParameterLib::CoordinateSystem> const&
264 local_coordinate_system,
265 unsigned const integration_order,
266 BaseLib::ConfigTree const& config);
267
268} // namespace ThermoMechanicalPhaseField
269} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:26
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
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
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)
OGS_NO_DANGLING Parameter< ParameterDataType > & findParameter(std::string const &parameter_name, std::vector< std::unique_ptr< ParameterBase > > const &parameters, int const num_components, MeshLib::Mesh const *const mesh=nullptr)
Definition Utils.h:102
std::unique_ptr< Process > createThermoMechanicalPhaseFieldProcess(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)
template std::unique_ptr< Process > createThermoMechanicalPhaseFieldProcess< 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)
template std::unique_ptr< Process > createThermoMechanicalPhaseFieldProcess< 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::vector< std::reference_wrapper< ProcessVariable > > findProcessVariables(std::vector< ProcessVariable > const &variables, BaseLib::ConfigTree const &pv_config, std::initializer_list< std::string > tags)
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables)