include/meltpooldg/time_integration/implicit_explicit_integrator.hpp Source File

Developer Documentation: include/meltpooldg/time_integration/implicit_explicit_integrator.hpp Source File
Developer Documentation
implicit_explicit_integrator.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <deal.II/lac/la_parallel_vector.h>
4
10
11#include <functional>
12#include <optional>
13
15{
17 inline static constexpr std::array<TimeIntegratorSchemes, 1> imex_supported_schemes{
18 {TimeIntegratorSchemes::imex}};
19
20
21 template <unsigned int dim, typename number>
23 {
24 using VectorType = dealii::LinearAlgebra::distributed::Vector<number>;
25
27 std::function<void(number,
28 number,
29 VectorType &,
30 const VectorType &,
31 const bool,
32 const std::function<void(unsigned, unsigned)> &)>;
33
35 std::function<void(number time, number time_step, VectorType &dst, const VectorType &src)>;
36
37 using ResidualType = std::function<void(number time,
38 number time_step,
39 const VectorType &src,
40 VectorType &dst,
41 const VectorType &explicit_solution)>;
42
43 using DistributeConstraintsType = std::function<void(VectorType &dst)>;
44
45 using CustomSolverType = std::function<void(number time,
46 number time_step,
47 const VectorType &explicit_step_solution,
48 const VectorType &solution)>;
49
50 public:
58 explicit ImplicitExplicitIntegrator(const TimeIntegratorData<number> &time_integrator_data);
59
64 unsigned
65 required_solution_history_size() const override;
66
74 void
75 reinit(const VectorType &vector_template) override;
76
81 void
82 reinit(const SolutionHistory<VectorType> &solution_history) override;
83
93 void
95
108 void
110
126 void
128 JacobianType jacobian,
129 ResidualType residual,
130 DistributeConstraintsType constraints = [](VectorType &) {});
131
141 void
143
158 void
159 perform_time_step(const number current_time,
160 const number time_step,
161 SolutionHistory<VectorType> &solution_history,
162 const std::function<void(number, number, VectorType &, const VectorType &)>
163 &stage_pre_processing,
164 const std::function<void(number, number, VectorType &, const VectorType &)>
165 &stage_post_processing) override;
166
167 private:
202
227
243
281
311
314
316 std::optional<NewtonRaphsonSolver<number, VectorType>> solver;
317
320
323
325 unsigned n_steps_performed = 0;
326
331 void
332 apply_explicit_step(number time,
333 number time_step,
334 const VectorType &src,
335 VectorType &dst) const;
336
343 void
344 apply_implicit_step(number time,
345 number time_step,
346 VectorType &explicit_solution,
347 VectorType &solution);
348 };
349} // namespace MeltPoolDG::TimeIntegration
Definition preconditioner.hpp:42
Definition implicit_explicit_integrator.hpp:23
std::function< void(number time, number time_step, const VectorType &explicit_step_solution, const VectorType &solution)> CustomSolverType
Definition implicit_explicit_integrator.hpp:48
void apply_explicit_step(number time, number time_step, const VectorType &src, VectorType &dst) const
Definition implicit_explicit_integrator.cpp:132
unsigned required_solution_history_size() const override
Definition implicit_explicit_integrator.cpp:21
std::function< void(number, number, VectorType &, const VectorType &, const bool, const std::function< void(unsigned, unsigned)> &)> ExplicitRhsFunctionType
Definition implicit_explicit_integrator.hpp:32
ResidualType compute_residual
Compute the negative residual for the implicit step of the time integrator.
Definition implicit_explicit_integrator.hpp:201
void configure_implicit_step_wo_internal_nonlinear_solver(CustomSolverType custom_solver_in)
Definition implicit_explicit_integrator.cpp:53
std::function< void(number time, number time_step, const VectorType &src, VectorType &dst, const VectorType &explicit_solution)> ResidualType
Definition implicit_explicit_integrator.hpp:41
JacobianType compute_jacobian
Apply the Jacobian of the residual operator to a given vector.
Definition implicit_explicit_integrator.hpp:226
ExplicitRhsFunctionType explicit_compute_rhs
Definition implicit_explicit_integrator.hpp:310
CustomSolverType custom_solver
Definition implicit_explicit_integrator.hpp:280
void configure_implicit_step(JacobianType jacobian, ResidualType residual, DistributeConstraintsType constraints=[](VectorType &) {})
Configure the functions used by the internal nonlinear solver to solve the implicit step....
Definition implicit_explicit_integrator.cpp:61
void set_preconditioner(Preconditioner< dim, VectorType, number > &&preconditioner_in)
Definition implicit_explicit_integrator.cpp:85
void reinit(const VectorType &vector_template) override
Definition implicit_explicit_integrator.cpp:28
unsigned n_steps_performed
Number of time steps already performed by the integrator.
Definition implicit_explicit_integrator.hpp:325
bool preconditioner_update_flag
Boolean to indicate whether the preconditioner needs to be updated before the next solve.
Definition implicit_explicit_integrator.hpp:322
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 implicit_explicit_integrator.cpp:94
void apply_implicit_step(number time, number time_step, VectorType &explicit_solution, VectorType &solution)
Definition implicit_explicit_integrator.cpp:155
Preconditioner< dim, VectorType, number > preconditioner
Preconditioner for the linear solver used within each nonlinear solver iteration.
Definition implicit_explicit_integrator.hpp:319
void configure_explicit_step(ExplicitRhsFunctionType explicit_rhs)
Configure the function used to compute the explicit right-hand side.
Definition implicit_explicit_integrator.cpp:45
dealii::LinearAlgebra::distributed::Vector< number > VectorType
Definition implicit_explicit_integrator.hpp:24
std::function< void(number time, number time_step, VectorType &dst, const VectorType &src)> JacobianType
Definition implicit_explicit_integrator.hpp:35
DistributeConstraintsType distribute_constraints
Definition implicit_explicit_integrator.hpp:242
VectorType intermediate_explicit_solution
Vector to store the solution of the explicit step.
Definition implicit_explicit_integrator.hpp:313
std::optional< NewtonRaphsonSolver< number, VectorType > > solver
Nonlinear solver used when no custom solver is provided.
Definition implicit_explicit_integrator.hpp:316
std::function< void(VectorType &dst)> DistributeConstraintsType
Definition implicit_explicit_integrator.hpp:43
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:18
static constexpr std::array< TimeIntegratorSchemes, 1 > imex_supported_schemes
The time integrator schemes supported by the implicit-explicit time integrator.
Definition implicit_explicit_integrator.hpp:17