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_W_METHOD_H 00011 #define _MATHTL_W_METHOD_H 00012 00013 #include <algebra/triangular_matrix.h> 00014 #include <algebra/vector.h> 00015 #include <numerics/ivp.h> 00016 #include <numerics/one_step_scheme.h> 00017 00018 namespace MathTL 00019 { 00035 template <class VECTOR> 00036 class WMethodStageEquationHelper 00037 { 00038 public: 00040 virtual ~WMethodStageEquationHelper() = 0; 00041 00047 virtual void solve_W_stage_equation(const AbstractIVP<VECTOR>* ivp, 00048 const double t, 00049 const VECTOR& v, 00050 const double alpha, 00051 const VECTOR& y, 00052 const double tolerance, 00053 VECTOR& x) const = 0; 00054 00061 virtual void approximate_ft(const AbstractIVP<VECTOR>* ivp, 00062 const double t, 00063 const VECTOR& v, 00064 const double tolerance, 00065 VECTOR& result) const = 0; 00066 }; 00067 00076 template <class VECTOR> 00077 class WMethodPreprocessRHSHelper 00078 { 00079 public: 00081 virtual ~WMethodPreprocessRHSHelper() = 0; 00082 00084 virtual void preprocess_rhs_share(VECTOR& wbeforeandafter, 00085 const double tolerance) const 00086 { // default behaviour: do nothing 00087 } 00088 }; 00089 00138 template <class VECTOR> 00139 class WMethod 00140 : public OneStepScheme<VECTOR> 00141 { 00142 public: 00178 enum Method { 00179 GRK4T, // s=4, p=4 00180 RODAS3, // s=4, p=3, index 1, L-stable, stiffly accurate 00181 ROS2, // s=2, p=2, L-stable 00182 ROS3, // s=3, p=3, L-stable 00183 ROWDA3, // s=3, p=3, index 1, L-stable 00184 ROS3P, // s=3, p=3, index 1, nonlinear PDEs 00185 ROS3Pw, // s=3, p=3, index 1, PDEs 00186 ROSI2P2, // s=4, p=3, index 2, L-stable, PDEs, stiffly accurate 00187 ROSI2PW, // s=4, p=3, index 2, L-stable, PDEs, stiffly accurate, W-method 00188 RODAS, // s=6, p=4 00189 RODASP // s=6, p=4, index 1, PDEs, L-stable, stiffly accurate 00190 }; 00191 00195 WMethod(const Method method, 00196 const WMethodStageEquationHelper<VECTOR>* stage_equation_solver); 00197 00201 virtual ~WMethod() {} 00202 00207 void increment(const AbstractIVP<VECTOR>* ivp, 00208 const double t_m, 00209 const VECTOR& u_m, 00210 const double tau, 00211 VECTOR& u_mplus1, 00212 VECTOR& error_estimate, 00213 const double tolerance = 1e-2) const; 00214 00218 int order() const { return p; } 00219 00223 void set_preprocessor(WMethodPreprocessRHSHelper<VECTOR>* pp) { 00224 preprocessor = pp; 00225 } 00226 00232 static void transform_coefficients(const LowerTriangularMatrix<double>& Alpha, 00233 const LowerTriangularMatrix<double>& Gamma, 00234 const Vector<double>& b, 00235 const Vector<double>& bhat, 00236 LowerTriangularMatrix<double>& A, 00237 LowerTriangularMatrix<double>& C, 00238 Vector<double>& m, 00239 Vector<double>& e, 00240 Vector<double>& alpha_vector, 00241 Vector<double>& gamma_vector); 00242 00246 static void check_order_conditions(const LowerTriangularMatrix<double>& Alpha, 00247 const LowerTriangularMatrix<double>& Gamma, 00248 const Vector<double>& b, 00249 const Vector<double>& bhat, 00250 const bool wmethod=false); 00251 00253 LowerTriangularMatrix<double> A; 00254 00256 LowerTriangularMatrix<double> C; 00257 00259 Vector<double> m; 00260 00262 Vector<double> e; 00263 00265 Vector<double> alpha_vector; 00266 00268 Vector<double> gamma_vector; 00269 00270 00271 protected: 00273 const WMethodStageEquationHelper<VECTOR>* stage_equation_helper; 00274 00276 WMethodPreprocessRHSHelper<VECTOR>* preprocessor; 00277 00279 int p; 00280 }; 00281 } 00282 00283 #include <numerics/w_method.cpp> 00284 00285 #endif