OGS
CreateThermoMechanicsProcess.cpp
Go to the documentation of this file.
1 
12 
13 #include <cassert>
14 
17 #include "MaterialLib/MPL/Medium.h"
20 #include "ParameterLib/Utils.h"
23 #include "ThermoMechanicsProcess.h"
25 
26 namespace ProcessLib
27 {
28 namespace ThermoMechanics
29 {
31  std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
32 {
33  std::array const required_solid_properties = {
37 
38  for (auto const& m : media)
39  {
40  checkRequiredProperties(m.second->phase("Solid"),
41  required_solid_properties);
42  }
43 }
44 
45 template <int DisplacementDim>
46 std::unique_ptr<Process> createThermoMechanicsProcess(
47  std::string name, MeshLib::Mesh& mesh,
48  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
49  std::vector<ProcessVariable> const& variables,
50  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
51  std::optional<ParameterLib::CoordinateSystem> const&
52  local_coordinate_system,
53  unsigned const integration_order, BaseLib::ConfigTree const& config,
54  std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media)
55 {
57  config.checkConfigParameter("type", "THERMO_MECHANICS");
58  DBUG("Create ThermoMechanicsProcess.");
59 
60  auto const coupling_scheme =
62  config.getConfigParameterOptional<std::string>("coupling_scheme");
63  const bool use_monolithic_scheme =
64  !(coupling_scheme && (*coupling_scheme == "staggered"));
65 
66  // Process variable.
67 
69  auto const pv_config = config.getConfigSubtree("process_variables");
70 
71  // Process IDs, which are set according to the appearance order of the
72  int heat_conduction_process_id = 0;
73  int mechanics_process_id = 0;
74 
75  ProcessVariable* variable_T;
76  ProcessVariable* variable_u;
77  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
78  process_variables;
79  if (use_monolithic_scheme) // monolithic scheme.
80  {
81  auto per_process_variables = findProcessVariables(
82  variables, pv_config,
83  {
84  "temperature",
86  "displacement"});
87  variable_T = &per_process_variables[0].get();
88  variable_u = &per_process_variables[1].get();
89  process_variables.push_back(std::move(per_process_variables));
90  }
91  else // staggered scheme.
92  {
93  using namespace std::string_literals;
94  for (auto const& variable_name : {"temperature"s, "displacement"s})
95  {
96  auto per_process_variables =
97  findProcessVariables(variables, pv_config, {variable_name});
98  process_variables.push_back(std::move(per_process_variables));
99  }
100  variable_T = &process_variables[0][0].get();
101  variable_u = &process_variables[1][0].get();
102  // process variables. Up to now, the ordering is fixed as:
103  heat_conduction_process_id = 0;
104  mechanics_process_id = 1;
105  }
106 
107  DBUG("Associate displacement with process variable '{:s}'.",
108  variable_u->getName());
109 
110  if (variable_u->getNumberOfGlobalComponents() != DisplacementDim)
111  {
112  OGS_FATAL(
113  "Number of components of the process variable '{:s}' is different "
114  "from the displacement dimension: got {:d}, expected {:d}",
115  variable_u->getName(),
116  variable_u->getNumberOfGlobalComponents(),
117  DisplacementDim);
118  }
119 
120  DBUG("Associate temperature with process variable '{:s}'.",
121  variable_T->getName());
122  if (variable_T->getNumberOfGlobalComponents() != 1)
123  {
124  OGS_FATAL(
125  "Pressure process variable '{:s}' is not a scalar variable but has "
126  "{:d} components.",
127  variable_T->getName(),
128  variable_T->getNumberOfGlobalComponents());
129  }
130 
132  config.peekConfigParameter<std::string>("constitutive_relation");
133  auto solid_constitutive_relations =
134  MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
135  parameters, local_coordinate_system, config);
136 
137  // Specific body force
138  Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
139  {
140  std::vector<double> const b =
142  config.getConfigParameter<std::vector<double>>(
143  "specific_body_force");
144  if (b.size() != DisplacementDim)
145  {
146  OGS_FATAL(
147  "The size of the specific body force vector does not match the "
148  "displacement dimension. Vector size is {:d}, displacement "
149  "dimension is {:d}",
150  b.size(), DisplacementDim);
151  }
152 
153  std::copy_n(b.data(), b.size(), specific_body_force.data());
154  }
155 
156  // Initial stress conditions
157  auto const initial_stress = ParameterLib::findOptionalTagParameter<double>(
159  config, "initial_stress", parameters,
160  // Symmetric tensor size, 4 or 6, not a Kelvin vector.
162  &mesh);
163 
164  auto media_map =
166  DBUG("Check the solid properties of ThermoMechanics process ...");
167  checkMPLProperties(media);
168  DBUG("Solid properties verified.");
169 
171  materialIDs(mesh),
172  std::move(media_map),
173  std::move(solid_constitutive_relations),
174  initial_stress,
175  specific_body_force,
176  mechanics_process_id,
177  heat_conduction_process_id};
178 
179  SecondaryVariableCollection secondary_variables;
180 
181  ProcessLib::createSecondaryVariables(config, secondary_variables);
182 
183  return std::make_unique<ThermoMechanicsProcess<DisplacementDim>>(
184  std::move(name), mesh, std::move(jacobian_assembler), parameters,
185  integration_order, std::move(process_variables),
186  std::move(process_data), std::move(secondary_variables),
187  use_monolithic_scheme);
188 }
189 
190 template std::unique_ptr<Process> createThermoMechanicsProcess<2>(
191  std::string name,
192  MeshLib::Mesh& mesh,
193  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
194  std::vector<ProcessVariable> const& variables,
195  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
196  std::optional<ParameterLib::CoordinateSystem> const&
197  local_coordinate_system,
198  unsigned const integration_order,
199  BaseLib::ConfigTree const& config,
200  std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
201 
202 template std::unique_ptr<Process> createThermoMechanicsProcess<3>(
203  std::string name,
204  MeshLib::Mesh& mesh,
205  std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
206  std::vector<ProcessVariable> const& variables,
207  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
208  std::optional<ParameterLib::CoordinateSystem> const&
209  local_coordinate_system,
210  unsigned const integration_order,
211  BaseLib::ConfigTree const& config,
212  std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
213 
214 } // namespace ThermoMechanics
215 } // namespace ProcessLib
#define OGS_FATAL(...)
Definition: Error.h:26
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:27
T peekConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, T const &value) const
std::optional< T > getConfigParameterOptional(std::string const &param) const
T getConfigParameter(std::string const &param) const
ConfigTree getConfigSubtree(std::string const &root) const
Definition: ConfigTree.cpp:146
std::string const & getName() const
int getNumberOfGlobalComponents() const
Returns the number of components of the process variable.
Handles configuration of several secondary variables from the project file.
std::unique_ptr< MaterialSpatialDistributionMap > createMaterialSpatialDistributionMap(std::map< int, std::shared_ptr< Medium >> const &media, MeshLib::Mesh const &mesh)
void checkRequiredProperties(Component const &c, Container const &required_properties)
Definition: Component.h:96
constexpr int kelvin_vector_dimensions(int const displacement_dim)
Kelvin vector dimensions for given displacement dimension.
Definition: KelvinVector.h:23
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition: Mesh.cpp:258
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, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium >> const &media)
void checkMPLProperties(std::map< int, std::shared_ptr< MaterialPropertyLib::Medium >> const &media)
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, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium >> const &media)
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, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium >> const &media)
std::vector< std::reference_wrapper< ProcessVariable > > findProcessVariables(std::vector< ProcessVariable > const &variables, BaseLib::ConfigTree const &pv_config, std::initializer_list< std::string > tags)
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables)