ESyS-Particle
4.0.1
|
00001 00002 // // 00003 // Copyright (c) 2003-2011 by The University of Queensland // 00004 // Earth Systems Science Computational Centre (ESSCC) // 00005 // http://www.uq.edu.au/esscc // 00006 // // 00007 // Primary Business: Brisbane, Queensland, Australia // 00008 // Licensed under the Open Software License version 3.0 // 00009 // http://www.opensource.org/licenses/osl-3.0.php // 00010 // // 00012 00013 00014 #ifndef ESYS_LSMCLOSEPACKITERATOR_H 00015 #define ESYS_LSMCLOSEPACKITERATOR_H 00016 00017 #include "Foundation/BoundingBox.h" 00018 #include "Foundation/vec3.h" 00019 #include "Geometry/Vec3L.h" 00020 #include "Geometry/ClosePackOrientation.h" 00021 00022 namespace esys 00023 { 00024 namespace lsm 00025 { 00026 template <int NI, int NJ, int NK> 00027 class TmplMatrix 00028 { 00029 public: 00030 TmplMatrix(); 00031 00032 TmplMatrix(const TmplMatrix &m); 00033 00034 TmplMatrix &operator=(const TmplMatrix &m); 00035 00036 const double &operator()(int i, int j, int k) const; 00037 00038 double &operator()(int i, int j, int k); 00039 00040 int getNumI() const; 00041 00042 int getNumJ() const; 00043 00044 int getNumK() const; 00045 00046 private: 00047 double m_matrix[NI][NJ][NK]; 00048 }; 00049 00054 class ClosePackIterator 00055 { 00056 public: 00057 static const double SQRT_1_OVER_3; 00058 static const double SQRT_8_OVER_3; 00059 static const double SQRT_3; 00060 00064 inline ClosePackIterator(); 00065 00075 inline ClosePackIterator( 00076 int numI, 00077 int numJ, 00078 int numK, 00079 double sphereRadius, 00080 ClosePackOrientation orientation = DEFAULT_ORIENT 00081 ); 00082 00087 inline bool hasNext() const; 00088 00092 inline Vec3 next(); 00093 00097 inline double getRadius() const; 00098 00099 protected: 00100 typedef TmplMatrix<3,6,6> OffsetMatrix; 00101 00102 inline void incrementDimIndex(); 00103 00104 inline double getOffset(int i) const; 00105 00106 inline const Vec3 &getMinPt() const; 00107 00108 inline void setMinPt(const Vec3 &pt) const; 00109 00110 inline void setDimRepeat(const Vec3L &dimRepeat); 00111 00112 inline void setOffsetMatrix(const OffsetMatrix &offsetMatrix); 00113 00114 private: 00115 static Vec3L s_orientationDimMap[NUM_ORIENTATIONS]; 00116 double m_radius; 00117 Vec3 m_minPt; 00118 OffsetMatrix m_offsetMatrix; 00119 Vec3L m_dimRepeat; 00120 Vec3L m_dimCount; 00121 Vec3L m_dimIdx; 00122 Vec3L m_dim; 00123 }; 00124 } 00125 } 00126 00127 #include "Geometry/ClosePackIterator.hpp" 00128 00129 #endif