FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
IntegrateGeodesic.hpp
1
2//
3// $Id: IntegrateGeodesic.hpp,v 1.1 2004/08/12 16:21:33 werner Exp $
4//
5// $Log: IntegrateGeodesic.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//
11#ifndef __INTEGRATE_GEODESIC_HPP
12#define __INTEGRATE_GEODESIC_HPP "Created 20.07.2004 00:19:45 by werner benger"
13
14#include <spacetime/Geodesic853.hpp>
15#include <spacetime/EulerGeodesic.hpp>
16#include <spacetime/RungeKutta.hpp>
17#include <spacetime/AdamsStoermer.hpp>
18
19namespace Traum
20{
21using namespace VecAl;
22
24{
25public:
26
27 enum IntegratorType
28 {
29 Euler,
30 RungeKutta,
31 AdamsStoermer,
32 DOP853
33 };
34 const IntegratorType myType;
35
36 GeodesicIntegratorBase(IntegratorType t)
37 : myType(t)
38 {}
39};
40
46template <class TangentialSpaceType>
48{
49public:
50 typedef typename TangentialSpaceType::Point_t Point_t;
51 typedef typename TangentialSpaceType::Vector_t Vector_t;
52
53 enum { Dims = TangentialSpaceType::Dims };
54
55 GeodesicIntegrator(IntegratorType t)
57 {}
58
59 virtual success_code advance(bool bk=false) = 0;
60 virtual void restart(const Point_t&x0, const Vector_t&v0) = 0;
61 virtual Point_t position() const = 0;
62 virtual Vector_t velocity() const = 0;
63};
64
80template <class Acceleration>
81class IntegrateGeodesic : public GeodesicIntegrator<typename Acceleration::TangentialSpace_t>
82{
83public:
85 typedef typename Acceleration::TangentialSpace_t TangentialSpace_t;
87
89 typedef typename Base_t::Point_t Point_t;
91 typedef typename Base_t::Vector_t Vector_t;
92
94 typedef typename Acceleration::Point_t GenericPoint_t;
96 typedef typename Acceleration::Vector_t GenericVector_t;
97
98 enum { Dims = Acceleration::Dims };
99
104
105 IntegrateGeodesic(const Acceleration&A, IntegratorType t)
106 : Base_t(t)
107 , E(A)
108 , RK(A)
109 , AS(A)
110 , DP853(A)
111 {}
112
113 success_code advance(bool bk=false) override
114 {
115 switch(myType)
116 {
117 case Euler: return E.advance(bk);
118 case RungeKutta: return RK.advance(bk);
119 case AdamsStoermer: return AS.advance(bk);
120 case DOP853: return DP853.advance(bk);
121 }
122 }
123
124 void setStepSize(double ds)
125 {
126 E.ds = ds;
127 RK.ds = ds;
128 AS.ds = ds;
129 }
130
131 void restart(const Point_t&x0, const Vector_t&v0) override
132 {
133 switch(myType)
134 {
135 case Euler: E .x = x0;
136 E .v = v0;
137 break;
138
139 case RungeKutta: RK .x = x0;
140 RK .v = v0;
141 break;
142
143 case AdamsStoermer: AS.reset_step();
144 AS .x = x0;
145 AS .v = v0;
146 break;
147
148 case DOP853: DP853.restart1(0, x0, v0);
149 break;
150 }
151 }
152
153
154 Point_t position() const override
155 {
156 switch(myType)
157 {
158 case Euler: return E.x;
159 case RungeKutta: return RK.x;
160 case AdamsStoermer: return AS.x;
161 case DOP853: return DP853.position();
162 }
163 }
164
165 Vector_t velocity() const override
166 {
167 switch(myType)
168 {
169 case Euler: return E.v;
170 case RungeKutta: return RK.v;
171 case AdamsStoermer: return AS.v;
172 case DOP853: return DP853.velocity();
173 }
174 }
175};
176
177} // namespace Vecal
178
179#endif // __INTEGRATE_GEODESIC_HPP
Modified from Florian Schrack's libgrav: Gravitation - Theorien, Effekte und Simulation am Computer
Definition AdamsStoermer.hpp:57
Definition Geodesic853.hpp:43
Definition IntegrateGeodesic.hpp:24
Abstract interface for computing geodesics in a certain coordinate system.
Definition IntegrateGeodesic.hpp:48
Implementation of a coordinate-specific integration of geodesics in a certain coordinate system,...
Definition IntegrateGeodesic.hpp:82
Base_t::Point_t Point_t
The coordinate-specific point type.
Definition IntegrateGeodesic.hpp:89
Base_t::Vector_t Vector_t
The coordinate-specific tangential vector type (from TangentialSpace<> )
Definition IntegrateGeodesic.hpp:91
Acceleration::Point_t GenericPoint_t
The coordinate-independent numerical raw type.
Definition IntegrateGeodesic.hpp:94
Acceleration::Vector_t GenericVector_t
The coordinate-specific tangential vector type (possibly just a Vector<> )
Definition IntegrateGeodesic.hpp:96
Acceleration::TangentialSpace_t TangentialSpace_t
The associated coordinate representation of the tangential space.
Definition IntegrateGeodesic.hpp:85
Class EulerGeodesic is coordinate-independent.
Definition EulerGeodesic.hpp:53
Definition RungeKutta.hpp:52