ESyS-Particle  4.0.1
ClosePackIterator.h
1 
2 // //
3 // Copyright (c) 2003-2011 by The University of Queensland //
4 // Earth Systems Science Computational Centre (ESSCC) //
5 // http://www.uq.edu.au/esscc //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.opensource.org/licenses/osl-3.0.php //
10 // //
12 
13 
14 #ifndef ESYS_LSMCLOSEPACKITERATOR_H
15 #define ESYS_LSMCLOSEPACKITERATOR_H
16 
17 #include "Foundation/BoundingBox.h"
18 #include "Foundation/vec3.h"
19 #include "Geometry/Vec3L.h"
20 #include "Geometry/ClosePackOrientation.h"
21 
22 namespace esys
23 {
24  namespace lsm
25  {
26  template <int NI, int NJ, int NK>
27  class TmplMatrix
28  {
29  public:
30  TmplMatrix();
31 
32  TmplMatrix(const TmplMatrix &m);
33 
34  TmplMatrix &operator=(const TmplMatrix &m);
35 
36  const double &operator()(int i, int j, int k) const;
37 
38  double &operator()(int i, int j, int k);
39 
40  int getNumI() const;
41 
42  int getNumJ() const;
43 
44  int getNumK() const;
45 
46  private:
47  double m_matrix[NI][NJ][NK];
48  };
49 
55  {
56  public:
57  static const double SQRT_1_OVER_3;
58  static const double SQRT_8_OVER_3;
59  static const double SQRT_3;
60 
64  inline ClosePackIterator();
65 
75  inline ClosePackIterator(
76  int numI,
77  int numJ,
78  int numK,
79  double sphereRadius,
80  ClosePackOrientation orientation = DEFAULT_ORIENT
81  );
82 
87  inline bool hasNext() const;
88 
92  inline Vec3 next();
93 
97  inline double getRadius() const;
98 
99  protected:
101 
102  inline void incrementDimIndex();
103 
104  inline double getOffset(int i) const;
105 
106  inline const Vec3 &getMinPt() const;
107 
108  inline void setMinPt(const Vec3 &pt) const;
109 
110  inline void setDimRepeat(const Vec3L &dimRepeat);
111 
112  inline void setOffsetMatrix(const OffsetMatrix &offsetMatrix);
113 
114  private:
115  static Vec3L s_orientationDimMap[NUM_ORIENTATIONS];
116  double m_radius;
117  Vec3 m_minPt;
118  OffsetMatrix m_offsetMatrix;
119  Vec3L m_dimRepeat;
120  Vec3L m_dimCount;
121  Vec3L m_dimIdx;
122  Vec3L m_dim;
123  };
124  }
125 }
126 
127 #include "Geometry/ClosePackIterator.hpp"
128 
129 #endif