include/meltpooldg/time_integration/time_integrator_util.hpp Source File

Developer Documentation: include/meltpooldg/time_integration/time_integrator_util.hpp Source File
Developer Documentation
time_integrator_util.hpp
Go to the documentation of this file.
1
2#pragma once
3
14
16
17#include <functional>
18
20{
29 inline bool
30 time_integrator_scheme_is_explicit(const TimeIntegratorSchemes scheme)
31 {
33 return true;
35 return true;
36 return false;
37 }
38
47 inline bool
48 time_integrator_scheme_is_implicit(const TimeIntegratorSchemes scheme)
49 {
51 return true;
52 return false;
53 }
54
67 template <typename number, typename PDEOperator>
68 TimeIntegratorBase<number> *
69 explicit_time_integrator_factory(const PDEOperator &pde_operator,
70 const TimeIntegratorData<number> &params)
71 {
72 if (Utils::contains(explicit_lsrk_supported_schemes, params.integrator_type))
73 {
75 params, std::bind_front(&PDEOperator::apply_operator, &pde_operator));
76 return integrator;
77 }
78 else if (Utils::contains(explicit_rkc_supported_schemes, params.integrator_type))
79 {
81 params, std::bind_front(&PDEOperator::apply_operator, &pde_operator));
82 return integrator;
83 }
84 return nullptr;
85 }
86
101 template <int dim, typename number, typename PDEOperator>
102 TimeIntegratorBase<number> *
103 implicit_time_integrator_factory(const PDEOperator &pde_operator,
104 const ScratchData<dim, dim, number> &scratch_data,
105 const unsigned int dof_idx,
106 const TimeIntegratorData<number> &params)
107 {
108 using VectorType = typename BDFIntegrator<dim, number>::VectorType;
109
110 if (Utils::contains(bdf_supported_schemes, params.integrator_type))
111 {
112 auto preconditioner = make_preconditioner<dim, number, PDEOperator, VectorType>(
113 params.linear_solver_data.preconditioner_type,
114 &pde_operator,
115 scratch_data,
116 dof_idx,
117 true);
118
120 bdf_solver_functions{.compute_jacobian =
121 std::bind_front(&PDEOperator::apply_jacobian, &pde_operator),
122 .compute_residual =
123 std::bind_front(&PDEOperator::compute_residual, &pde_operator),
124 .distribute_constraints = std::function<void(VectorType &)>()};
125
126 auto integrator =
127 new BDFIntegrator<dim, number>(params, bdf_solver_functions, std::move(preconditioner));
128 return integrator;
129 }
130 return nullptr;
131 }
132
133
148 template <typename number,
149 typename PDEOperator,
150 typename VectorType = dealii::LinearAlgebra::distributed::Vector<number>>
151 TimeIntegratorBase<number> *
152 time_integrator_factory(const PDEOperator &pde_operator,
153 const TimeIntegratorData<number> &params,
154 const LinearSolverData<number> &linear_solver_data,
155 dealii::TimerOutput &)
156 {
157 if (Utils::contains(explicit_lsrk_supported_schemes, params.integrator_type))
158 {
160 params,
161 [&pde_operator](number time,
162 number,
163 dealii::LinearAlgebra::distributed::Vector<number> &dst,
164 const dealii::LinearAlgebra::distributed::Vector<number> &src,
165 std::function<void(unsigned, unsigned)> post) {
166 pde_operator.apply_operator(time, dst, src, post);
167 });
168 return integrator;
169 }
170 else if (Utils::contains(explicit_rkc_supported_schemes, params.integrator_type))
171 {
173 params,
174 [&pde_operator](number time,
175 number,
176 dealii::LinearAlgebra::distributed::Vector<number> &dst,
177 const dealii::LinearAlgebra::distributed::Vector<number> &src,
178 std::function<void(unsigned, unsigned)> post) {
179 pde_operator.apply_operator(time, dst, src, post);
180 });
181 return integrator;
182 }
183 if (Utils::contains(one_step_theta_supported_schemes, params.integrator_type))
184 return new OneStepTheta<number, PDEOperator>(pde_operator, params, linear_solver_data);
185 DEAL_II_NOT_IMPLEMENTED();
186 }
187} // namespace MeltPoolDG::TimeIntegration
Container for shared scratch data between operations/operators.
Definition scratch_data.hpp:61
Definition bdf_time_integration.hpp:31
dealii::LinearAlgebra::distributed::Vector< number > VectorType
Definition bdf_time_integration.hpp:33
Definition explicit_runge_kutta_chebyshev_integrator.hpp:29
Definition explicit_low_storage_runge_kutta_integrator.hpp:33
Definition one_step_theta.hpp:27
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
static constexpr std::array< TimeIntegratorSchemes, 3 > one_step_theta_supported_schemes
Definition one_step_theta.hpp:20
static constexpr std::array< TimeIntegratorSchemes, 1 > explicit_rkc_supported_schemes
The number of stages does not need to be split into different schemes.
Definition explicit_runge_kutta_chebyshev_integrator.hpp:23
TimeIntegratorBase< number > * time_integrator_factory(const PDEOperator &pde_operator, const TimeIntegratorData< number > &params, const LinearSolverData< number > &linear_solver_data, dealii::TimerOutput &)
Definition time_integrator_util.hpp:152
bool time_integrator_scheme_is_explicit(const TimeIntegratorSchemes scheme)
Definition time_integrator_util.hpp:30
TimeIntegratorBase< number > * implicit_time_integrator_factory(const PDEOperator &pde_operator, const ScratchData< dim, dim, number > &scratch_data, const unsigned int dof_idx, const TimeIntegratorData< number > &params)
Definition time_integrator_util.hpp:103
bool time_integrator_scheme_is_implicit(const TimeIntegratorSchemes scheme)
Definition time_integrator_util.hpp:48
TimeIntegratorBase< number > * explicit_time_integrator_factory(const PDEOperator &pde_operator, const TimeIntegratorData< number > &params)
Definition time_integrator_util.hpp:69
static constexpr std::array< TimeIntegratorSchemes, 5 > explicit_lsrk_supported_schemes
The time integrator schemes supported by the low storage explicit Runge-Kutta time integrator.
Definition explicit_low_storage_runge_kutta_integrator.hpp:23
bool contains(const Container &c, typename Container::value_type const value)
Definition cpp23_functions.h:26
JacobianType compute_jacobian
Function that applies the Jacobian of the residual operator to a given vector.
Definition bdf_time_integration.hpp:53