26template<
class ContainerType>
27struct FilteredExplicitMultistep;
58template<
class ContainerType>
68 template<
class ...Params>
75 const ContainerType&
copyable()
const{
return m_fem.copyable();}
89 template<
class ExplicitRHS>
92 m_fem.init( std::tie(rhs,
id), t0, u0, dt);
106 template<
class ExplicitRHS>
109 m_fem.step( std::tie(rhs,
id), t, u);
154template<
class ContainerType>
175 for(
unsigned i=0; i<m_t.
steps(); i++ )
177 if( m_t.
im( i+1) != 0 )
187 template<
class ...Params>
194 const ContainerType&
copyable()
const{
return m_tmp;}
213 template<
class ExplicitRHS,
class ImplicitRHS,
class Solver>
214 void init(
const std::tuple<ExplicitRHS, ImplicitRHS, Solver>& ode,
238 template<
class ExplicitRHS,
class ImplicitRHS,
class Solver>
239 void step(
const std::tuple<ExplicitRHS, ImplicitRHS, Solver>& ode,
244 std::vector<ContainerType> m_u, m_ex, m_im;
251template<
class ContainerType>
252template<
class RHS,
class Diffusion,
class Solver>
255 m_tu = t0, m_dt = dt;
256 unsigned s = m_t.steps();
259 if( s-1-m_counter < m_im.size())
260 std::get<1>(ode)( m_tu, m_u[s-1-m_counter], m_im[s-1-m_counter]);
261 std::get<0>(ode)( t0, u0, m_ex[s-1]);
264template<
class ContainerType>
265template<
class RHS,
class Diffusion,
class Solver>
268 unsigned s = m_t.steps();
269 if( m_counter < s - 1)
271 std::map<unsigned, std::string> order2method{
280 ARKStep<ContainerType> ark( order2method.at( m_t.order()), u);
281 ContainerType tmp ( u);
282 ark.step( ode, t, u, t, u, m_dt, tmp);
286 if( s-1-m_counter < m_im.size())
287 std::get<1>(ode)( m_tu, m_u[s-1-m_counter], m_im[s-1-m_counter]);
288 std::get<0>(ode)( m_tu, m_u[s-1-m_counter], m_ex[s-1-m_counter]);
293 for (
unsigned i = 1; i < s; i++)
295 for (
unsigned i = 0; i < m_im.size(); i++)
297 t = m_tu = m_tu + m_dt;
300 std::rotate( m_u.rbegin(), m_u.rbegin() + 1, m_u.rend());
301 std::rotate( m_ex.rbegin(), m_ex.rbegin() + 1, m_ex.rend());
303 std::rotate( m_im.rbegin(), m_im.rbegin() + 1, m_im.rend());
305 value_type alpha = m_dt*m_t.im(0);
306 std::get<2>(ode)( alpha, t, u, m_tmp);
311 std::get<0>(ode)(m_tu, m_u[0], m_ex[0]);
344template<
class ContainerType>
361 ContainerType&
copyable): m_t( tableau)
364 for(
unsigned i=0; i<m_t.
steps(); i++ )
366 if( m_t.
im( i+1) != 0 )
376 template<
class ...Params>
383 const ContainerType&
copyable()
const{
return m_tmp;}
402 template<
class ImplicitRHS,
class Solver>
424 template<
class ImplicitRHS,
class Solver>
429 std::vector<ContainerType> m_u;
430 std::vector<ContainerType> m_f;
432 unsigned m_counter = 0;
435template<
class ContainerType>
436template<
class ImplicitRHS,
class Solver>
438 value_type t0,
const ContainerType& u0, value_type dt)
440 m_tu = t0, m_dt = dt;
444 unsigned s = m_t.steps();
445 if( s-1-m_counter < m_f.size())
446 std::get<0>(ode)( m_tu, m_u[s-1-m_counter], m_f[s-1-m_counter]);
449template<
class ContainerType>
450template<
class ImplicitRHS,
class Solver>
452 value_type& t, container_type& u)
454 unsigned s = m_t.steps();
455 if( m_counter < s - 1)
457 std::map<unsigned, enum tableau_identifier> order2method{
466 ImplicitRungeKutta<ContainerType> dirk(
467 order2method.at(m_t.order()), u);
468 dirk.step( ode, t, u, t, u, m_dt);
473 if( s-1-m_counter < m_f.size())
474 std::get<0>(ode)( m_tu, m_u[s-1-m_counter], m_f[s-1-m_counter]);
479 for (
unsigned i = 1; i < s; i++)
481 for (
unsigned i = 0; i < m_f.size(); i++)
483 t = m_tu = m_tu + m_dt;
486 std::rotate(m_u.rbegin(), m_u.rbegin() + 1, m_u.rend());
488 std::rotate(m_f.rbegin(), m_f.rbegin() + 1, m_f.rend());
489 value_type alpha = m_dt*m_t.im(0);
490 std::get<1>(ode)( alpha, t, u, m_tmp);
513template<
class ContainerType>
531 const ContainerType&
copyable): m_t(tableau)
538 template<
class ...Params>
545 const ContainerType&
copyable()
const{
return m_u[0];}
562 template<
class ExplicitRHS,
class Limiter>
580 template<
class ExplicitRHS,
class Limiter>
581 void step(
const std::tuple<ExplicitRHS, Limiter>& ode,
value_type& t, ContainerType& u);
585 std::vector<ContainerType> m_u, m_f;
590template<
class ContainerType>
591template<
class ExplicitRHS,
class Limiter>
594 m_tu = t0, m_dt = dt;
595 unsigned s = m_t.steps();
597 std::get<1>(ode)( m_u[s-1]);
598 std::get<0>(ode)(m_tu, m_u[s-1], m_f[s-1]);
602template<
class ContainerType>
603template<
class ExplicitRHS,
class Limiter>
606 unsigned s = m_t.steps();
609 std::map<unsigned, enum tableau_identifier> order2method{
618 ShuOsher<ContainerType> rk( order2method.at(m_t.order()), u);
619 rk.step( ode, t, u, t, u, m_dt);
623 std::get<0>(ode)( m_tu, m_u[s-1-m_counter], m_f[s-1-m_counter]);
627 t = m_tu = m_tu + m_dt;
629 for (
unsigned i = 1; i < s; i++){
633 std::get<1>(ode)( u);
635 std::rotate( m_f.rbegin(), m_f.rbegin()+1, m_f.rend());
636 std::rotate( m_u.rbegin(), m_u.rbegin()+1, m_u.rend());
638 std::get<0>(ode)(m_tu, m_u[0], m_f[0]);
661template<
class ContainerType>
676 step,
value_type dt ) : m_step(step), m_dt(dt){}
696 template<
class Stepper,
class ODE>
698 Stepper&& stepper, ODE&& ode,
value_type t0,
const
701 stepper.init( ode, t0, u0, dt);
702 m_step = [=, cap = std::tuple<Stepper, ODE>(std::forward<Stepper>(stepper),
703 std::forward<ODE>(ode)) ](
auto& t,
auto&
y)
mutable
705 std::get<0>(cap).step( std::get<1>(cap), t,
y);
711 template<
class ...Params>
723 std::function<void (
value_type&, ContainerType&)> m_step;
724 virtual value_type do_dt( )
const {
return m_dt;}
729template<
class ContainerType>
730void MultistepTimeloop<ContainerType>::do_integrate(
731 value_type& t_begin,
const ContainerType&
732 begin, value_type t_end, ContainerType& end,
735 bool forward = (t_end - t_begin > 0);
743 unsigned N = (unsigned)round((t_end - t_begin)/m_dt);
744 for(
unsigned i=0; i<N; i++)
745 m_step( t_begin, end);
752 <<m_dt<<
" has to integer divide the interval "<<t_end-t_begin);
753 unsigned N = (unsigned)floor( (t_end-t_begin)/m_dt);
754 for(
unsigned i=0; i<N+1; i++)
755 m_step( t_begin, end);
class intended for the use in throw statements
Definition: exceptions.h:83
small class holding a stringstream
Definition: exceptions.h:29
#define _ping_
Definition: exceptions.h:12
void copy(const ContainerTypeIn &source, ContainerTypeOut &target)
Definition: blas1.h:164
void axpbypgz(get_value_type< ContainerType > alpha, const ContainerType1 &x, get_value_type< ContainerType > beta, const ContainerType2 &y, get_value_type< ContainerType > gamma, ContainerType &z)
Definition: blas1.h:265
void axpby(get_value_type< ContainerType > alpha, const ContainerType1 &x, get_value_type< ContainerType > beta, ContainerType &y)
Definition: blas1.h:231
@ forward
forward derivative (cell to the right and current cell)
Definition: enums.h:98
bool is_divisable(double a, double b, double eps=1e-15)
Definition: runge_kutta.h:961
to
Switch for the Timeloop integrate function.
Definition: ode.h:17
@ exact
match the ending exactly
@ SSPRK_2_2
SSPRK "Shu-Osher-Form"
Definition: tableau.h:1379
@ SSPRK_3_3
SSPRK "Shu-Osher-Form"
Definition: tableau.h:1381
@ SANCHEZ_6_5
Sanchez-6-5
Definition: tableau.h:1375
@ SSPRK_5_4
SSPRK "Shu-Osher-Form"
Definition: tableau.h:1383
@ IMPLICIT_EULER_1_1
Euler (implicit)
Definition: tableau.h:1356
@ SDIRK_2_1_2
generic 2nd order A and L-stable
Definition: tableau.h:1359
@ SANCHEZ_7_6
Sanchez-7-6
Definition: tableau.h:1377
@ SDIRK_5_3_4
SDIRK-5-3-4
Definition: tableau.h:1371
@ SDIRK_4_2_3
Cameron2002
Definition: tableau.h:1365
typename TensorTraits< std::decay_t< Vector > >::value_type get_value_type
Definition: tensor_traits.h:38
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
An abstract ODE integrator.
Runge-Kutta explicit ODE-integrators.
Convert identifiers to their corresponding dg::MultistepTableau.
Definition: multistep_tableau.h:651
General explicit linear multistep ODE integrator .
Definition: multistep.h:60
ExplicitMultistep()=default
No memory allocation.
void step(ExplicitRHS &rhs, value_type &t, ContainerType &u)
Advance one timestep.
Definition: multistep.h:107
ContainerType container_type
Definition: multistep.h:62
ExplicitMultistep(ConvertsToMultistepTableau< value_type > tableau, const ContainerType ©able)
Reserve memory for the integration.
Definition: multistep.h:66
void init(ExplicitRHS &rhs, value_type t0, const ContainerType &u0, value_type dt)
Initialize timestepper. Call before using the step function.
Definition: multistep.h:90
void construct(Params &&...ps)
Perfect forward parameters to one of the constructors.
Definition: multistep.h:69
get_value_type< ContainerType > value_type
the value type of the time variable (float or double)
Definition: multistep.h:61
const ContainerType & copyable() const
Return an object of same size as the object used for construction.
Definition: multistep.h:75
EXPERIMENTAL: General explicit linear multistep ODE integrator with Limiter / Filter .
Definition: multistep.h:515
const ContainerType & copyable() const
Return an object of same size as the object used for construction.
Definition: multistep.h:545
void init(const std::tuple< ExplicitRHS, Limiter > &ode, value_type t0, const ContainerType &u0, value_type dt)
Initialize timestepper. Call before using the step function.
FilteredExplicitMultistep(ConvertsToMultistepTableau< value_type > tableau, const ContainerType ©able)
Reserve memory for the integration.
Definition: multistep.h:530
ContainerType container_type
Definition: multistep.h:517
void construct(Params &&...ps)
Perfect forward parameters to one of the constructors.
Definition: multistep.h:539
void step(const std::tuple< ExplicitRHS, Limiter > &ode, value_type &t, ContainerType &u)
Advance one timestep.
get_value_type< ContainerType > value_type
the value type of the time variable (float or double)
Definition: multistep.h:516
FilteredExplicitMultistep()
No memory allocation.
Definition: multistep.h:519
A filter that does nothing.
Definition: runge_kutta.h:119
Semi-implicit multistep ODE integrator .
Definition: multistep.h:156
void construct(Params &&...ps)
Perfect forward parameters to one of the constructors.
Definition: multistep.h:188
ImExMultistep(ConvertsToMultistepTableau< value_type > tableau, const ContainerType ©able)
Reserve memory for integration and construct Solver.
Definition: multistep.h:169
const ContainerType & copyable() const
Return an object of same size as the object used for construction.
Definition: multistep.h:194
get_value_type< ContainerType > value_type
the value type of the time variable (float or double)
Definition: multistep.h:157
void step(const std::tuple< ExplicitRHS, ImplicitRHS, Solver > &ode, value_type &t, ContainerType &u)
Advance one timestep.
void init(const std::tuple< ExplicitRHS, ImplicitRHS, Solver > &ode, value_type t0, const ContainerType &u0, value_type dt)
Initialize timestepper. Call before using the step function.
ImExMultistep()=default
No memory allocation.
ContainerType container_type
Definition: multistep.h:158
Implicit multistep ODE integrator .
Definition: multistep.h:346
void construct(Params &&...ps)
Perfect forward parameters to one of the constructors.
Definition: multistep.h:377
const ContainerType & copyable() const
Return an object of same size as the object used for construction.
Definition: multistep.h:383
void step(const std::tuple< ImplicitRHS, Solver > &ode, value_type &t, container_type &u)
Advance one timestep.
ImplicitMultistep(ConvertsToMultistepTableau< value_type > tableau, const ContainerType ©able)
Reserve memory for integration.
Definition: multistep.h:360
get_value_type< ContainerType > value_type
the value type of the time variable (float or double)
Definition: multistep.h:348
void init(const std::tuple< ImplicitRHS, Solver > &ode, value_type t0, const ContainerType &u0, value_type dt)
Initialize timestepper. Call before using the step function.
ImplicitMultistep()=default
No memory allocation.
ContainerType container_type
Definition: multistep.h:349
unsigned steps() const
The number of stages s.
Definition: multistep_tableau.h:75
real_type im(unsigned i)
Read the implicit (c_i) coefficients.
Definition: multistep_tableau.h:73
Integrate using a for loop and a fixed non-changeable time-step.
Definition: multistep.h:663
MultistepTimeloop(Stepper &&stepper, ODE &&ode, value_type t0, const ContainerType &u0, value_type dt)
Initialize and bind the step function of a Multistep stepper.
Definition: multistep.h:697
ContainerType container_type
Definition: multistep.h:664
MultistepTimeloop(std::function< void(value_type &, ContainerType &)> step, value_type dt)
Construct using a std::function.
Definition: multistep.h:675
virtual MultistepTimeloop * clone() const
Abstract copy method that returns a copy of *this on the heap.
Definition: multistep.h:718
void construct(Params &&...ps)
Perfect forward parameters to one of the constructors.
Definition: multistep.h:712
MultistepTimeloop()=default
no allocation
dg::get_value_type< ContainerType > value_type
Definition: multistep.h:665
Abstract timeloop independent of stepper and ODE.
Definition: ode.h:60