31template<
class ContainerType>
40 Simpsons(
unsigned order = 3): m_counter(0), m_order(order), m_t0(0)
49 if( !(order == 2 || order == 3))
84 if( t_new < m_t.front())
86 auto pt0 = m_t.begin();
87 auto pt1 = std::next( pt0);
88 auto pu0 = m_u.begin();
89 auto pu1 = std::next( pu0);
91 if( m_counter % 2 == 0 || m_order == 2)
95 0.5*(t2 - t1), *pu0 , 1., m_integral);
100 value_type pre0 = (2.*t0-3.*t1+t2)*(t2-t0)/(6.*(t0-t1));
101 value_type pre1 = (t2-t0)*(t2-t0)*(t2-t0)/(6.*(t0-t1)*(t1-t2));
102 value_type pre2 = (t0-3.*t1+2.*t2)*(t0-t2)/(6.*(t1-t2));
106 pre1-0.5*(t1-t0), *pu0,
107 pre0-0.5*(t1-t0), *pu1,
111 m_t.splice( pt0, m_t, pt1, m_t.end());
112 m_u.splice( pu0, m_u, pu1, m_u.end());
130 std::array<value_type,2> times{ m_t0, m_t.front()};
134 unsigned m_counter, m_order;
135 ContainerType m_integral;
137 std::list<value_type> m_t;
138 std::list<ContainerType> m_u;
class intended for the use in throw statements
Definition: exceptions.h:83
small class holding a stringstream
Definition: exceptions.h:29
Error classes or the dg library.
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
void scal(ContainerType &x, get_value_type< ContainerType > alpha)
Definition: blas1.h:185
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...
Time integration based on Simpson's rule.
Definition: simpsons.h:33
unsigned get_order() const
Access current integration order.
Definition: simpsons.h:53
Simpsons(unsigned order=3)
Set integration order without initializing values.
Definition: simpsons.h:40
void init(value_type t0, const ContainerType &u0)
Initialize the left-side boundary of the integration.
Definition: simpsons.h:59
void flush()
Reset the integral to zero and the last (t,u) pair in the add function as the new left-side.
Definition: simpsons.h:71
void add(value_type t_new, const ContainerType &u_new)
Add a new (t,u) pair to the time integral.
Definition: simpsons.h:83
std::array< value_type, 2 > get_boundaries() const
Access the left and right boundary in time.
Definition: simpsons.h:129
ContainerType container_type
the type of the vector class in use
Definition: simpsons.h:35
const ContainerType & get_integral() const
Access the current value of the time integral.
Definition: simpsons.h:121
get_value_type< ContainerType > value_type
the value type of the time variable (float or double)
Definition: simpsons.h:34
void set_order(unsigned order)
Set integration order without initializing values.
Definition: simpsons.h:45