OGS
ThermoMechanicalPhaseFieldProcess.cpp
Go to the documentation of this file.
1
12
13#include <cassert>
14
16#include "ProcessLib/Process.h"
20
21namespace ProcessLib
22{
23namespace ThermoMechanicalPhaseField
24{
25template <int DisplacementDim>
28 std::string name,
29 MeshLib::Mesh& mesh,
30 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&&
31 jacobian_assembler,
32 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const&
33 parameters,
34 unsigned const integration_order,
35 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
36 process_variables,
38 SecondaryVariableCollection&& secondary_variables,
39 int const mechanics_related_process_id,
40 int const phase_field_process_id,
41 int const heat_conduction_process_id)
42 : Process(std::move(name), mesh, std::move(jacobian_assembler), parameters,
43 integration_order, std::move(process_variables),
44 std::move(secondary_variables), false),
45 _process_data(std::move(process_data)),
46 _mechanics_related_process_id(mechanics_related_process_id),
47 _phase_field_process_id(phase_field_process_id),
48 _heat_conduction_process_id(heat_conduction_process_id)
49{
50}
51
52template <int DisplacementDim>
57
58template <int DisplacementDim>
61 const int process_id) const
62{
63 if (process_id == _mechanics_related_process_id)
64 {
65 auto const& l = *_local_to_global_index_map;
66 return {l.dofSizeWithoutGhosts(), l.dofSizeWithoutGhosts(),
67 &l.getGhostIndices(), &this->_sparsity_pattern};
68 }
69
70 // For staggered scheme and phase field process or heat conduction.
71 auto const& l = *_local_to_global_index_map_single_component;
72 return {l.dofSizeWithoutGhosts(), l.dofSizeWithoutGhosts(),
73 &l.getGhostIndices(), &_sparsity_pattern_with_single_component};
74}
75
76template <int DisplacementDim>
79 const int process_id) const
80{
81 if (process_id == _mechanics_related_process_id)
82 {
83 return *_local_to_global_index_map;
84 }
85
86 // For the equation of phasefield or heat conduction.
87 return *_local_to_global_index_map_single_component;
88}
89
90template <int DisplacementDim>
93 const int process_id) const
94{
95 if (process_id == _mechanics_related_process_id)
96 {
97 return *_local_to_global_index_map;
98 }
99
100 // For the equation of phasefield or heat conduction.
101 return *_local_to_global_index_map_single_component;
102}
103
104template <int DisplacementDim>
106{
107 // For displacement equation.
108 constructDofTableOfSpecifiedProcessStaggeredScheme(
109 _mechanics_related_process_id);
110
111 // TODO move the two data members somewhere else.
112 // for extrapolation of secondary variables of stress or strain
113 std::vector<MeshLib::MeshSubset> all_mesh_subsets_single_component{
114 *_mesh_subset_all_nodes};
115 _local_to_global_index_map_single_component =
116 std::make_unique<NumLib::LocalToGlobalIndexMap>(
117 std::move(all_mesh_subsets_single_component),
118 // by location order is needed for output
120
121 assert(_local_to_global_index_map_single_component);
122
123 // For phase field equation or the heat conduction.
124 _sparsity_pattern_with_single_component = NumLib::computeSparsityPattern(
125 *_local_to_global_index_map_single_component, _mesh);
126}
127
128template <int DisplacementDim>
131 MeshLib::Mesh const& mesh,
132 unsigned const integration_order)
133{
136 mesh.getElements(), dof_table, _local_assemblers,
137 NumLib::IntegrationOrder{integration_order}, mesh.isAxiallySymmetric(),
138 _process_data, _mechanics_related_process_id, _phase_field_process_id,
139 _heat_conduction_process_id);
140
141 _secondary_variables.addSecondaryVariable(
142 "sigma",
145 DisplacementDim>::RowsAtCompileTime,
146 getExtrapolator(), _local_assemblers,
148
149 _secondary_variables.addSecondaryVariable(
150 "epsilon",
152 DisplacementDim>::RowsAtCompileTime,
153 getExtrapolator(), _local_assemblers,
155 getIntPtEpsilon));
156
157 _secondary_variables.addSecondaryVariable(
158 "heat_flux",
159 makeExtrapolator(mesh.getDimension(), getExtrapolator(),
160 _local_assemblers,
162 getIntPtHeatFlux));
163
164 // Initialize local assemblers after all variables have been set.
166 &LocalAssemblerInterface::initialize, _local_assemblers,
167 *_local_to_global_index_map);
168}
169
170template <int DisplacementDim>
173 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const&
174 media)
175{
176 // Staggered scheme:
177 // for the equations of temperature-deformation.
178 initializeProcessBoundaryConditionsAndSourceTerms(
179 getDOFTableByProcessID(_mechanics_related_process_id),
180 _mechanics_related_process_id, media);
181 // for the phase field
182 initializeProcessBoundaryConditionsAndSourceTerms(
183 getDOFTableByProcessID(_phase_field_process_id),
184 _phase_field_process_id, media);
185 // for heat conduction
186 initializeProcessBoundaryConditionsAndSourceTerms(
187 getDOFTableByProcessID(_heat_conduction_process_id),
188 _heat_conduction_process_id, media);
189}
190
191template <int DisplacementDim>
193 assembleConcreteProcess(const double t, double const dt,
194 std::vector<GlobalVector*> const& x,
195 std::vector<GlobalVector*> const& x_prev,
196 int const process_id, GlobalMatrix& M,
198{
199 DBUG("Assemble the equations for ThermoMechanicalPhaseFieldProcess.");
200
201 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
202 _local_to_global_index_map.get()};
203
204 // Call global assembler for each local assembly item.
206 _global_assembler, &VectorMatrixAssembler::assemble, _local_assemblers,
207 getActiveElementIDs(), dof_table, t, dt, x, x_prev, process_id, &M, &K,
208 &b);
209}
210
211template <int DisplacementDim>
214 const double t, double const dt, std::vector<GlobalVector*> const& x,
215 std::vector<GlobalVector*> const& x_prev, int const process_id,
216 GlobalVector& b, GlobalMatrix& Jac)
217{
218 // For the staggered scheme
219 if (process_id == _mechanics_related_process_id)
220 {
221 DBUG(
222 "Assemble the Jacobian equations of "
223 "temperature-deformation in ThermoMechanicalPhaseFieldProcess for "
224 "the staggered scheme.");
225 }
226
227 if (process_id == _phase_field_process_id)
228 {
229 DBUG(
230 "Assemble the Jacobian equations ofphase field in "
231 "ThermoMechanicalPhaseFieldProcess for the staggered scheme.");
232 }
233 else
234 {
235 DBUG(
236 "Assemble the Jacobian equations of heat conduction in "
237 "ThermoMechanicalPhaseFieldProcess for the staggered scheme.");
238 }
239
240 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
241 dof_tables.emplace_back(
242 &getDOFTableByProcessID(_heat_conduction_process_id));
243 dof_tables.emplace_back(
244 &getDOFTableByProcessID(_mechanics_related_process_id));
245 dof_tables.emplace_back(&getDOFTableByProcessID(_phase_field_process_id));
246
249 _local_assemblers, getActiveElementIDs(), dof_tables, t, dt, x, x_prev,
250 process_id, &b, &Jac);
251}
252
253template <int DisplacementDim>
255 preTimestepConcreteProcess(std::vector<GlobalVector*> const& x,
256 double const t,
257 double const dt,
258 const int process_id)
259{
260 DBUG("PreTimestep ThermoMechanicalPhaseFieldProcess.");
261
262 if (process_id != _mechanics_related_process_id)
263 {
264 return;
265 }
266
269 _local_assemblers, getActiveElementIDs(), getDOFTable(process_id),
270 *x[process_id], t, dt);
271}
272
273template <int DisplacementDim>
275 postTimestepConcreteProcess(std::vector<GlobalVector*> const& x,
276 std::vector<GlobalVector*> const& x_prev,
277 double const t,
278 double const dt,
279 int const process_id)
280{
281 if (process_id != 0)
282 {
283 return;
284 }
285
286 DBUG("PostTimestep ThermoMechanicalPhaseFieldProcess.");
287
290 _local_assemblers, getActiveElementIDs(), getDOFTables(x.size()), x,
291 x_prev, t, dt, process_id);
292}
293
294template <int DisplacementDim>
296 postNonLinearSolverConcreteProcess(std::vector<GlobalVector*> const& x,
297 std::vector<GlobalVector*> const& x_prev,
298 const double t, double const dt,
299 const int process_id)
300{
301 if (process_id != _mechanics_related_process_id)
302 {
303 return;
304 }
305
306 DBUG("PostNonLinearSolver ThermoMechanicalPhaseFieldProcess.");
307 // Calculate strain, stress or other internal variables of mechanics.
308
311 getActiveElementIDs(), getDOFTables(x.size()), x, x_prev, t, dt,
312 process_id);
313}
314
317
318} // namespace ThermoMechanicalPhaseField
319} // namespace ProcessLib
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
Global vector based on Eigen vector.
Definition EigenVector.h:25
bool isAxiallySymmetric() const
Definition Mesh.h:137
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:109
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition Mesh.h:88
void postNonLinearSolver(std::size_t const mesh_item_id, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, double const t, double const dt, int const process_id)
virtual void postTimestep(std::size_t const mesh_item_id, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, double const t, double const dt, int const process_id)
virtual void preTimestep(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const &dof_table, GlobalVector const &x, double const t, double const delta_t)
virtual void initialize(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const &dof_table)
Handles configuration of several secondary variables from the project file.
A class to simulate thermo-mechanical fracturing process using phase-field approach in solids describ...
NumLib::LocalToGlobalIndexMap const & getDOFTable(const int process_id) const override
void assembleWithJacobianConcreteProcess(const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id, GlobalVector &b, GlobalMatrix &Jac) override
void preTimestepConcreteProcess(std::vector< GlobalVector * > const &x, double const t, double const dt, const int process_id) override
void assembleConcreteProcess(const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b) override
MathLib::MatrixSpecifications getMatrixSpecifications(const int process_id) const override
NumLib::LocalToGlobalIndexMap & getDOFTableByProcessID(const int process_id) const
void postNonLinearSolverConcreteProcess(std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, const double t, double const dt, int const process_id) override
void initializeBoundaryConditions(std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media) override
ThermoMechanicalPhaseFieldProcess(std::string name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > &&process_variables, ThermoMechanicalPhaseFieldProcessData< DisplacementDim > &&process_data, SecondaryVariableCollection &&secondary_variables, int const mechanics_related_process_id, int const phase_field_process_id, int const heat_conduction_process_id)
void postTimestepConcreteProcess(std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, double const t, double const dt, int const process_id) override
void initializeConcreteProcess(NumLib::LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh, unsigned const integration_order) override
Process specific initialization called by initialize().
void assemble(std::size_t const mesh_item_id, LocalAssemblerInterface &local_assembler, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, double const t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id, GlobalMatrix *M, GlobalMatrix *K, GlobalVector *b)
void assembleWithJacobian(std::size_t const mesh_item_id, LocalAssemblerInterface &local_assembler, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id, GlobalVector *b, GlobalMatrix *Jac)
Eigen::Matrix< double, kelvin_vector_dimensions(DisplacementDim), 1, Eigen::ColMajor > KelvinVectorType
@ BY_LOCATION
Ordering data by spatial location.
GlobalSparsityPattern computeSparsityPattern(LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh)
Computes a sparsity pattern for the given inputs.
void createLocalAssemblers(std::vector< MeshLib::Element * > const &mesh_elements, NumLib::LocalToGlobalIndexMap const &dof_table, std::vector< std::unique_ptr< LocalAssemblerInterface > > &local_assemblers, ProviderOrOrder const &provider_or_order, ExtraCtorArgs &&... extra_ctor_args)
SecondaryVariableFunctions makeExtrapolator(const unsigned num_components, NumLib::Extrapolator &extrapolator, LocalAssemblerCollection const &local_assemblers, typename NumLib::ExtrapolatableLocalAssemblerCollection< LocalAssemblerCollection >::IntegrationPointValuesMethod integration_point_values_method)
static void executeSelectedMemberOnDereferenced(Method method, Container const &container, std::vector< std::size_t > const &active_container_ids, Args &&... args)
static void executeSelectedMemberDereferenced(Object &object, Method method, Container const &container, std::vector< std::size_t > const &active_container_ids, Args &&... args)
static void executeMemberOnDereferenced(Method method, Container const &container, Args &&... args)
virtual std::vector< double > const & getIntPtSigma(const double t, std::vector< GlobalVector * > const &x, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_table, std::vector< double > &cache) const =0