OGS 6.2.0-97-g4a610c866
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  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_MECHANICS");
40  DBUG("Create ThermoMechanicsProcess.");
41 
42  auto const staggered_scheme =
44  config.getConfigParameterOptional<std::string>("coupling_scheme");
45  const bool use_monolithic_scheme =
46  !(staggered_scheme && (*staggered_scheme == "staggered"));
47 
48  // Process variable.
49 
51  auto const pv_config = config.getConfigSubtree("process_variables");
52 
53  ProcessVariable* variable_T;
54  ProcessVariable* variable_u;
55  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
56  process_variables;
57  if (use_monolithic_scheme) // monolithic scheme.
58  {
59  auto per_process_variables = findProcessVariables(
60  variables, pv_config,
61  {
62  "temperature",
64  "displacement"});
65  variable_T = &per_process_variables[0].get();
66  variable_u = &per_process_variables[1].get();
67  process_variables.push_back(std::move(per_process_variables));
68  }
69  else // staggered scheme.
70  {
71  using namespace std::string_literals;
72  for (auto const& variable_name : {"temperature"s, "displacement"s})
73  {
74  auto per_process_variables =
75  findProcessVariables(variables, pv_config, {variable_name});
76  process_variables.push_back(std::move(per_process_variables));
77  }
78  variable_T = &process_variables[0][0].get();
79  variable_u = &process_variables[1][0].get();
80  }
81 
82  DBUG("Associate displacement with process variable '%s'.",
83  variable_u->getName().c_str());
84 
85  if (variable_u->getNumberOfComponents() != DisplacementDim)
86  {
87  OGS_FATAL(
88  "Number of components of the process variable '%s' is different "
89  "from the displacement dimension: got %d, expected %d",
90  variable_u->getName().c_str(),
91  variable_u->getNumberOfComponents(),
92  DisplacementDim);
93  }
94 
95  DBUG("Associate temperature with process variable '%s'.",
96  variable_T->getName().c_str());
97  if (variable_T->getNumberOfComponents() != 1)
98  {
99  OGS_FATAL(
100  "Pressure process variable '%s' is not a scalar variable but has "
101  "%d components.",
102  variable_T->getName().c_str(),
103  variable_T->getNumberOfComponents());
104  }
105 
107  config.peekConfigParameter<std::string>("constitutive_relation");
108  auto solid_constitutive_relations =
109  MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
110  parameters, local_coordinate_system, config);
111 
112  // Reference solid density
113  auto& reference_solid_density = ParameterLib::findParameter<double>(
114  config,
116  "reference_solid_density", parameters, 1);
117  DBUG("Use '%s' as solid density parameter.",
118  reference_solid_density.name.c_str());
119 
120  // Linear thermal expansion coefficient
121  auto& linear_thermal_expansion_coefficient = ParameterLib::findParameter<
122  double>(
123  config,
125  "linear_thermal_expansion_coefficient", parameters, 1);
126  DBUG("Use '%s' as linear thermal expansion coefficient.",
127  linear_thermal_expansion_coefficient.name.c_str());
128  // Specific heat capacity
129  auto& specific_heat_capacity = ParameterLib::findParameter<double>(
130  config,
132  "specific_heat_capacity", parameters, 1);
133  DBUG("Use '%s' as specific heat capacity parameter.",
134  specific_heat_capacity.name.c_str());
135  // Thermal conductivity // TODO To be changed as tensor input.
136  auto& thermal_conductivity = ParameterLib::findParameter<double>(
137  config,
139  "thermal_conductivity", parameters, 1);
140  DBUG("Use '%s' as thermal conductivity parameter.",
141  thermal_conductivity.name.c_str());
142 
143  // Specific body force
144  Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
145  {
146  std::vector<double> const b =
148  config.getConfigParameter<std::vector<double>>(
149  "specific_body_force");
150  if (b.size() != DisplacementDim)
151  {
152  OGS_FATAL(
153  "The size of the specific body force vector does not match the "
154  "displacement dimension. Vector size is %d, displacement "
155  "dimension is %d",
156  b.size(), DisplacementDim);
157  }
158 
159  std::copy_n(b.data(), b.size(), specific_body_force.data());
160  }
161 
163  materialIDs(mesh), std::move(solid_constitutive_relations),
164  reference_solid_density, linear_thermal_expansion_coefficient,
166  specific_body_force};
167 
168  SecondaryVariableCollection secondary_variables;
169 
170  NumLib::NamedFunctionCaller named_function_caller(
171  {"ThermoMechanics_temperature_displacement"});
172 
173  ProcessLib::createSecondaryVariables(config, secondary_variables,
174  named_function_caller);
175 
176  return std::make_unique<ThermoMechanicsProcess<DisplacementDim>>(
177  mesh, std::move(jacobian_assembler), parameters, integration_order,
178  std::move(process_variables), std::move(process_data),
179  std::move(secondary_variables), std::move(named_function_caller),
180  use_monolithic_scheme);
181 }
182 
183 template std::unique_ptr<Process> createThermoMechanicsProcess<2>(
184  MeshLib::Mesh& mesh,
185  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
186  std::vector<ProcessVariable> const& variables,
187  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
188  boost::optional<ParameterLib::CoordinateSystem> const&
189  local_coordinate_system,
190  unsigned const integration_order,
191  BaseLib::ConfigTree const& config);
192 
193 template std::unique_ptr<Process> createThermoMechanicsProcess<3>(
194  MeshLib::Mesh& mesh,
195  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
196  std::vector<ProcessVariable> const& variables,
197  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
198  boost::optional<ParameterLib::CoordinateSystem> const&
199  local_coordinate_system,
200  unsigned const integration_order,
201  BaseLib::ConfigTree const& config);
202 
203 } // namespace ThermoMechanics
204 } // namespace ProcessLib
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables, NumLib::NamedFunctionCaller &named_function_caller)
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< 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.
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< ParameterLib::ParameterBase >> const &parameters, boost::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
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
T peekConfigParameter(std::string const &param) const
std::string const & getName() const
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< ParameterLib::ParameterBase >> const &parameters, boost::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, 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: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