OGS 6.1.0-1699-ge946d4c5f
CreateThermoMechanicalPhaseFieldProcess.cpp
Go to the documentation of this file.
1 
11 
12 #include <cassert>
13 
18 
21 
22 namespace ProcessLib
23 {
24 namespace ThermoMechanicalPhaseField
25 {
26 template <int DisplacementDim>
27 std::unique_ptr<Process> createThermoMechanicalPhaseFieldProcess(
28  MeshLib::Mesh& mesh,
29  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
30  std::vector<ProcessVariable> const& variables,
31  std::vector<std::unique_ptr<ParameterBase>> const& parameters,
32  unsigned const integration_order,
33  BaseLib::ConfigTree const& config)
34 {
36  config.checkConfigParameter("type", "THERMO_MECHANICAL_PHASE_FIELD");
37  DBUG("Create ThermoMechanicalPhaseFieldProcess.");
38 
39  INFO(
40  "Solve the coupling with the staggered scheme,"
41  "which is the only option for TM-Phasefield in the current code");
42 
43  // Process variable.
44 
46  auto const pv_config = config.getConfigSubtree("process_variables");
47  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
48  process_variables;
49  int heat_conduction_process_id = 0;
50  int mechanics_related_process_id = 1;
51  int phase_field_process_id = 2;
52 
53  auto process_variable_T = findProcessVariables(
54  variables, pv_config,
55  {
56  "temperature"});
57  process_variables.push_back(std::move(process_variable_T));
58  ProcessVariable* variable_T =
59  &process_variables[process_variables.size() - 1][0].get();
60 
61  auto process_variable_u = findProcessVariables(
62  variables, pv_config,
63  {
64  "displacement"});
65  process_variables.push_back(std::move(process_variable_u));
66  ProcessVariable* variable_u =
67  &process_variables[process_variables.size() - 1][0].get();
68  auto process_variable_ph = findProcessVariables(
69  variables, pv_config,
70  {
71  "phasefield"});
72  process_variables.push_back(std::move(process_variable_ph));
73  ProcessVariable* variable_ph =
74  &process_variables[process_variables.size() - 1][0].get();
75 
76  DBUG("Associate displacement with process variable '%s'.",
77  variable_u->getName().c_str());
78 
79  if (variable_u->getNumberOfComponents() != DisplacementDim)
80  {
81  OGS_FATAL(
82  "Number of components of the process variable '%s' is different "
83  "from the displacement dimension: got %d, expected %d",
84  variable_u->getName().c_str(),
85  variable_u->getNumberOfComponents(),
86  DisplacementDim);
87  }
88 
89  DBUG("Associate phase field with process variable '%s'.",
90  variable_ph->getName().c_str());
91  if (variable_ph->getNumberOfComponents() != 1)
92  {
93  OGS_FATAL(
94  "Phasefield process variable '%s' is not a scalar variable but has "
95  "%d components.",
96  variable_ph->getName().c_str(),
97  variable_ph->getNumberOfComponents());
98  }
99 
100  DBUG("Associate temperature with process variable '%s'.",
101  variable_T->getName().c_str());
102  if (variable_T->getNumberOfComponents() != 1)
103  {
104  OGS_FATAL(
105  "Temperature process variable '%s' is not a scalar variable but "
106  "has "
107  "%d components.",
108  variable_T->getName().c_str(),
109  variable_T->getNumberOfComponents());
110  }
111 
112  auto solid_constitutive_relations =
113  MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
114  parameters, config);
115 
116  auto const phasefield_parameters_config =
118  config.getConfigSubtree("phasefield_parameters");
119 
120  auto const thermal_parameters_config =
122  config.getConfigSubtree("thermal_parameters");
123 
124  // Residual stiffness
125  auto& residual_stiffness = findParameter<double>(
126  phasefield_parameters_config,
128  "residual_stiffness", parameters, 1);
129  DBUG("Use '%s' as residual stiffness.", residual_stiffness.name.c_str());
130 
131  // Crack resistance
132  auto& crack_resistance = findParameter<double>(
133  phasefield_parameters_config,
135  "crack_resistance", parameters, 1);
136  DBUG("Use '%s' as crack resistance.", crack_resistance.name.c_str());
137 
138  // Crack length scale
139  auto& crack_length_scale = findParameter<double>(
140  phasefield_parameters_config,
142  "crack_length_scale", parameters, 1);
143  DBUG("Use '%s' as crack length scale.", crack_length_scale.name.c_str());
144 
145  // Kinetic coefficient
146  auto& kinetic_coefficient = findParameter<double>(
147  phasefield_parameters_config,
149  "kinetic_coefficient", parameters, 1);
150  DBUG("Use '%s' as kinetic coefficient.", kinetic_coefficient.name.c_str());
151 
152  // Solid density
153  auto& solid_density = findParameter<double>(
154  config,
156  "solid_density", parameters, 1);
157  DBUG("Use '%s' as solid density parameter.", solid_density.name.c_str());
158 
159  // Linear thermal expansion coefficient
160  auto& linear_thermal_expansion_coefficient = findParameter<double>(
161  thermal_parameters_config,
163  "linear_thermal_expansion_coefficient", parameters, 1);
164  DBUG("Use '%s' as linear thermal expansion coefficient.",
165  linear_thermal_expansion_coefficient.name.c_str());
166 
167  // Specific heat capacity
168  auto& specific_heat_capacity = findParameter<double>(
169  thermal_parameters_config,
171  "specific_heat_capacity", parameters, 1);
172  DBUG("Use '%s' as specific heat capacity.",
173  specific_heat_capacity.name.c_str());
174 
175  // Thermal conductivity
176  auto& thermal_conductivity = findParameter<double>(
177  thermal_parameters_config,
179  "thermal_conductivity", parameters, 1);
180  DBUG("Use '%s' as thermal conductivity parameter.",
181  thermal_conductivity.name.c_str());
182  // Residual thermal conductivity
183  auto& residual_thermal_conductivity = findParameter<double>(
184  thermal_parameters_config,
186  "residual_thermal_conductivity", parameters, 1);
187  DBUG("Use '%s' as residual thermal conductivity parameter.",
188  residual_thermal_conductivity.name.c_str());
189  // Reference temperature
190  const double reference_temperature =
192  config.getConfigParameter<double>("reference_temperature");
193 
194  // Specific body force
195  Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
196  {
197  std::vector<double> const b =
199  config.getConfigParameter<std::vector<double>>(
200  "specific_body_force");
201  if (specific_body_force.size() != DisplacementDim)
202  OGS_FATAL(
203  "The size of the specific body force vector does not match the "
204  "displacement dimension. Vector size is %d, displacement "
205  "dimension is %d",
206  specific_body_force.size(), DisplacementDim);
207 
208  std::copy_n(b.data(), b.size(), specific_body_force.data());
209  }
210 
212  materialIDs(mesh),
213  std::move(solid_constitutive_relations),
214  residual_stiffness,
215  crack_resistance,
216  crack_length_scale,
217  kinetic_coefficient,
218  solid_density,
219  linear_thermal_expansion_coefficient,
222  residual_thermal_conductivity,
224  specific_body_force};
225 
226  SecondaryVariableCollection secondary_variables;
227 
228  NumLib::NamedFunctionCaller named_function_caller(
229  {"temperature_phasefield_displacement"});
230 
231  ProcessLib::createSecondaryVariables(config, secondary_variables,
232  named_function_caller);
233 
234  return std::make_unique<ThermoMechanicalPhaseFieldProcess<DisplacementDim>>(
235  mesh, std::move(jacobian_assembler), parameters, integration_order,
236  std::move(process_variables), std::move(process_data),
237  std::move(secondary_variables), std::move(named_function_caller),
238  mechanics_related_process_id, phase_field_process_id,
239  heat_conduction_process_id);
240 }
241 
242 template std::unique_ptr<Process> createThermoMechanicalPhaseFieldProcess<2>(
243  MeshLib::Mesh& mesh,
244  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
245  std::vector<ProcessVariable> const& variables,
246  std::vector<std::unique_ptr<ParameterBase>> const& parameters,
247  unsigned const integration_order,
248  BaseLib::ConfigTree const& config);
249 
250 template std::unique_ptr<Process> createThermoMechanicalPhaseFieldProcess<3>(
251  MeshLib::Mesh& mesh,
252  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
253  std::vector<ProcessVariable> const& variables,
254  std::vector<std::unique_ptr<ParameterBase>> const& parameters,
255  unsigned const integration_order,
256  BaseLib::ConfigTree const& config);
257 
258 } // namespace ThermoMechanicalPhaseField
259 } // namespace ProcessLib
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables, NumLib::NamedFunctionCaller &named_function_caller)
std::vector< std::reference_wrapper< ProcessVariable > > findProcessVariables(std::vector< ProcessVariable > const &variables, BaseLib::ConfigTree const &pv_config, std::initializer_list< std::string > tags)
Builds expression trees of named functions dynamically at runtime.
void checkConfigParameter(std::string const &param, T const &value) const
template std::unique_ptr< Process > createThermoMechanicalPhaseFieldProcess< 3 >(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config)
std::string const & getName() const
template std::unique_ptr< Process > createThermoMechanicalPhaseFieldProcess< 2 >(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config)
int getNumberOfComponents() const
Returns the number of components of the process variable.
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition: Mesh.cpp:342
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:146
std::unique_ptr< Process > createThermoMechanicalPhaseFieldProcess(MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config)
Handles configuration of several secondary variables from the project file.
#define OGS_FATAL(fmt,...)
Definition: Error.h:71