Extension: Matrix functions
#include "dg/matrix/matrix.h"
dg::mat::ExponentialStep< ContainerType > Struct Template Reference

Exponential one step time-integration for \( \dot y = A y \). More...

Public Types

using value_type = get_value_type< ContainerType >
 the value type of the time variable (float or double) More...
 
using container_type = ContainerType
 

Public Member Functions

 ExponentialStep ()=default
 no memory allocation More...
 
 ExponentialStep (const ContainerType &copyable)
 Reserve internal workspace for the integration. More...
 
const ContainerType & copyable () const
 
template<class MatrixFunction >
void step (MatrixFunction &ode, value_type t0, const ContainerType &u0, value_type &t1, ContainerType &u1, value_type dt)
 Advance one step via \( u_1 = \exp( A \Delta t) u_0\), \( t_1 = t_0 + \Delta_t\). More...
 

Detailed Description

template<class ContainerType>
struct dg::mat::ExponentialStep< ContainerType >

Exponential one step time-integration for \( \dot y = A y \).

This integrator computes the exact solution

\[ \begin{align} y^{n+1} = \exp(-\Delta t A) y^n \end{align} \]

This class is usable in the dg::SinglestepTimeloop

Template Parameters
ContainerTypeAny class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag. Among others
  • dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
  • std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
  • double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them
See also
See The dg dispatch system for a detailed explanation of our type dispatch system

Member Typedef Documentation

◆ container_type

template<class ContainerType >
using dg::mat::ExponentialStep< ContainerType >::container_type = ContainerType

the type of the vector class in use

◆ value_type

template<class ContainerType >
using dg::mat::ExponentialStep< ContainerType >::value_type = get_value_type<ContainerType>

the value type of the time variable (float or double)

Constructor & Destructor Documentation

◆ ExponentialStep() [1/2]

template<class ContainerType >
dg::mat::ExponentialStep< ContainerType >::ExponentialStep ( )
default

no memory allocation

◆ ExponentialStep() [2/2]

template<class ContainerType >
dg::mat::ExponentialStep< ContainerType >::ExponentialStep ( const ContainerType &  copyable)
inline

Reserve internal workspace for the integration.

Parameters
copyablevector of the size that is later used in step ( it does not matter what values copyable contains, but its size is important; the step method can only be called with vectors of the same size)

Member Function Documentation

◆ copyable()

template<class ContainerType >
const ContainerType & dg::mat::ExponentialStep< ContainerType >::copyable ( ) const
inline

◆ step()

template<class ContainerType >
template<class MatrixFunction >
void dg::mat::ExponentialStep< ContainerType >::step ( MatrixFunction ode,
value_type  t0,
const ContainerType &  u0,
value_type t1,
ContainerType &  u1,
value_type  dt 
)
inline

Advance one step via \( u_1 = \exp( A \Delta t) u_0\), \( t_1 = t_0 + \Delta_t\).

Template Parameters
MatrixFunctionThe exponential of the (part of the) right hand side is a functor type with no return value (subroutine) of signature void operator()(UnaryOp, const ContainerType&, ContainerType&) The first argument is the matrix function to compute, the second is the input vector, which the functor may not override, and the third is the output. The timestepper will call MatrixFunction(f, y, yp) where f typically is the exponential or dg::mat::phi1, dg::mat::phi2, etc. The FunctionalButcherTableau determines which matrix functions are used. The timestepper expects that MatrixFunction(f, y, yp) computes \( y' = f( A) y\). The two ContainerType arguments never alias each other in calls to the functor. The functor can throw to indicate failure. Exceptions should derive from std::exception.
Parameters
odeobject that computes matrix functions (for this class always the exponential) of the right hand side
t0start time
u0value at t0
t1(write only) end time ( equals t0+dt on return, may alias t0)
u1(write only) contains result on return (may alias u0)
dttimestep

The documentation for this struct was generated from the following file: