MathTL
|
00001 // -*- c++ -*- 00002 00003 // +--------------------------------------------------------------------+ 00004 // | This file is part of MathTL - the Mathematical Template Library | 00005 // | | 00006 // | Copyright (c) 2002-2009 | 00007 // | Thorsten Raasch, Manuel Werner | 00008 // +--------------------------------------------------------------------+ 00009 00010 #ifndef _MATHTL_RUNGE_KUTTA_H 00011 #define _MATHTL_RUNGE_KUTTA_H 00012 00013 #include <algebra/vector.h> 00014 #include <algebra/triangular_matrix.h> 00015 #include <numerics/one_step_scheme.h> 00016 00017 namespace MathTL 00018 { 00026 template <class VECTOR> 00027 class ExplicitRungeKuttaScheme 00028 : public OneStepScheme<VECTOR> 00029 { 00030 public: 00038 enum Method { 00039 RK12, // s=2, p=2(1) (embedded scheme is Euler scheme) 00040 RK23, // s=3, p=3(2) (embedded scheme is the Runge/improved Euler scheme), see [S] 00041 Fehlberg34, // s=5 (effective: 4), p=4(3), FSAL (uses the classical RK scheme), see [DB] 00042 DoPri45, // s=7 (effective: 6), p=5(4), FSAL 00043 DoPri78 // s=13 (effective: 12), p=8(7), FSAL 00044 }; 00045 00049 ExplicitRungeKuttaScheme(const Method method); 00050 00054 void increment(const AbstractIVP<VECTOR>* ivp, 00055 const double t_m, const VECTOR& u_m, 00056 const double tau, 00057 VECTOR& u_mplus1, 00058 VECTOR& error_estimate, 00059 const double tolerance = 1e-2) const; 00060 00064 int order() const { return p; } 00065 00066 protected: 00071 bool fsal; 00072 00074 Vector<double> c; 00075 00077 LowerTriangularMatrix<double> A; 00078 00080 Vector<double> b, bhat; 00081 00083 int p; 00084 }; 00085 } 00086 00087 #include "numerics/runge_kutta.cpp" 00088 00089 #endif