FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
Interpolate.hpp
1
2//
3// $Id: Interpolate.hpp,v 1.5 2007/12/28 13:50:49 werner Exp $
4//
6#ifndef __FIBER_ARRAY_INTERPOLATE_HPP
7#define __FIBER_ARRAY_INTERPOLATE_HPP "Created 3.07.2004 21:42:21 by bzfbenge"
8
9#include <iostream>
10
11#include "VVector.hpp"
12#include "MultiArray.hpp"
13#include "IpolDelimiter.hpp"
14
15namespace Fiber
16{
30template <class T, class Interpol1D, bool Derive=false>
32{
33public:
34 template <class Storage1D, class Limiter>
35static T interpolate(const Storage1D&Data, double t, index_t size, const Limiter&L)
36 {
37// printf("IpolDerivative, non ipol, at %.20lg\n", t);
38 return Interpol1D::interpolate(Data,t,size,L);
39 }
40};
41
46template <class T, class Interpol1D>
48{
49public:
50 template <class Storage1D, class Limiter>
51static T interpolate(const Storage1D&Data, double t, index_t size, const Limiter&L)
52 {
53 return Interpol1D::derivative(Data,t,size,L);
54 }
55};
56
57
61template <int N, class Type, class Interpol, class CoordinateType = double,
63struct Interpolate;
64
73template <class Type, class Interpol, class CoordinateType, class Delimiter, int DerivativeDimension>
74struct Interpolate<1, Type, Interpol, CoordinateType, Delimiter, DerivativeDimension>
75{
76 enum { Dims = 1 };
77
78 typedef Type value_type;
80
82
83private:
84 const MultiArray_t&M;
85 const Point_t &Point;
86
87public: Delimiter myDelimiter;
88
90 const Point_t&point)
91 : M(m), Point(point)
92 {}
93
95 const Point_t&point,
96 const Delimiter&myDeli)
97 : M(m), Point(point), myDelimiter(myDeli)
98 {}
99
100 Type operator[](index_t i) const
101 {
102 // printf("\nInterpolate<1D, DerivativeDimension=%d>: Slice %d\n", DerivativeDimension, i);
103#if 0
105 interpolate(M, Point[0], M.Size()[0] /*Extension()[0]*/, myDelimiter );
106 cout << "Interpolate<1D> at " << Point << " yields " << T << endl;
107 return T;
108#else
110 interpolate(M, Point[0], M.Size()[0] /*Extension()[0]*/, myDelimiter );
111#endif
112 }
113
114 index_t size() const
115 {
116 return M.Size().maxidx();
117 }
118
119
120 Type eval() const
121 {
122 // printf("\nInterpolate<DerivativeDimension=%d> Eval\n", DerivativeDimension);
123
125 interpolate(M, Point[0], M.Size()[0] /*M.Extension()[0]*/, myDelimiter );
126 }
127};
128
129
133template <class Type, class Interpol, class CoordinateType, class Delimiter, int DerivativeDimension>
134struct Interpolate<2, Type, Interpol, CoordinateType, Delimiter, DerivativeDimension>
135{
136 enum { Dims = 2 };
137
138 typedef Type value_type;
141 typedef typename MultiArray_t::SliceStorage_t SliceStorage_t;
142
143private:
144 const MultiArray_t &M;
145 const Point_t &Point;
146
147public: Delimiter myDelimiter;
148
150 const Point_t &point)
151 : M(m), Point(point)
152 {}
153
155 const Point_t &point,
156 const Delimiter&myDeli)
157 : M(m), Point(point), myDelimiter(myDeli)
158 {}
159
160 Type operator[](index_t i) const
161 {
163
164 // printf("\nInterpolate<2D, DerivativeDimension=%d, Type=%s>: slice %d, at %lg\n",
165 // DerivativeDimension, typeid(Type).name(), i, double(Point[0]) );
166#if 0
168 interpolate(Sub, Point[0], M.Size()[0], myDelimiter );
169
170 cout << "Interpolate2D<" << typeid(Interpol).name() << "> at " << Point << " yields " << T << endl;
171 cout << " IArray " << M << endl;
172
173 return T;
174#else
176 interpolate(Sub, Point[0], M.Size()[0], myDelimiter );
177#endif
178 }
179
180 index_t size() const
181 {
182 return M.Size()[1];
183 }
184
185 Type eval() const
186 {
187// printf("\nInterpolate<DerivativeDimension=%d> Eval\n", DerivativeDimension);
188
190 interpolate(*this, Point[1], M.Size()[1], myDelimiter );
191 }
192};
193
275template <int N, class Type, class Interpol, class CoordinateType,
278{
279 enum { Dims = N };
280
281 typedef Type value_type;
283 typedef typename MultiArray_t::Hyperslab_t SliceStorage_t;
285 typedef FixedArray<CoordinateType, N-1> SubPoint_t;
286
287private:
288 const MultiArray<N, Type>&M;
289 const Point_t&Point;
290
291public: Delimiter myDelimiter;
292
293 const MultiArray<N, Type>&MArray()
294 {
295 return M;
296 }
297
298
305 const Point_t&point)
306 : M(m), Point(point)
307 {}
308
316 : M(m), Point(point.vec() )
317 {}
318
319 Interpolate(const MultiArray_t&m,
321 const Delimiter&myDeli)
322 : M(m), Point(point), myDelimiter(myDeli)
323 {}
324
325 Interpolate(const MultiArray_t&m,
327 const Delimiter&myDeli)
328 : M(m), Point(point.vec() ), myDelimiter(myDeli)
329 {}
330
331
337 Type operator[](index_t i) const
338 {
339 MultiArray <N-1, Type> Slice = M[i];
340
341 const SubPoint_t&subP = Point.get_subdim();
342
343 Interpolate<N-1, Type, Interpol, CoordinateType, Delimiter, DerivativeDimension>
344
345 LI( Slice, subP, myDelimiter );
346
347// printf("\nInterpolate<%dD (rec), DerivativeDimension=%d>: Slice %d\n", N, DerivativeDimension, i);
348
350 interpolate(LI, Point[N-2], M.Size()[N-2], this->myDelimiter );
351 }
352
353 index_t size() const
354 {
355 return M.Size()[N-1];
356 }
357
358 Type eval() const
359 {
360// printf("\nInterpolateN<DerivativeDimension=%d> Eval at %lg\n", DerivativeDimension, double(Point[N-1]) );
361 return IpolDerivative<Type, Interpol, N-1==DerivativeDimension>::
362 interpolate(*this, Point[N-1], M.Size()[N-1], myDelimiter );
363 }
364
365 Type operator()() const
366 {
367 return eval();
368 }
369};
370
371
372} /* namespace Fiber */
373
374#endif /* __FIBER_ARRAY_INTERPOLATE_HPP */
375
valarray< size_t > size() const
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
ostream cout
Vectorized vector.
Definition VVector.hpp:288
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Internal intermediate template which computes a one-dimensionally interpolated value,...
Definition Interpolate.hpp:32
Information per time slice, mainly a set of Grid objects that are accessed via GridID objects.
Definition Slice.hpp:36
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
IndexTypeConfig< sizeof(void *)>::index_t index_t
Define the index type as according to the size of a pointer, i.e.
Definition Index.hpp:22
The interpolator template.
Definition Interpolate.hpp:278
Type operator[](index_t i) const
Perform an interpolation along the dimension, i.e.
Definition Interpolate.hpp:337
Interpolate(const MultiArray_t &m, const Point_t &point)
Basic constructor.
Definition Interpolate.hpp:304
Interpolate(const MultiArray_t &m, const Eagle::VVector< N, CoordinateType > &point)
Convenience constructor which takes a vvectorized coordinate point.
Definition Interpolate.hpp:314