Click here to Skip to main content
15,896,153 members
Articles / Programming Languages / CUDA

odeint v2 - Solving ordinary differential equations in C++

Rate me:
Please Sign up or sign in to vote.
4.64/5 (18 votes)
19 Oct 2011CPOL19 min read 130.1K   2.8K   34  
odeint v2 - Solving ordinary differential equations in C++
/*
 * fusion_explicit_error_rk.hpp
 *
 *  Created on: Apr 29, 2011
 *      Author: mario
 */

#ifndef FUSION_EXPLICIT_ERROR_RK_HPP_
#define FUSION_EXPLICIT_ERROR_RK_HPP_

#include "fusion_explicit_rk_new.hpp"
#include "fusion_algebra.hpp"

namespace mpl = boost::mpl;
namespace fusion = boost::fusion;

using namespace std;

template< class StateType , size_t stage_count >
class explicit_error_rk : public explicit_rk< StateType , stage_count >
{

public:

    typedef explicit_rk< StateType , stage_count > base;

    typedef StateType state_type;

    typedef typename base::stage_indices stage_indices;

    typedef typename base::coef_a_type coef_a_type;

    typedef typename base::coef_b_type coef_b_type;
    typedef typename base::coef_c_type coef_c_type;

 public:

    explicit_error_rk( const coef_a_type &a ,
                          const coef_b_type &b ,
                          const coef_b_type &b2 ,
                          const coef_c_type &c )
    : base( a , b , c ) , m_b2( b2 )
    { }

    template< class System >
    void inline do_step( System system , state_type &x , const double t , const double dt , state_type &x_err )
    {
        base::do_step( system , x , t , dt );
        // compute error estimate
        fusion_algebra< stage_count >::foreach( x_err , m_b2 , base::m_F , dt );
    }

private:

    const coef_b_type m_b2;
};

#endif /* FUSION_EXPLICIT_ERROR_RK_HPP_ */

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions