/home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/timestepping/boost_rk.hh Source File#

DiFfRG: /home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/timestepping/boost_rk.hh Source File
DiFfRG
Discretization Framework for functional Renormalization Group flows
boost_rk.hh
Go to the documentation of this file.
1#pragma once
2
3// external libraries
4#include <boost/numeric/odeint.hpp>
5#include <boost/numeric/odeint/external/eigen/eigen.hpp>
6
7// DiFfRG
15
16namespace DiFfRG
17{
18 template <int prec> struct stepperChoice {
19 static_assert(prec == 0 || prec == 1, "Only precisions 0 and 1 are supported!");
20
21 using error_stepper_type_0 = boost::numeric::odeint::runge_kutta_cash_karp54<Eigen::VectorXd>;
22 using error_stepper_type_1 = boost::numeric::odeint::runge_kutta_fehlberg78<Eigen::VectorXd>;
23
24 using value = std::conditional_t<prec == 0, error_stepper_type_0, error_stepper_type_1>;
25 };
26
36 template <typename VectorType, typename SparseMatrixType, uint dim, int prec>
37 class TimeStepperBoostRK_impl : public AbstractTimestepper<VectorType, SparseMatrixType, dim>
38 {
40
41 public:
42 using NumberType = typename Base::NumberType;
45
61
63
67 virtual void run(AbstractFlowingVariables<NumberType, VectorType> &initial_condition, const double t_start,
68 const double t_stop) override;
69
70 private:
71 void run(VectorType &initial_data, const double t_start, const double t_stop);
72 void run(BlockVectorType &initial_data, const double t_start, const double t_stop);
73 void run_vars(VectorType &initial_data, const double t_start, const double t_stop);
74 };
75
76 // ##############################################################################
77 // Application-facing spelling
78 // ##############################################################################
79 //
80 // The class above takes the linear algebra spelled out because it is compiled out of line: the
81 // set of valid arguments is closed by the explicit instantiations in src/. Applications name the
82 // assembler instead and let these aliases project it onto that fixed parameter list.
83 //
84 // The argument is anything exposing VectorType, SparseMatrixType and dim -- an Assembler, or a
85 // Discretization where the assembler type is not a single type (e.g. a test that runs one
86 // discretization against several models).
87
88 template <typename Assembler, int prec>
89 using TimeStepperBoostRK = TimeStepperBoostRK_impl<typename Assembler::VectorType,
90 typename Assembler::SparseMatrixType, Assembler::dim, prec>;
91
93 template <typename Assembler> using TimeStepperBoostRK54 = TimeStepperBoostRK<Assembler, 0>;
94
96 template <typename Assembler> using TimeStepperBoostRK78 = TimeStepperBoostRK<Assembler, 1>;
97} // namespace DiFfRG
Implement a simple interface to do all adaptivity tasks, i.e. solution transfer, reinit of dofHandler...
Definition abstract_adaptor.hh:11
This is the general assembler interface for any kind of discretization. An assembler is responsible f...
Definition abstract_assembler.hh:54
A class to set up initial data for whatever discretization we have chosen. Also used to switch/manage...
Definition abstract_data.hh:21
The abstract base class for all timestepping algorithms. It provides a standard constructor which pop...
Definition abstract_timestepper.hh:155
VectorType VectorType
Definition abstract_timestepper.hh:158
struct DiFfRG::AbstractTimestepper::ExplicitParameters expl
typename get_type::BlockVectorType< VectorType > BlockVectorType
Definition abstract_timestepper.hh:169
AbstractAssembler< VectorType, SparseMatrixType, dim > & assembler
Definition abstract_timestepper.hh:309
OutputSession_impl< dim, VectorType > & data_out
Definition abstract_timestepper.hh:310
AbstractAdaptor< VectorType > & adaptor
Definition abstract_timestepper.hh:311
typename get_type::NumberType< VectorType > NumberType
Definition abstract_timestepper.hh:159
const ConfigTree config
Definition abstract_timestepper.hh:307
struct DiFfRG::AbstractTimestepper::ImplicitParameters impl
double output_dt
Definition abstract_timestepper.hh:318
A hierarchical configuration tree, readable from JSON and TOML files.
Definition config_tree.hh:32
Definition output_session.hh:176
A class to perform time stepping using adaptive Boost Runge-Kutta methods. This stepper uses adaptive...
Definition boost_rk.hh:38
TimeStepperBoostRK_impl(const ConfigTree &config, AbstractAssembler< VectorType, SparseMatrixType, dim > &assembler, OutputSession_impl< dim, VectorType > &data_out)
Definition boost_rk.hh:50
void run_vars(VectorType &initial_data, const double t_start, const double t_stop)
typename get_type::InverseSparseMatrixType< SparseMatrixType > InverseSparseMatrixType
Definition boost_rk.hh:43
TimeStepperBoostRK_impl(const ConfigTree &config, AbstractAssembler< VectorType, SparseMatrixType, dim > &assembler, OutputSession_impl< dim, VectorType > &data_out, AbstractAdaptor< VectorType > &adaptor)
Definition boost_rk.hh:55
typename stepperChoice< prec >::value error_stepper_type
Definition boost_rk.hh:62
void run(VectorType &initial_data, const double t_start, const double t_stop)
virtual void run(AbstractFlowingVariables< NumberType, VectorType > &initial_condition, const double t_start, const double t_stop) override
Run the time stepping algorithm.
typename Base::NumberType NumberType
Definition boost_rk.hh:42
void run(BlockVectorType &initial_data, const double t_start, const double t_stop)
typename Base::BlockVectorType BlockVectorType
Definition boost_rk.hh:44
All compile-time knowledge about which linear algebra types DiFfRG uses.
typename internal::_InverseSparseMatrixType< SparseMatrixType >::value InverseSparseMatrixType
Definition linear_algebra.hh:158
Definition complex_math.hh:10
Definition boost_rk.hh:18
boost::numeric::odeint::runge_kutta_fehlberg78< Eigen::VectorXd > error_stepper_type_1
Definition boost_rk.hh:22
boost::numeric::odeint::runge_kutta_cash_karp54< Eigen::VectorXd > error_stepper_type_0
Definition boost_rk.hh:21
std::conditional_t< prec==0, error_stepper_type_0, error_stepper_type_1 > value
Definition boost_rk.hh:24