RungeKutta.hpp

00001 
00002 //
00003 // $Id: RungeKutta.hpp,v 1.1 2004/08/12 16:21:33 werner Exp $
00004 //
00005 // $Log: RungeKutta.hpp,v $
00006 // Revision 1.1  2004/08/12 16:21:33  werner
00007 // Integration of numerical geodesics now compiles. Working is not yet satisfying.
00008 //
00009 // Revision 1.8  2004/05/12 14:36:22  werner
00010 // Separation of chart definitions on a manifold and the tangential space.
00011 // Introduced convenient coordinate transformations.
00012 //
00013 // Revision 1.7  2004/05/11 18:05:10  werner
00014 //
00015 // Revision 1.6  2004/05/11 16:53:47  werner
00016 // Introduction of coordinate systems for improved type-safety.
00017 // Will support easy coordinate transformations soon.
00018 //
00019 // Revision 1.5  2004/05/06 22:42:16  werner
00020 // Towards a specification of a spacetime via the Acceleration structure.
00021 //
00022 // Revision 1.4  2004/05/05 15:56:52  werner
00023 // Separation of DOP core routines with dynamic size into the ODE library.
00024 //
00025 // Revision 1.3  2004/05/03 13:33:33  werner
00026 // integration improved
00027 //
00028 // Revision 1.2  2004/03/29 11:51:02  werner
00029 // Common interface among simple integrators, DiffMe and Vecal, and preliminiary work on integrating dop853.
00030 //
00031 // Revision 1.1  2004/03/22 11:55:02  werner
00032 // Schwarzschild geodesic integration.
00033 //
00034 // Revision 1.1  2004/02/13 16:36:21  werner
00035 // Initial preliminiary version of the Vector Algebra Library.
00036 //
00038 #ifndef __RUNGE_KUTTA_Geodesic_HPP
00039 #define __RUNGE_KUTTA_Geodesic_HPP "Created 20.07.2004 00:11:27 by werner"
00040 
00041 #include <vecal/VVector.hpp>
00042 #include <vecal/Matrix.hpp>
00043 
00044 #include <ode/Integrator.hpp>
00045 #include <spacetime/Geodesic.hpp>
00046 
00047 namespace Traum
00048 {
00049 
00050 template <class Acceleration>
00051 struct  RungeKuttaGeodesic : public IntegratorBase
00052 {
00053         typedef typename Acceleration::Scalar_t     Scalar_t;
00054         typedef typename Acceleration::Point_t      Point_t;
00055         typedef typename Acceleration::Vector_t     Vector_t;
00056         typedef typename Acceleration::Christoffel_t Christoffel_t;
00057 
00058         typedef typename Point_t::Vector_t PointComponents_t;
00059         enum { Dims = PointComponents_t::SIZE };
00060 
00061         Point_t  x;
00062         Vector_t v;
00063 
00064         const Acceleration&Accel;
00065         Scalar_t ds;
00066 
00067         RungeKuttaGeodesic(const Acceleration&A)
00068         : Accel(A), ds(1)
00069         {}
00070 
00071         success_code advance(bool bk=false)
00072         {
00073         Scalar_t ds = bk?-this->ds:this->ds;
00074 
00075         Point_t  P = x + v*(ds/2.L);
00076         Vector_t V = v + v/2.L;
00077 
00078         Vector_t
00079                 b1 = ds * Accel(x, v),
00080                 b2 = ds * Accel(x + v*(ds/2.L) + b1*(ds/8.L), v + b1/2.L),
00081                 b3 = ds * Accel(x + v*(ds/2.L) + b1*(ds/8.L), v + b2/2.L),
00082                 b4 = ds * Accel(x + v*ds    + b3*(ds/2.L), v + b3);
00083 
00084                 x += v*ds + (b1 +    b2 +    b3) * ds/6;
00085                 v +=        (b1 +2.L*b2 +2.L*b3 + b4)/6;
00086 
00087                 return StepOk;
00088         }
00089 };
00090 
00091 
00092 } /* namespace VecAl */ 
00093 
00094 #endif /* __RUNGE_KUTTA_Geodesic_HPP */