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