include/meltpooldg/time_integration/bdf_time_integration.hpp Source File

Developer Documentation: include/meltpooldg/time_integration/bdf_time_integration.hpp Source File
Developer Documentation
bdf_time_integration.hpp
Go to the documentation of this file.
1#pragma once
2
3
4
5#include <deal.II/lac/la_parallel_vector.h>
6
13
14#include <functional>
15#include <memory>
16#include <vector>
17
19{
21 inline static constexpr std::array<TimeIntegratorSchemes, 6> bdf_supported_schemes{
22 {TimeIntegratorSchemes::bdf_1,
23 TimeIntegratorSchemes::bdf_2,
24 TimeIntegratorSchemes::bdf_3,
25 TimeIntegratorSchemes::bdf_4,
26 TimeIntegratorSchemes::bdf_5,
27 TimeIntegratorSchemes::bdf_6}};
28
29 template <int dim, typename number>
30 class BDFIntegrator final : public TimeIntegratorBase<number>
31 {
32 public:
33 using VectorType = dealii::LinearAlgebra::distributed::Vector<number>;
34
36 std::function<void(number time_step, VectorType &src, const VectorType &dst)>;
37
38 using ResidualType = std::function<void(number time,
39 number time_step,
40 const VectorType &src,
41 VectorType &dst,
42 const VectorType &old_solution)>;
43
44 using DistributeConstraintsType = std::function<void(VectorType &dst)>;
45
62
71 explicit BDFIntegrator(
72 const TimeIntegratorData<number> &time_integrator_data,
73 const SolverFunctions &solver_functions,
74 Preconditioner<dim, VectorType, number> &&preconditioner_in =
76
81 unsigned int
82 required_solution_history_size() const override;
83
91 void
92 reinit(const VectorType &vector_template) override;
93
98 void
99 reinit(const SolutionHistory<VectorType> &solution_history) override;
100
113 void
114 perform_time_step(const number current_time,
115 const number time_step,
116 SolutionHistory<VectorType> &solution_history,
117 const std::function<void(number, number, VectorType &, const VectorType &)>
118 &stage_pre_processing,
119 const std::function<void(number, number, VectorType &, const VectorType &)>
120 &stage_post_processing) override;
121
122 private:
150
173
187
189 std::unique_ptr<NewtonRaphsonSolver<number, VectorType>> solver;
190
193
195 struct
196 {
198 number rhs;
200 std::vector<number> old_solutions;
202
205
208
210 unsigned n_steps_performed = 0;
211
217 void
219
228 void
229 set_up_bdf_parameters(const unsigned int bdf_scheme);
230 };
231} // namespace MeltPoolDG::TimeIntegration
Definition preconditioner_trilinos_wrapper.hpp:190
Definition preconditioner.hpp:42
Definition bdf_time_integration.hpp:31
number rhs
Prefactor for the right hand side f(y).
Definition bdf_time_integration.hpp:198
JacobianType compute_jacobian
Apply the Jacobian of the residual operator to a given vector.
Definition bdf_time_integration.hpp:172
struct MeltPoolDG::TimeIntegration::BDFIntegrator::@9 bdf_weights
BDF prefactors and weights.
void compute_weighted_old_solution_sum(SolutionHistory< VectorType > &solution_history)
Compute sum of old solutions weighted with the BDF prefactors bdf_weights.old_solutions .
Definition bdf_time_integration.cpp:161
bool preconditioner_update_flag
Boolean to indicate whether the preconditioner needs to be updated before the next solve.
Definition bdf_time_integration.hpp:207
std::vector< number > old_solutions
Weights for the old solutions y^{n}, y^{n-1}, ...
Definition bdf_time_integration.hpp:200
unsigned int required_solution_history_size() const override
Definition bdf_time_integration.cpp:31
void set_up_bdf_parameters(const unsigned int bdf_scheme)
Set the up bdf parameters object.
Definition bdf_time_integration.cpp:178
DistributeConstraintsType distribute_constraints
Definition bdf_time_integration.hpp:186
void reinit(const VectorType &vector_template) override
Definition bdf_time_integration.cpp:54
std::function< void(number time_step, VectorType &src, const VectorType &dst)> JacobianType
Definition bdf_time_integration.hpp:36
Preconditioner< dim, VectorType, number > preconditioner
Preconditioner for the linear solver used in each nonlinear iteration.
Definition bdf_time_integration.hpp:192
std::unique_ptr< NewtonRaphsonSolver< number, VectorType > > solver
Nonlinear solver.
Definition bdf_time_integration.hpp:189
unsigned n_steps_performed
Number of time steps already performed by the integrator.
Definition bdf_time_integration.hpp:210
VectorType summed_old_solution
Sum of old solution with prefactors from BDF method.
Definition bdf_time_integration.hpp:204
std::function< void(VectorType &dst)> DistributeConstraintsType
Definition bdf_time_integration.hpp:44
void perform_time_step(const number current_time, const number time_step, SolutionHistory< VectorType > &solution_history, const std::function< void(number, number, VectorType &, const VectorType &)> &stage_pre_processing, const std::function< void(number, number, VectorType &, const VectorType &)> &stage_post_processing) override
Definition bdf_time_integration.cpp:70
ResidualType compute_residual
Compute the negative residual for the implicit step of the time integrator.
Definition bdf_time_integration.hpp:149
std::function< void(number time, number time_step, const VectorType &src, VectorType &dst, const VectorType &old_solution)> ResidualType
Definition bdf_time_integration.hpp:42
dealii::LinearAlgebra::distributed::Vector< number > VectorType
Definition bdf_time_integration.hpp:33
Definition solution_history.hpp:21
Definition time_integrator_base.hpp:17
const TimeIntegratorData< number > time_integrator_data
Definition time_integrator_base.hpp:105
Class providing different low storage explicit Runge-Kutta schemes. The schemes implemented in this c...
Definition bdf_time_integration.hpp:19
static constexpr std::array< TimeIntegratorSchemes, 6 > bdf_supported_schemes
The time integrator schemes supported by the bdf time integrator.
Definition bdf_time_integration.hpp:21
DistributeConstraintsType distribute_constraints
Definition bdf_time_integration.hpp:60
JacobianType compute_jacobian
Function that applies the Jacobian of the residual operator to a given vector.
Definition bdf_time_integration.hpp:53
ResidualType compute_residual
Function that computes the negative residual for the implicit step of the time integrator.
Definition bdf_time_integration.hpp:56