FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
SkeletonID.hpp
1
2//
3// $Id: SkeletonID.hpp,v 1.4 2008/04/09 01:54:30 werner Exp $
4//
6#ifndef __FIBER_SKELETONID_HPP
7#define __FIBER_SKELETONID_HPP "Created 27.02.2001 21:42:27 by werner"
8
9#include "GridAPI.h"
10#include <fiber/field/DynamicSize.hpp>
11
12namespace Fiber
13{
14 using MemCore::WeakPtr;
15 using MemCore::NullPtr;
16
24{
25 int index_depth;
26 DynamicSize domainsize;
27 DynamicSize refinement;
28
29public:
33 explicit SkeletonID(int dimension, int index_depth=0);
34
35 explicit SkeletonID(const std::nullptr_t&);
36
38 : index_depth(IndexDepth)
39 , domainsize( theDomainSize )
40 , refinement( theRefinementSize )
41 {}
42
48
49private:
50 struct RefinementConstructorArg {};
51 struct RefinementCreationArg {};
52
53 SkeletonID(const RefinementConstructorArg&, const SkeletonID&Sid, int refinement_increment);
54 SkeletonID(const RefinementCreationArg&, const SkeletonID&Sid, int refinement_value);
55public:
56
59
63 const SkeletonID&ID() const
64 {
65 return *this;
66 }
67
72 {
73 return SkeletonID( RefinementConstructorArg(), Sid, refinement_increment);
74 }
75
80 {
81 return SkeletonID( RefinementCreationArg(), Sid, refinement_value);
82 }
83
84
86 bool operator<(const SkeletonID&S) const;
87
89 int IndexDepth() const
90 {
91 return index_depth;
92 }
93
95 const DynamicSize&DomainSize() const
96 {
97 return domainsize;
98 }
99
101 const DynamicSize&Size() const
102 {
103 return domainsize;
104 }
105
107 const DynamicSize&RefinementSize() const
108 {
109 return refinement;
110 }
111
113 const DynamicSize&getRefinementSize() const
114 {
115 return refinement;
116 }
117
118
119 template <class T>
120 DynamicSize&setSize(int N, const T values[])
121 {
122 return domainsize.setSize(N, values);
123 }
124
125 template <class T>
126 DynamicSize&setRefinementSize(int N, const T values[])
127 {
128 return refinement.setSize(N, values);
129 }
130
131 template <int N>
132 auto setSize(const MultiIndex<N>&I)
133 {
134 return domainsize.changeSize(I);
135 }
136
137 template <int N>
138 DynamicSize&setRefinementSize(const MultiIndex<N>&I)
139 {
140 return refinement.setSize(I);
141 }
142
144 int Dims() const
145 {
146 return domainsize.getRank();
147 }
148
150 int getRank() const
151 {
152 return domainsize.getRank();
153 }
154
155 bool hasCompatibleHigherDims(const DynamicSize&DS) const;
156
160 {
161 return refinement.getRank();
162 }
163
164 index_t Refinement(unsigned int i) const
165 {
166 return refinement[i];
167 }
168
174 {
175 for(int i=0; i<refinement.getRank(); i++)
176 {
177 if (refinement[i] != F)
178 return false;
179 }
180 return true;
181 }
182
190 {
191 if (refinement.getRank()<1)
192 return 0;
193
194 index_t L = refinement[0];
195 for(int i=1; i<refinement.getRank(); i++)
196 {
197 if (refinement[i] != L)
198 return -i;
199 }
200 return L;
201 }
202
203
204 index_t getTotalRefinement() const
205 {
207
208 for(int i=0; i<refinement.getRank(); i++)
209 {
210 TotalRefinement *= refinement[i];
211 }
212 return TotalRefinement;
213 }
214
215 unsigned getDomainSize(unsigned i) const
216 {
217 return unsigned( domainsize[i] );
218 }
219
221 bool setSize(unsigned i, index_t extension)
222 {
223 return domainsize.setSize( i, extension);
224 }
225
226 template <int N>
227 bool setSize(MultiIndex<N>&MI) const
228 {
229 return domainsize.setSize( MI );
230 }
231
232 bool setSize(const DynamicSize&DS) const
233 {
234 return domainsize.setSize( DS, 1 );
235 }
236
237 const DynamicSize&setRefinementSize(const DynamicSize&DS)
238 {
239 return refinement = DS;
240 }
241
243 bool setRefinement(unsigned i, index_t extension)
244 {
245 return refinement.setSize( i, extension);
246 }
247
252 {
253 for (auto i = 0; i < Dims(); ++i)
254 setRefinement( i, ref_level );
255 }
256
257 bool hasRefinement()
258 {
259 if( NumberOfRefinementLevels() > 1)
260 return true;
261
262 if( NumberOfRefinementLevels() == 1)
263 {
264 if( refinement[0] > 0 )
265 return true;
266 }
267 else
268 return false;
269
270 return false;
271 }
272
276 std::string Name() const;
277
278 // stream output operator
279 friend std::ostream&operator<<(std::ostream&os, const SkeletonID&SID)
280 {
281 os << "( depth: " << SID.IndexDepth() << ", dims: " << SID.Dims() << ", refs: " << SID.NumberOfRefinementLevels();
282
283 for(auto i = 0; i < SID.NumberOfRefinementLevels(); i++ )
284 os << ", ref[" << i << "]:" << SID.Refinement( i );
285
286 os << " )";
287
288 return os;
289 }
290
294 friend bool operator==(const SkeletonID&L, const SkeletonID&R)
295 {
296 if (L.IndexDepth() != R.IndexDepth())
297 return false;
298
299 if (L.domainsize.getRank() != R.domainsize.getRank())
300 return false;
301
302 if (L.refinement != R.refinement)
303 return false;
304
305 return true;
306 }
307
311 friend bool operator!=(const SkeletonID&L, const SkeletonID&R)
312 {
313 return !( L == R);
314 }
315
317 bool operator!() const;
318
320 operator bool() const
321 {
322 return !!*this;
323 }
324};
325
326
327} /* namespace Fiber */
328
329
330namespace std
331{
332
333inline string to_string(const Fiber::SkeletonID&SID)
334{
335 return "(dims=" + to_string(SID.Dims() )
336 + ", depth=" + to_string(SID.IndexDepth() )
337 + ", refinement=" + to_string( SID.RefinementSize())
338 + ")"
339 ;
340}
341
342} // namespace std
343
344#ifdef __MEMCORE_VERBOSE_HPP
345
346namespace MemCore
347{
348
349inline VerboseStream&operator<<(VerboseStream&VS, const Fiber::SkeletonID&ID)
350{
351 return VS << std::to_string(ID);
352}
353
354} // namespace MemCore
355
356#endif
357
358#endif /* __FIBER_SKELETONID_HPP */
basic_ostream< char > ostream
basic_string< char > string
bool operator<(const multimap< _Key, _Tp, _Compare, _Alloc > &__x, const multimap< _Key, _Tp, _Compare, _Alloc > &__y)
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
A class describing an n-dimensional space at runtime.
Definition field/DynamicSize.hpp:29
bool changeSize(const MultiIndex< N > &MI)
Adjust size for lowest matching dimensions.
Definition field/DynamicSize.hpp:291
DynamicSize & setSize(int N, const T values[])
Assign values from arbitrary type that is convertible into integers.
Definition field/DynamicSize.hpp:107
rank_t getRank() const
Dimensionality of the domain (same as rank).
Definition field/DynamicSize.hpp:220
Identifier for Skeletons within a Grid.
Definition SkeletonID.hpp:24
int NumberOfRefinementLevels() const
Number of available refinement levels This usually matches Dims, but in case of Dims=0 also allows a ...
Definition SkeletonID.hpp:159
int IndexDepth() const
Index depth of this skeleton.
Definition SkeletonID.hpp:89
index_t getHomogeneousLevel() const
IF this skeleton ID refers to a refinement level that is same in all dimensions, return that single i...
Definition SkeletonID.hpp:189
int Dims() const
Dimensionality of this skeleton.
Definition SkeletonID.hpp:144
bool isIsotropicRefinementFactor(index_t F) const
Check if the given skeleton ID corresponds to a refinement by factor F in all dimensions.
Definition SkeletonID.hpp:173
friend bool operator!=(const SkeletonID &L, const SkeletonID &R)
Check if two SkeletonIDs differ.
Definition SkeletonID.hpp:311
static SkeletonID nextRefinement(const SkeletonID &Sid, int refinement_increment)
Create a SkeletonID that is refined by a certain increment.
Definition SkeletonID.hpp:71
const SkeletonID & ID() const
Shortcut to ease type conversion in child classes.
Definition SkeletonID.hpp:63
friend bool operator==(const SkeletonID &L, const SkeletonID &R)
Check if SkeletonIDs are identical.
Definition SkeletonID.hpp:294
int getRank() const
Dimensionality of this skeleton.
Definition SkeletonID.hpp:150
void setIsotropicRefinement(index_t ref_level)
Set the same refinement level in all dimensions of the skeleton dimensionality.
Definition SkeletonID.hpp:251
static SkeletonID refinedSkeleton(const SkeletonID &Sid, int refinement_value)
Create a SkeletonID that is refined by a certain value.
Definition SkeletonID.hpp:79
Anemone_Context_t operator<<(Anemone &A, VRenderContext &VC)
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
std::nullptr_t NullPtr
std::string to_string(const span< char > &s)
STL namespace.
string to_string(const Eagle::FixedArray< ElementType, N > &A, const char *OpenBrace="{", const char *CloseBrace="}", const char *Separator=",")