Blockstructured Adaptive Mesh Refinement in object-oriented C++
00001 #ifndef _included_sfcIndex_h 00002 #define _included_sfcIndex_h 00003 00009 #include "BitVec.h" 00010 #include <math.h> 00011 00012 #include "DAGHDefaults.h" 00013 00014 #ifndef sfcBase 00015 #define sfcBase (2) 00016 #endif 00017 00028 class sfcIndex : public BitVec 00029 { 00030 friend ostream& operator<<(ostream&, sfcIndex const &); 00031 00032 short int sfcbasew; 00033 short int sfcdigitw; 00034 00035 protected: 00036 short int sfcbase; 00037 short int sfcdim; 00038 short int sfclevs; 00039 00040 public: 00041 inline sfcIndex() 00042 : BitVec(), 00043 sfcbasew(0), sfcdigitw(0), 00044 sfcbase(0), sfcdim(0), sfclevs(0) 00045 {} 00046 00047 inline sfcIndex(const int dim, const int levs, 00048 const int base = sfcBase) 00049 : BitVec(levs*dim*(int)ceil(log((double)base)/log((double)2.0))), 00050 sfcbase(base), sfcdim(dim), sfclevs(levs) 00051 { sfcbasew = (int)ceil(log((double)base)/log((double)2.0)); 00052 sfcdigitw = sfcdim*sfcbasew; } 00053 00054 inline sfcIndex(sfcIndex const &other) 00055 : BitVec((BitVec const &)other), 00056 sfcbasew(other.sfcbasew), sfcdigitw(other.sfcdigitw), 00057 sfcbase(other.sfcbase), sfcdim(other.sfcdim), 00058 sfclevs(other.sfclevs) 00059 {} 00060 00062 sfcIndex const &operator= (sfcIndex const &other); 00063 00064 int operator== (sfcIndex const &other) const; 00065 int operator!= (sfcIndex const &other) const; 00066 int operator> (sfcIndex const &other) const; 00067 int operator< (sfcIndex const &other) const; 00068 int operator>= (sfcIndex const &other) const; 00069 int operator<= (sfcIndex const &other) const; 00070 00071 /* Operations on digits; i.e. (sfcdim*sfcbasew) bits */ 00075 int sfcGetDigit(const int level) const; 00077 void sfcSetDigit(const int level, const int digit); 00079 void sfcUnsetDigit(const int level); 00081 void sfcMaxDigit(const int level); 00082 00083 /* Operations on base sfcbase words (sfcbasew bits) within a digit */ 00086 void sfcSwapDigitWd(const int level, const int pos1, const int pos2); 00088 void sfcToggleDigitWd(const int level, const int pos); 00089 00090 /* Operations on the sfcIndex */ 00092 int sfcGetIndex() const; 00094 int sfcGetIndex(const int lev) const; 00096 int sfcGetIndex(const int lev, const int nlev) const; 00097 00099 void sfcSetIndex(const int index); 00101 void sfcSetIndex(const int index, const int lev); 00103 void sfcSetIndex(const int index, const int lev, const int nlev); 00104 void sfcMaxIndex(const int lev); 00105 00106 /* Mapping, inverse mapping routines */ 00108 void sfcCreateLocNum(const int *coords); 00110 void sfcGetCoords(int *coords) const; 00112 void sfcGetDigitArray(int *digits) const; 00113 00115 inline int sfcGetBaseW(void) const 00116 {return sfcbasew;} 00117 inline int sfcGetDigitW(void) const 00118 {return sfcdigitw;} 00119 00120 private: 00121 inline void sfcSetDigitBit(const int level, const int pos) 00122 { SetBit((level-1)*sfcdigitw + pos); } 00123 inline void sfcUnsetDigitBit(const int level, const int pos) 00124 { UnsetBit((level-1)*sfcdigitw + pos); } 00125 inline void sfcToggleDigitBit(const int level, const int pos) 00126 { ToggleBit((level-1)*sfcdigitw + pos); } 00127 00128 }; 00129 00130 extern ostream& operator << (ostream& os, sfcIndex const &si); 00131 00132 #endif
Quickstart Users Guide Programmers Reference Installation Examples Download
AMROC Main Home Contactlast update: 06/01/04