|
| Simpsons (unsigned order=3) |
| Set integration order without initializing values. More...
|
|
void | set_order (unsigned order) |
| Set integration order without initializing values. More...
|
|
unsigned | get_order () const |
| Access current integration order. More...
|
|
void | init (value_type t0, const ContainerType &u0) |
| Initialize the left-side boundary of the integration. More...
|
|
void | flush () |
| Reset the integral to zero and the last (t,u) pair in the add function as the new left-side. More...
|
|
void | add (value_type t_new, const ContainerType &u_new) |
| Add a new (t,u) pair to the time integral. More...
|
|
const ContainerType & | get_integral () const |
| Access the current value of the time integral. More...
|
|
std::array< value_type, 2 > | get_boundaries () const |
| Access the left and right boundary in time. More...
|
|
template<class ContainerType>
struct dg::Simpsons< ContainerType >
Time integration based on Simpson's rule.
The intention of this class is to provide a means to continuously integrate a sample of \(( t_i, u_i)\) pairs that become available one after the other (e.g. from the integration of an ODE) and approximate
\[ \int_{t_0}^T u(t) dt \]
- Note
- The algorithm simply integrates the Lagrange-polynomial through up to three data points. For equidistant Data points this equals either the Trapezoidal (linear) or the Simpson's rule (quadratic)
- See also
- For an explanation of Simpson's rule: https://en.wikipedia.org/wiki/Simpson%27s_rule
The class works by first calling the init function to set the left-side boundary and then adding values as they become available.
unsigned N=20;
for ( unsigned i=0; i<g1d.size(); i++)
simpsons.
add( times[i], values[i]);
std::cout << "Error Simpsons is "<<fabs(integral-1.)<<std::endl;
#define M_PI
M_PI is non-standard ... so MSVC complains.
Definition: functors.h:6
static DG_DEVICE double cooX1d(double x)
Definition: functions.h:38
thrust::host_vector< real_type > evaluate(UnaryOp f, const RealGrid1d< real_type > &g)
Evaluate a 1d function on grid coordinates.
Definition: evaluation.h:67
thrust::host_vector< double > HVec
Host Vector.
Definition: typedefs.h:19
Time integration based on Simpson's rule.
Definition: simpsons.h:33
void init(value_type t0, const ContainerType &u0)
Initialize the left-side boundary of the integration.
Definition: simpsons.h:59
void add(value_type t_new, const ContainerType &u_new)
Add a new (t,u) pair to the time integral.
Definition: simpsons.h:83
const ContainerType & get_integral() const
Access the current value of the time integral.
Definition: simpsons.h:121
- Template Parameters
-
ContainerType | Any 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