Blockstructured Adaptive Mesh Refinement in object-oriented C++
00001 #ifndef _included_PeanoHilbert_h 00002 #define _included_PeanoHilbert_h 00003 00008 #include "sfcIndex.h" 00009 00010 #ifndef PeanoHibertBase 00011 #define PeanoHibertBase (2) 00012 #endif 00013 00021 class PeanoHilbert : public sfcIndex 00022 { 00023 00024 public: 00025 00027 inline PeanoHilbert() 00028 : sfcIndex() {} 00029 00031 inline PeanoHilbert(const int dim, const int levs) 00032 : sfcIndex(dim,levs,PeanoHibertBase) 00033 {assert(dim<=3);} 00034 00036 inline PeanoHilbert(PeanoHilbert const &other) 00037 : sfcIndex((sfcIndex const &)other) {} 00038 00040 private: 00041 void Invert(int *coords) const; 00042 00043 public: 00044 inline void SetIndex(const int index, const int idxlev) 00045 { sfcSetIndex(index,idxlev); } 00046 inline void SetIndex(const int index, const int idxlev, 00047 const int nlev) 00048 { sfcSetIndex(index,idxlev,nlev); } 00049 00051 void Map(const int *coords); 00053 void Invert(int *coords, const int index); 00055 void Invert(int *coords, const int index, const int idxlev); 00057 void Invert(int *coords, const int index, 00058 const int idxlev, const int nlev); 00059 00063 PeanoHilbert *GetBox(const int lev, const int nlev) const; 00064 void SetBox(const int lev, const int nlev); 00065 00067 PeanoHilbert *GetMax(const int lev, const int nlev) const; 00068 void SetMax(const int lev, const int nlev); 00069 00071 void ResetBase(const int lev, const int nlev); 00072 00073 /* Query routines */ 00075 void GetCoords(int *coords, const int lev = 1) const; 00076 int *GetCoords(const int lev = 1) const; 00077 00079 inline int GetCardinality(const int dim, const int lev) const 00080 {return (int)1<<(lev*dim);} 00081 inline int GetCardinality(const int lev) const 00082 {return (int)1<<(lev*sfcdim);} 00083 00085 inline int GetDimCardinality(const int lev) const 00086 {return (int)1<<(sfclevs-lev);} 00087 00089 inline int GetDimMax(const int lev) const 00090 {return (((int)1<<lev)-1)*((int)1<<(sfclevs-lev));} 00091 00092 private: 00093 00094 /* 00095 // The following operations are used to orient the seed 00096 // curve as required. The seed curve is "->" 00097 // Axis are numbered as follows: 00098 // "->" x: 1 00099 // "|" y: 2 00100 // "/" z: 3 00101 // Directions are numbered as follows: 00102 // "->" (positive x): 1 00103 // "|" (positive y): 2 00104 // "/" (positive z): 3 00105 // phSwapDir ->(PH) = <-(PH) 00106 // phTranslate ->(PH) = (PH)-> 00107 // phRotate ->(PH) (1,2) = |(PH) 00108 // phRotate ->(PH) (1,3) = /(PH) 00109 // phRotate |(PH) (2,1) = ->(PH) 00110 // phRotate /(PH) (3,1) = ->(PH) 00111 // Note: 00112 // (1) "phRotate" is valid to/from the seed orientation only ! 00113 // i.e. "to" or "from" should be "->" or 1. 00114 // (2) Bit are numbered from 0 to DIM-1 such that the msb is 0 and 00115 // the lsb is Dim-1. 00116 // i.e. x = xb0 xb1 xb2 xb3 ... xbDIM-1 00117 */ 00118 00119 inline void phSwapDir(const int level, const int axis) 00120 {sfcToggleDigitWd(level,axis-1);} 00121 inline void phTranslate(const int level, const int axis) 00122 {sfcToggleDigitWd(level,axis-1);} 00123 inline void phRotate(const int level, const int from_axis, 00124 const int to_axis) 00125 {sfcSwapDigitWd(level,from_axis-1,to_axis-1);} 00126 00128 void phOrient(const int level, const int pos); 00130 int phGray(const int level); 00131 int phGinv(const int level); 00132 00133 }; 00134 00135 #endif
Quickstart Users Guide Programmers Reference Installation Examples Download
AMROC Main Home Contactlast update: 06/01/04