OGS 6.1.0-1699-ge946d4c5f
CreateThermoMechanicsProcess.cpp
Go to the documentation of this file.
1 
11 
12 #include <cassert>
13 
18 
19 #include "ThermoMechanicsProcess.h"
21 
22 namespace ProcessLib
23 {
24 namespace ThermoMechanics
25 {
26 template <int DisplacementDim>
27 std::unique_ptr<Process> createThermoMechanicsProcess(
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_MECHANICS");
37  DBUG("Create ThermoMechanicsProcess.");
38 
39  auto const staggered_scheme =
41  config.getConfigParameterOptional<std::string>("coupling_scheme");
42  const bool use_monolithic_scheme =
43  !(staggered_scheme && (*staggered_scheme == "staggered"));
44 
45  // Process variable.
46 
48  auto const pv_config = config.getConfigSubtree("process_variables");
49 
50  ProcessVariable* variable_T;
51  ProcessVariable* variable_u;
52  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
53  process_variables;
54  if (use_monolithic_scheme) // monolithic scheme.
55  {
56  auto per_process_variables = findProcessVariables(
57  variables, pv_config,
58  {
59  "temperature",
61  "displacement"});
62  variable_T = &per_process_variables[0].get();
63  variable_u = &per_process_variables[1].get();
64  process_variables.push_back(std::move(per_process_variables));
65  }
66  else // staggered scheme.
67  {
68  using namespace std::string_literals;
69  for (auto const& variable_name : {"temperature"s, "displacement"s})
70  {
71  auto per_process_variables =
72  findProcessVariables(variables, pv_config, {variable_name});
73  process_variables.push_back(std::move(per_process_variables));
74  }
75  variable_T = &process_variables[0][0].get();
76  variable_u = &process_variables[1][0].get();
77  }
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 temperature with process variable '%s'.",
93  variable_T->getName().c_str());
94  if (variable_T->getNumberOfComponents() != 1)
95  {
96  OGS_FATAL(
97  "Pressure process variable '%s' is not a scalar variable but has "
98  "%d components.",
99  variable_T->getName().c_str(),
100  variable_T->getNumberOfComponents());
101  }
102 
104  config.peekConfigParameter<std::string>("constitutive_relation");
105  auto solid_constitutive_relations =
106  MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
107  parameters, config);
108 
109  // Reference solid density
110  auto& reference_solid_density = findParameter<double>(
111  config,
113  "reference_solid_density", parameters, 1);
114  DBUG("Use '%s' as solid density parameter.",
115  reference_solid_density.name.c_str());
116 
117  // Linear thermal expansion coefficient
118  auto& linear_thermal_expansion_coefficient = findParameter<double>(
119  config,
121  "linear_thermal_expansion_coefficient", parameters, 1);
122  DBUG("Use '%s' as linear thermal expansion coefficient.",
123  linear_thermal_expansion_coefficient.name.c_str());
124  // Specific heat capacity
125  auto& specific_heat_capacity = findParameter<double>(
126  config,
128  "specific_heat_capacity", parameters, 1);
129  DBUG("Use '%s' as specific heat capacity parameter.",
130  specific_heat_capacity.name.c_str());
131  // Thermal conductivity // TODO To be changed as tensor input.
132  auto& thermal_conductivity = findParameter<double>(
133  config,
135  "thermal_conductivity", parameters, 1);
136  DBUG("Use '%s' as thermal conductivity parameter.",
137  thermal_conductivity.name.c_str());
138 
139  // Specific body force
140  Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
141  {
142  std::vector<double> const b =
144  config.getConfigParameter<std::vector<double>>(
145  "specific_body_force");
146  if (b.size() != DisplacementDim)
147  OGS_FATAL(
148  "The size of the specific body force vector does not match the "
149  "displacement dimension. Vector size is %d, displacement "
150  "dimension is %d",
151  b.size(), DisplacementDim);
152 
153  std::copy_n(b.data(), b.size(), specific_body_force.data());
154  }
155 
157  materialIDs(mesh), std::move(solid_constitutive_relations),
158  reference_solid_density, linear_thermal_expansion_coefficient,
160  specific_body_force};
161 
162  SecondaryVariableCollection secondary_variables;
163 
164  NumLib::NamedFunctionCaller named_function_caller(
165  {"ThermoMechanics_temperature_displacement"});
166 
167  ProcessLib::createSecondaryVariables(config, secondary_variables,
168  named_function_caller);
169 
170  return std::make_unique<ThermoMechanicsProcess<DisplacementDim>>(
171  mesh, std::move(jacobian_assembler), parameters, integration_order,
172  std::move(process_variables), std::move(process_data),
173  std::move(secondary_variables), std::move(named_function_caller),
174  use_monolithic_scheme);
175 }
176 
177 template std::unique_ptr<Process> createThermoMechanicsProcess<2>(
178  MeshLib::Mesh& mesh,
179  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
180  std::vector<ProcessVariable> const& variables,
181  std::vector<std::unique_ptr<ParameterBase>> const& parameters,
182  unsigned const integration_order,
183  BaseLib::ConfigTree const& config);
184 
185 template std::unique_ptr<Process> createThermoMechanicsProcess<3>(
186  MeshLib::Mesh& mesh,
187  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
188  std::vector<ProcessVariable> const& variables,
189  std::vector<std::unique_ptr<ParameterBase>> const& parameters,
190  unsigned const integration_order,
191  BaseLib::ConfigTree const& config);
192 
193 } // namespace ThermoMechanics
194 } // 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)
template std::unique_ptr< Process > createThermoMechanicsProcess< 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)
Builds expression trees of named functions dynamically at runtime.
void checkConfigParameter(std::string const &param, T const &value) const
template std::unique_ptr< Process > createThermoMechanicsProcess< 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)
T peekConfigParameter(std::string const &param) 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:342
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:146
std::unique_ptr< Process > createThermoMechanicsProcess(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.
boost::optional< T > getConfigParameterOptional(std::string const &param) const
#define OGS_FATAL(fmt,...)
Definition: Error.h:71