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>
54{
55 return false;
56}
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 mesh.isAxiallySymmetric(), integration_order, _process_data,
138 _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>
172 DisplacementDim>::initializeBoundaryConditions()
173{
174 // Staggered scheme:
175 // for the equations of temperature-deformation.
176 initializeProcessBoundaryConditionsAndSourceTerms(
177 getDOFTableByProcessID(_mechanics_related_process_id),
178 _mechanics_related_process_id);
179 // for the phase field
180 initializeProcessBoundaryConditionsAndSourceTerms(
181 getDOFTableByProcessID(_phase_field_process_id),
182 _phase_field_process_id);
183 // for heat conduction
184 initializeProcessBoundaryConditionsAndSourceTerms(
185 getDOFTableByProcessID(_heat_conduction_process_id),
186 _heat_conduction_process_id);
187}
188
189template <int DisplacementDim>
191 assembleConcreteProcess(const double t, double const dt,
192 std::vector<GlobalVector*> const& x,
193 std::vector<GlobalVector*> const& xdot,
194 int const process_id, GlobalMatrix& M,
196{
197 DBUG("Assemble the equations for ThermoMechanicalPhaseFieldProcess.");
198
199 std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
200 dof_table = {std::ref(*_local_to_global_index_map)};
201 ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
202
203 // Call global assembler for each local assembly item.
205 _global_assembler, &VectorMatrixAssembler::assemble, _local_assemblers,
206 pv.getActiveElementIDs(), dof_table, t, dt, x, xdot, process_id, M, K,
207 b);
208}
209
210template <int DisplacementDim>
212 assembleWithJacobianConcreteProcess(const double t, double const dt,
213 std::vector<GlobalVector*> const& x,
214 std::vector<GlobalVector*> const& xdot,
215 int const process_id, GlobalMatrix& M,
217 GlobalMatrix& Jac)
218{
219 std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
220 dof_tables;
221 // For the staggered scheme
222 if (process_id == _mechanics_related_process_id)
223 {
224 DBUG(
225 "Assemble the Jacobian equations of "
226 "temperature-deformation in ThermoMechanicalPhaseFieldProcess for "
227 "the staggered scheme.");
228 }
229
230 if (process_id == _phase_field_process_id)
231 {
232 DBUG(
233 "Assemble the Jacobian equations ofphase field in "
234 "ThermoMechanicalPhaseFieldProcess for the staggered scheme.");
235 }
236 else
237 {
238 DBUG(
239 "Assemble the Jacobian equations of heat conduction in "
240 "ThermoMechanicalPhaseFieldProcess for the staggered scheme.");
241 }
242 dof_tables.emplace_back(
243 getDOFTableByProcessID(_heat_conduction_process_id));
244 dof_tables.emplace_back(
245 getDOFTableByProcessID(_mechanics_related_process_id));
246 dof_tables.emplace_back(getDOFTableByProcessID(_phase_field_process_id));
247
248 ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
249
252 _local_assemblers, pv.getActiveElementIDs(), dof_tables, t, dt, x, xdot,
253 process_id, M, K, b, Jac);
254}
255
256template <int DisplacementDim>
258 preTimestepConcreteProcess(std::vector<GlobalVector*> const& x,
259 double const t,
260 double const dt,
261 const int process_id)
262{
263 DBUG("PreTimestep ThermoMechanicalPhaseFieldProcess.");
264
265 if (process_id != _mechanics_related_process_id)
266 {
267 return;
268 }
269
270 ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
271
274 _local_assemblers, pv.getActiveElementIDs(), getDOFTable(process_id),
275 *x[process_id], t, dt);
276}
277
278template <int DisplacementDim>
280 postTimestepConcreteProcess(std::vector<GlobalVector*> const& x,
281 double const t,
282 double const dt,
283 int const process_id)
284{
285 if (process_id != 0)
286 {
287 return;
288 }
289
290 DBUG("PostTimestep ThermoMechanicalPhaseFieldProcess.");
291 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
292 auto const n_processes = x.size();
293 dof_tables.reserve(n_processes);
294 for (std::size_t process_id = 0; process_id < n_processes; ++process_id)
295 {
296 dof_tables.push_back(&getDOFTable(process_id));
297 }
298
299 ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
302 _local_assemblers, pv.getActiveElementIDs(), dof_tables, x, t, dt);
303}
304
305template <int DisplacementDim>
308 GlobalVector const& xdot, const double t,
309 double const dt, const int process_id)
310{
311 if (process_id != _mechanics_related_process_id)
312 {
313 return;
314 }
315
316 DBUG("PostNonLinearSolver ThermoMechanicalPhaseFieldProcess.");
317 // Calculate strain, stress or other internal variables of mechanics.
318 const bool use_monolithic_scheme = false;
319 ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
320
323 pv.getActiveElementIDs(), getDOFTable(process_id), x, xdot, t, dt,
324 use_monolithic_scheme, process_id);
325}
326
329
330} // namespace ThermoMechanicalPhaseField
331} // namespace ProcessLib
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:29
Global vector based on Eigen vector.
Definition: EigenVector.h:28
bool isAxiallySymmetric() const
Definition: Mesh.h:131
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition: Mesh.h:103
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition: Mesh.h:76
virtual void postTimestep(std::size_t const mesh_item_id, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, std::vector< GlobalVector * > const &x, double const t, double const dt)
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)
void postNonLinearSolver(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const &dof_table, GlobalVector const &x, GlobalVector const &xdot, double const t, double const dt, bool const use_monolithic_scheme, int const process_id)
std::vector< std::size_t > const & getActiveElementIDs() const
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 assembleConcreteProcess(const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &xdot, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b) override
void postNonLinearSolverConcreteProcess(GlobalVector const &x, GlobalVector const &xdot, const double t, double const dt, int const process_id) override
void preTimestepConcreteProcess(std::vector< GlobalVector * > const &x, double const t, double const dt, const int process_id) override
void assembleWithJacobianConcreteProcess(const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &xdot, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b, GlobalMatrix &Jac) override
MathLib::MatrixSpecifications getMatrixSpecifications(const int process_id) const override
void postTimestepConcreteProcess(std::vector< GlobalVector * > const &x, double const t, double const dt, int const process_id) override
NumLib::LocalToGlobalIndexMap & getDOFTableByProcessID(const int process_id) const
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 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< std::reference_wrapper< NumLib::LocalToGlobalIndexMap > > const &dof_tables, double const t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &xdot, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b)
void assembleWithJacobian(std::size_t const mesh_item_id, LocalAssemblerInterface &local_assembler, std::vector< std::reference_wrapper< NumLib::LocalToGlobalIndexMap > > const &dof_tables, const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &xdot, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b, GlobalMatrix &Jac)
Eigen::Matrix< double, kelvin_vector_dimensions(DisplacementDim), 1, Eigen::ColMajor > KelvinVectorType
Definition: KelvinVector.h:48
static const double t
@ 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, 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