Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)

app-bholger/gfem/gfemDofIteratorFast.h
Go to the documentation of this file.
00001 #pragma once
00002 
00003 #include <algorithm>
00004 #include <assert.h>
00005 #include "gfemOverlapCondition.h"
00006 #include "unitcell.h"
00007 #include "hp2D/quadFunctions.hh"
00008 
00009 namespace concepts {
00010 namespace gfem {
00011 
00012 struct GfemDofIteratorFast 
00013 {
00014   GfemDofIteratorFast(const GfemOverlapCondition& overC, const Unitcell& uc
00015       , const int p_macro[2])
00016     : overC(overC)
00017     , uc(uc)
00018     , i_t(0)
00019     , i_macroX(0)
00020     , i_macroY(0)
00021     , i_micro(0)
00022   { 
00023     this->p_macro[0] = p_macro[0];
00024     this->p_macro[1] = p_macro[1];
00025   }
00026 
00027   void print() const;
00028 
00030   GfemDofIteratorFast& operator++() 
00031   {
00032     #if 0
00033     ++i_macroY;
00034     if(i_macroY > nMacroY()) {
00035       i_macroY = 0;
00036       ++i_macroX;
00037       if(i_macroX > nMacroX()) {
00038         i_macroX = 0;
00039       }
00040     }
00041     #endif
00042 
00043     ++i_t;
00044     update(i_t);
00045 
00046     return *this;
00047   }
00048 
00053   void updateLdof(int i_micro, int i_macroX, int i_macroY) {
00054     int i_macro = i_macroY * nMacroX() + i_macroX;
00055     i_t = i_macro * numUC() + i_micro;
00056 
00057     //assert(i_t <= nDofs());
00058   }
00059 
00060   void updateLdof(int i_vert) {
00061     i_t = overC.disabledVertDof(i_vert);
00062   }
00063 
00070   void updateLdof(int i_edge, int i_shape) {
00071     assert(i_shape < overC.edgeDofs(i_edge) );
00072 
00073     i_t = overC.nVertDofs();
00074 
00075     for(int i=0; i < i_edge; ++i)
00076       if(overC.edgeDisabled(i))
00077         i_t += overC.edgeDofs(i);
00078 
00079     i_t += i_shape;
00080   }
00081 
00082   bool update(int i_t) {
00083     this->i_t = i_t;
00084 #if 0
00085     if(i_t < overC.nDofs()) {
00086       i_micro = i_t;
00087       i_macroX = -1;
00088       i_macroY = -1;
00089 
00090       return true;
00091     }
00092     i_t -= overC.nDofs();
00093 #endif
00094 
00095     int i_macro = i_t / numUC();
00096     i_micro = i_t % numUC();
00097 
00098     i_macroY = i_macro / nMacroX();
00099     i_macroX = i_macro % nMacroX();
00100 
00101     assert(i_macroX >= 0);
00102     assert(i_macroY >= 0);
00103 
00104     return i_macroY < nMacroY(); 
00105   }
00106 
00107   void updateVertMacro(int i_vert) 
00108   {
00109     uint ll[2];
00110     hp2D::QuadFunctions::vertexIndex(i_vert, ll);
00111 
00112     i_macroX = ll[0];
00113     i_macroY = ll[1];
00114   }
00115  
00116   void updateEdgeMacro(int i_edge, int i_t) 
00117   {
00118     uint pIndex = 0, qIndex = 0;
00119     uint ll[2];
00120     hp2D::QuadFunctions::edgeOrientation(i_edge, pIndex, qIndex);
00121     hp2D::QuadFunctions::edgeIndex(i_edge, qIndex, ll);
00122 
00123     ll[pIndex] = i_t + 2;
00124 
00125     i_macroX = ll[0];
00126     i_macroY = ll[1];
00127   }
00128  
00129   void setPMax(int p_max[2]) {
00130     p_macro[0] = p_max[0];
00131     p_macro[1] = p_max[1];
00132   }
00133 
00134   int numUC() const {
00135     return uc.size();
00136   }
00137 
00138   int nMicro() const {
00139     return numUC();
00140   }
00141   int pMacroX() const {
00142     return p_macro[0];
00143   }
00144 
00145   int pMacroY() const {
00146     return p_macro[1];
00147   }
00148 
00149   int nMacroX() const {
00150     return p_macro[0]+1;
00151   }
00152 
00153   int nMacroY() const {
00154     return p_macro[1]+1;
00155   }
00156 
00157   bool isFinished() const {
00158     return i_t >= numLdofs();
00159   }
00160 
00161   int nDofs() const {
00162     return numLdofs();
00163   }
00164 
00165   int numLdofs() const {
00166     return nMacroX() * nMacroY() * numUC();
00167   }
00168 
00169 //private:
00170   
00171   const GfemOverlapCondition& overC;
00172   const Unitcell& uc;
00173   int i_t;
00174   int i_macroX;
00175   int i_macroY;
00176   int i_micro;
00177   int p_macro[2];
00178 };
00179 
00180 } // namespace
00181 } // namespace

Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)