OGS
CreateThermoMechanicsProcess.cpp
Go to the documentation of this file.
1
12
13#include <cassert>
14
20#include "ParameterLib/Utils.h"
25
26namespace ProcessLib
27{
28namespace 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
45template <int DisplacementDim>
46std::unique_ptr<Process> createThermoMechanicsProcess(
47 std::string const& 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
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 {
83 auto per_process_variables = findProcessVariables(
84 variables, pv_config,
85 {
86 "temperature",
88 "displacement"});
89 variable_T = &per_process_variables[0].get();
90 variable_u = &per_process_variables[1].get();
91 process_variables.push_back(std::move(per_process_variables));
92 }
93 else // staggered scheme.
94 {
95 using namespace std::string_literals;
96 for (auto const& variable_name : {"temperature"s, "displacement"s})
97 {
98 auto per_process_variables =
99 findProcessVariables(variables, pv_config, {variable_name});
100 process_variables.push_back(std::move(per_process_variables));
101 }
102 variable_T = &process_variables[0][0].get();
103 variable_u = &process_variables[1][0].get();
104 // process variables. Up to now, the ordering is fixed as:
105 heat_conduction_process_id = 0;
106 mechanics_process_id = 1;
107 }
108
109 DBUG("Associate displacement with process variable '{:s}'.",
110 variable_u->getName());
111
112 if (variable_u->getNumberOfGlobalComponents() != DisplacementDim)
113 {
114 OGS_FATAL(
115 "Number of components of the process variable '{:s}' is different "
116 "from the displacement dimension: got {:d}, expected {:d}",
117 variable_u->getName(),
118 variable_u->getNumberOfGlobalComponents(),
119 DisplacementDim);
120 }
121
122 DBUG("Associate temperature with process variable '{:s}'.",
123 variable_T->getName());
124 if (variable_T->getNumberOfGlobalComponents() != 1)
125 {
126 OGS_FATAL(
127 "Pressure process variable '{:s}' is not a scalar variable but has "
128 "{:d} components.",
129 variable_T->getName(),
130 variable_T->getNumberOfGlobalComponents());
131 }
132
135 config.peekConfigParameter<std::string>("constitutive_relation");
136 auto solid_constitutive_relations =
137 MaterialLib::Solids::createConstitutiveRelations<DisplacementDim>(
138 parameters, local_coordinate_system, materialIDs(mesh), config);
139
140 // Specific body force
141 Eigen::Matrix<double, DisplacementDim, 1> specific_body_force;
142 {
143 std::vector<double> const b =
145 config.getConfigParameter<std::vector<double>>(
146 "specific_body_force");
147 if (b.size() != DisplacementDim)
148 {
149 OGS_FATAL(
150 "The size of the specific body force vector does not match the "
151 "displacement dimension. Vector size is {:d}, displacement "
152 "dimension is {:d}",
153 b.size(), DisplacementDim);
154 }
155
156 std::copy_n(b.data(), b.size(), specific_body_force.data());
157 }
158
159 // Initial stress conditions
160 auto const initial_stress = ParameterLib::findOptionalTagParameter<double>(
162 config, "initial_stress", parameters,
163 // Symmetric tensor size, 4 or 6, not a Kelvin vector.
165 &mesh);
166
167 auto media_map =
169 DBUG("Check the solid properties of ThermoMechanics process ...");
170 checkMPLProperties(media);
171 DBUG("Solid properties verified.");
172
174 materialIDs(mesh),
175 std::move(media_map),
176 std::move(solid_constitutive_relations),
177 initial_stress,
178 specific_body_force,
179 mechanics_process_id,
180 heat_conduction_process_id};
181
182 SecondaryVariableCollection secondary_variables;
183
184 ProcessLib::createSecondaryVariables(config, secondary_variables);
185
186 return std::make_unique<ThermoMechanicsProcess<DisplacementDim>>(
187 std::move(name), mesh, std::move(jacobian_assembler), parameters,
188 integration_order, std::move(process_variables),
189 std::move(process_data), std::move(secondary_variables),
190 use_monolithic_scheme);
191}
192
193template std::unique_ptr<Process> createThermoMechanicsProcess<2>(
194 std::string const& name,
195 MeshLib::Mesh& mesh,
196 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
197 std::vector<ProcessVariable> const& variables,
198 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
199 std::optional<ParameterLib::CoordinateSystem> const&
200 local_coordinate_system,
201 unsigned const integration_order,
202 BaseLib::ConfigTree const& config,
203 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
204
205template std::unique_ptr<Process> createThermoMechanicsProcess<3>(
206 std::string const& name,
207 MeshLib::Mesh& mesh,
208 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
209 std::vector<ProcessVariable> const& variables,
210 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
211 std::optional<ParameterLib::CoordinateSystem> const&
212 local_coordinate_system,
213 unsigned const integration_order,
214 BaseLib::ConfigTree const& config,
215 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media);
216
217} // namespace ThermoMechanics
218} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:26
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
T peekConfigParameter(std::string const &param) const
std::optional< T > getConfigParameterOptional(std::string const &param) const
T getConfigParameter(std::string const &param) const
ConfigTree getConfigSubtree(std::string const &root) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
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.
MaterialSpatialDistributionMap createMaterialSpatialDistributionMap(std::map< int, std::shared_ptr< Medium > > const &media, MeshLib::Mesh const &mesh)
constexpr int kelvin_vector_dimensions(int const displacement_dim)
Kelvin vector dimensions for given displacement dimension.
template std::unique_ptr< Process > createThermoMechanicsProcess< 3 >(std::string const &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::unique_ptr< Process > createThermoMechanicsProcess(std::string const &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)
template std::unique_ptr< Process > createThermoMechanicsProcess< 2 >(std::string const &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)