FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
AdamsStoermer.hpp
1
2//
3// $Id: AdamsStoermer.hpp,v 1.1 2004/08/12 16:21:33 werner Exp $
4//
5// $Log: AdamsStoermer.hpp,v $
6// Revision 1.1 2004/08/12 16:21:33 werner
7// Integration of numerical geodesics now compiles. Working is not yet satisfying.
8//
9// Revision 1.8 2004/05/12 14:36:22 werner
10// Separation of chart definitions on a manifold and the tangential space.
11// Introduced convenient coordinate transformations.
12//
13// Revision 1.7 2004/05/11 18:05:10 werner
14//
15// Revision 1.6 2004/05/11 16:53:47 werner
16// Introduction of coordinate systems for improved type-safety.
17// Will support easy coordinate transformations soon.
18//
19// Revision 1.5 2004/05/06 22:42:16 werner
20// Towards a specification of a spacetime via the Acceleration structure.
21//
22// Revision 1.4 2004/05/05 15:56:52 werner
23// Separation of DOP core routines with dynamic size into the ODE library.
24//
25// Revision 1.3 2004/05/03 13:33:33 werner
26// integration improved
27//
28// Revision 1.2 2004/03/29 11:51:02 werner
29// Common interface among simple integrators, DiffMe and Vecal, and preliminiary work on integrating dop853.
30//
31// Revision 1.1 2004/03/22 11:55:02 werner
32// Schwarzschild geodesic integration.
33//
34// Revision 1.1 2004/02/13 16:36:21 werner
35// Initial preliminiary version of the Vector Algebra Library.
36//
38#ifndef __AdamsStoermer_Geodesic_HPP
39#define __AdamsStoermer_Geodesic_HPP "Created 27.02.2001 21:42:27 by werner"
40
41#include <vecal/VVector.hpp>
42#include <vecal/Matrix.hpp>
43
44#include <ode/Integrator.hpp>
45#include <spacetime/RungeKutta.hpp>
46
47namespace Traum
48{
49
55template <class Acceleration>
56class AdamsStoermerGeodesic : public RungeKuttaGeodesic<Acceleration>
57{
58public:
59 typedef typename RungeKuttaGeodesic<Acceleration>::Scalar_t Scalar_t;
60 typedef typename RungeKuttaGeodesic<Acceleration>::Point_t Point_t;
61 typedef typename RungeKuttaGeodesic<Acceleration>::Vector_t Vector_t;
62
63 using RungeKuttaGeodesic<Acceleration>::x;
64 using RungeKuttaGeodesic<Acceleration>::v;
65
66private:
67 int step;
68 Vector_t b0, b1, b2, b3;
69
70 void predict(Point_t&xp, Vector_t&vp, const Scalar_t&ds) const
71 {
72 xp = x + v*ds + ds*ds/360.*(323.*b0-264.*b1+159.*b2-38.*b3);
73 vp = v + ds/24. *( 55.*b0- 59.*b1+ 37.*b2- 9.*b3);
74 }
75
76 void correct(Point_t&xp, Vector_t&vp, const Scalar_t&ds) const
77 {
78 Vector_t bp = -Accel(xp, vp);
79 xp = x + v*ds
80 + ds*ds/1440.*(135.*bp+752.*b0-246.*b1+ 96.*b2-17.*b3);
81 vp = v + ds/720. *(251.*bp+646.*b0-264.*b1+106.*b2-19.*b3);
82 }
83
84 void shift()
85 {
86 b3 = b2;
87 b2 = b1;
88 b1 = b0;
89 b0 = -Accel(x, v);
90 }
91
92public:
93 AdamsStoermerGeodesic (const Acceleration&A)
95 , step(0)
96 {}
97
98 void reset_step()
99 {
100 step = 0;
101 }
102
103 success_code advance(bool bk=false)
104 {
105 Scalar_t ds = bk?-this->ds:this->ds;
106
107 if (step++ < 4)
108 {
110 shift();
111 return StepOk;
112 }
113 Point_t xp;
114 Vector_t vp;
115 predict(xp, vp, ds);
116 correct(xp, vp, ds);
117 correct(xp, vp, ds);
118 shift();
119 x = xp;
120 v = vp;
121
122 return StepOk;
123 }
124};
125
126} /* namespace VecAl */
127
128#endif /* __AdamsStoermer_Geodesic_HPP */
Modified from Florian Schrack's libgrav: Gravitation - Theorien, Effekte und Simulation am Computer
Definition AdamsStoermer.hpp:57
Definition RungeKutta.hpp:52