OGS 6.2.1-97-g73d1aeda3
CreateThermoMechanicsProcess.cpp
Go to the documentation of this file.
1 
11 
12 #include <cassert>
13 
16 #include "ParameterLib/Utils.h"
19 
20 #include "ThermoMechanicsProcess.h"
22 
23 namespace ProcessLib
24 {
25 namespace ThermoMechanics
26 {
27 template <int DisplacementDim>
28 std::unique_ptr<Process> createThermoMechanicsProcess(
29  std::string 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  boost::optional<ParameterLib::CoordinateSystem> const&
35  local_coordinate_system,
36  unsigned const integration_order,
37  BaseLib::ConfigTree const& config)
38 {
40  config.checkConfigParameter("type", "THERMO_MECHANICS");
41  DBUG("Create ThermoMechanicsProcess.");
42 
43  auto const staggered_scheme =
45  config.getConfigParameterOptional<std::string>("coupling_scheme");
46  const bool use_monolithic_scheme =
47  !(staggered_scheme && (*staggered_scheme == "staggered"));
48 
49  // Process variable.
50 
52  auto const pv_config = config.getConfigSubtree("process_variables");
53 
54  // Process IDs, which are set according to the appearance order of the
55  int heat_conduction_process_id = 0;
56  int mechanics_process_id = 0;
57 
58  ProcessVariable* variable_T;
59  ProcessVariable* variable_u;
60  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
61  process_variables;
62  if (use_monolithic_scheme) // monolithic scheme.
63  {
64  auto per_process_variables = findProcessVariables(
65  variables, pv_config,
66  {
67  "temperature",
69  "displacement"});
70  variable_T = &per_process_variables[0].get();
71  variable_u = &per_process_variables[1].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 : {"temperature"s, "displacement"s})
78  {
79  auto per_process_variables =
80  findProcessVariables(variables, pv_config, {variable_name});
81  process_variables.push_back(std::move(per_process_variables));
82  }
83  variable_T = &process_variables[0][0].get();
84  variable_u = &process_variables[1][0].get();
85  // process variables. Up to now, the ordering is fixed as:
86  heat_conduction_process_id = 0;
87  mechanics_process_id = 1;
88  }
89 
90  DBUG("Associate displacement with process variable '%s'.",
91  variable_u->getName().c_str());
92 
93  if (variable_u->getNumberOfComponents() != DisplacementDim)
94  {
95  OGS_FATAL(
96  "Number of components of the process variable '%s' is different "
97  "from the displacement dimension: got %d, expected %d",
98  variable_u->getName().c_str(),
99  variable_u->getNumberOfComponents(),
100  DisplacementDim);
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  "Pressure process variable '%s' is not a scalar variable but has "
109  "%d components.",
110  variable_T->getName().c_str(),
111  variable_T->getNumberOfComponents());
112  }
113 
115  config.peekConfigParameter<std::string>("constitutive_relation");
116  auto solid_constitutive_relations =
117  MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
118  parameters, local_coordinate_system, config);
119 
120  // Reference solid density
121  auto& reference_solid_density = ParameterLib::findParameter<double>(
122  config,
124  "reference_solid_density", parameters, 1, &mesh);
125  DBUG("Use '%s' as solid density parameter.",
126  reference_solid_density.name.c_str());
127 
128  // Linear thermal expansion coefficient
129  auto& linear_thermal_expansion_coefficient = ParameterLib::findParameter<
130  double>(
131  config,
133  "linear_thermal_expansion_coefficient", parameters, 1, &mesh);
134  DBUG("Use '%s' as linear thermal expansion coefficient.",
135  linear_thermal_expansion_coefficient.name.c_str());
136  // Specific heat capacity
137  auto& specific_heat_capacity = ParameterLib::findParameter<double>(
138  config,
140  "specific_heat_capacity", parameters, 1, &mesh);
141  DBUG("Use '%s' as specific heat capacity parameter.",
142  specific_heat_capacity.name.c_str());
143  // Thermal conductivity // TODO To be changed as tensor input.
144  auto& thermal_conductivity = ParameterLib::findParameter<double>(
145  config,
147  "thermal_conductivity", parameters, 1, &mesh);
148  DBUG("Use '%s' as thermal conductivity parameter.",
149  thermal_conductivity.name.c_str());
150 
151  // Specific body force
152  Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
153  {
154  std::vector<double> const b =
156  config.getConfigParameter<std::vector<double>>(
157  "specific_body_force");
158  if (b.size() != DisplacementDim)
159  {
160  OGS_FATAL(
161  "The size of the specific body force vector does not match the "
162  "displacement dimension. Vector size is %d, displacement "
163  "dimension is %d",
164  b.size(), DisplacementDim);
165  }
166 
167  std::copy_n(b.data(), b.size(), specific_body_force.data());
168  }
169  // Non-equilibrium variables
170  ParameterLib::Parameter<double> const* nonequilibrium_stress = nullptr;
171  const auto& nonequilibrium_state_variables_config =
173  config.getConfigSubtreeOptional("nonequilibrium_state_variables");
174  if (nonequilibrium_state_variables_config)
175  {
176  nonequilibrium_stress = &ParameterLib::findParameter<double>(
177  *nonequilibrium_state_variables_config,
179  "stress", parameters,
181  DisplacementDim>::value);
182  }
183 
185  materialIDs(mesh), std::move(solid_constitutive_relations),
186  reference_solid_density, linear_thermal_expansion_coefficient,
188  specific_body_force, nonequilibrium_stress,
189  mechanics_process_id, heat_conduction_process_id};
190 
191  SecondaryVariableCollection secondary_variables;
192 
193  NumLib::NamedFunctionCaller named_function_caller(
194  {"ThermoMechanics_temperature_displacement"});
195 
196  ProcessLib::createSecondaryVariables(config, secondary_variables,
197  named_function_caller);
198 
199  return std::make_unique<ThermoMechanicsProcess<DisplacementDim>>(
200  std::move(name), mesh, std::move(jacobian_assembler), parameters,
201  integration_order, std::move(process_variables),
202  std::move(process_data), std::move(secondary_variables),
203  std::move(named_function_caller), use_monolithic_scheme);
204 }
205 
206 template std::unique_ptr<Process> createThermoMechanicsProcess<2>(
207  std::string name,
208  MeshLib::Mesh& mesh,
209  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
210  std::vector<ProcessVariable> const& variables,
211  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
212  boost::optional<ParameterLib::CoordinateSystem> const&
213  local_coordinate_system,
214  unsigned const integration_order,
215  BaseLib::ConfigTree const& config);
216 
217 template std::unique_ptr<Process> createThermoMechanicsProcess<3>(
218  std::string name,
219  MeshLib::Mesh& mesh,
220  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
221  std::vector<ProcessVariable> const& variables,
222  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
223  boost::optional<ParameterLib::CoordinateSystem> const&
224  local_coordinate_system,
225  unsigned const integration_order,
226  BaseLib::ConfigTree const& config);
227 
228 } // namespace ThermoMechanics
229 } // namespace ProcessLib
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables, NumLib::NamedFunctionCaller &named_function_caller)
Kelvin vector dimensions for given displacement dimension.
Definition: KelvinVector.h:23
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:101
template std::unique_ptr< Process > createThermoMechanicsProcess< 2 >(std::string 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, 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.
void checkConfigParameter(std::string const &param, T const &value) const
T peekConfigParameter(std::string const &param) const
std::string const & getName() const
int getNumberOfComponents() const
Returns the number of components of the process variable.
std::unique_ptr< Process > createThermoMechanicsProcess(std::string 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, boost::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
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.
boost::optional< T > getConfigParameterOptional(std::string const &param) const
#define OGS_FATAL(fmt,...)
Definition: Error.h:63
template std::unique_ptr< Process > createThermoMechanicsProcess< 3 >(std::string 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, boost::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)