FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
Integrate4D.hpp
1
2//
3// $Id: Integrate4D.hpp,v 1.6 2007/03/28 22:31:38 georg Exp $
4//
5// $Log: Integrate4D.hpp,v $
6// Revision 1.6 2007/03/28 22:31:38 georg
7// dtors adapted for gcc4
8//
9// Revision 1.5 2007/02/22 17:08:42 werner
10// A major revision of the vector/fixed array interface, unifying three independent
11// libraries into one. The vecal (Vector Algebra), fish/vector (Multidimensional
12// vector arrays) and the Eagle library (Geometric Algebra) thus share a common
13// root now.
14//
15// Revision 1.4 2004/05/11 17:16:24 werner
16// *** empty log message ***
17//
18// Revision 1.3 2004/05/05 15:56:52 werner
19// Separation of DOP core routines with dynamic size into the ODE library.
20//
21// Revision 1.2 2004/05/03 13:33:33 werner
22// integration improved
23//
24// Revision 1.1 2004/04/28 14:06:37 werner
25// Integrators may be safely derived from the dop853 template now.
26// The template definition does not include the member functions, these
27// need to be included explicitely when instantiating the dop853 integrator.
28//
29//
31#ifndef __INTEGRATE4D_HPP
32#define __INTEGRATE4D_HPP "Created 25.04.2004 11:02:10 by werner benger"
33
34#include <ode/Integrator.hpp>
35#include <eagle/FixedArray.hpp>
36#include <ode/dop853decl.hpp>
37
38#include "spacetime.h"
39
40namespace Traum
41{
42 using namespace Eagle;
43
44template <class real=long double, int Dims=4>
46
47template <class Real, int N>
49 {
50 typedef Real real;
51
52 struct RealArray_t : FixedArray<real, 2*N>
53 {
54 void init(int) {}
55 };
56
57 struct DOPVarsArray_t : FixedArray<dop_vars<real>, 2*N >
58 {
59 void init(int) {}
60 };
61
63
64 //virtual void Accel(real s, const real *x, const real *v, real *d2x_ds2) = 0;
65
66 void DiffEqn(int nEquations, real s, const real *q, real *dq_ds)
67 {
68 const real *x = q;
69 const real *v = q + N;
70 real *dx_ds = dq_ds;
71 real *dv_ds = dq_ds + N;
72
73 for(int i=0; i<N; i++)
74 {
75 dx_ds[i] = v[i];
76 }
77 parent->Accel(s, x, v, dv_ds);
78 }
79 };
80
81
82template <>
83class SPACETIME_API IntegratePathBase<long double, 4> : public Integrator<long double>
84{
85 typedef long double real;
86 enum { n = 4 };
87
89 PathIntegrator*myIntegrator;
90
91public:
93// ~IntegratePathBase<long double, 4>();
95
96 real *initialize(int n, const real&s);
97 long step_nr() const override;
98 const real&dx() const override;
99 const real&x0() const override;
100 const real&x1() const override;
101 int size() const override;
102 const real&f(int i) const override;
103 real f(int i, const real&x) const override;
104
105 success_code advance(bool backward=false) override;
106
107 virtual void Accel(real s, const real *x, const real *v, real *d2x_ds2) = 0;
108};
109
110
111
112
113template <class Real, int Dims>
114class IntegratePath : public IntegratePathBase<Real, Dims>
115{
116public:
117 typedef Real real;
118
119 template <class sValue, class Value>
120 void init(const sValue&s, const Value*q, const Value*dq)
121 {
122 real *x = initialize(2*Dims, s);
123 real *v = x + Dims;
124 for(int i=0; i<Dims; i++)
125 {
126 x[i] = q[i];
127 v[i] = dq[i];
128 }
129 }
130
131 template <class sValue, class Value>
132 void init(const sValue&s, const FixedArray<Value, Dims>&q, const FixedArray<Value, Dims>&dq)
133 {
134 real *x = initialize(2*Dims, s);
135 real *v = x + Dims;
136 for(int i=0; i<Dims; i++)
137 {
138 x[i] = q[i];
139 v[i] = dq[i];
140 }
141 }
142
144
145 virtual void Accel(real s, const real *x, const real *v, real *d2x_ds2) = 0;
146
148static unsigned nPaths()
149 {
150 return Dims;
151 }
152
154 const real&s0() const
155 {
156 return this->x0();
157 }
158
159 const real&s1() const
160 {
161 return this->x1();
162 }
163
164 const real&q(int i) const
165 {
166 return this->f(i);
167 }
168
169 real q(unsigned i, real s) const
170 {
171 return this->f(i, s );
172 }
173
174 const real&dq(int i) const
175 {
176 return this->f(i+nPaths() );
177 }
178
179 real dq(unsigned i, real s) const
180 {
181 return this->f(i+nPaths(), s );
182 }
183};
184
186//typedef IntegratePath< double, 4> IntegratePath4Dd;
187//typedef IntegratePath< float , 4> IntegratePath4Df;
188
189
190} // namespace Traum
191
192#endif // __INTEGRATE4D_HPP
valarray< size_t > size() const
constexpr void advance(_InputIterator &__i, _Distance __n)
Definition Integrate4D.hpp:45
Definition Integrate4D.hpp:115
Definition Integrate4D.hpp:49