ESyS-Particle  2.3.4
ClosePackIterator.hpp
Go to the documentation of this file.
1 // //
3 // Copyright (c) 2003-2017 by The University of Queensland //
4 // Centre for Geoscience Computing //
5 // http://earth.uq.edu.au/centre-geoscience-computing //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.apache.org/licenses/LICENSE-2.0 //
10 // //
12 
13 
14 #ifndef ESYS_LSMCLOSEPACKITERATOR_HPP
15 #define ESYS_LSMCLOSEPACKITERATOR_HPP
16 
17 namespace esys
18 {
19  namespace lsm
20  {
21  template <int NI, int NJ, int NK>
23  {
24  for (int i = 0; i < NI; i++)
25  {
26  for (int j = 0; j < NJ; j++)
27  {
28  for (int k = 0; k < NJ; k++)
29  {
30  m_matrix[i][j][k] = 0.0;
31  }
32  }
33  }
34  }
35 
36  template <int NI, int NJ, int NK>
38  {
39  for (int i = 0; i < NI; i++)
40  {
41  for (int j = 0; j < NJ; j++)
42  {
43  for (int k = 0; k < NJ; k++)
44  {
45  m_matrix[i][j][k] = m(i,j,k);
46  }
47  }
48  }
49  }
50 
51  template <int NI, int NJ, int NK>
52  TmplMatrix<NI,NJ,NK> &
53  TmplMatrix<NI,NJ,NK>::TmplMatrix::operator=(const TmplMatrix &m)
54  {
55  for (int i = 0; i < NI; i++)
56  {
57  for (int j = 0; j < NJ; j++)
58  {
59  for (int k = 0; k < NJ; k++)
60  {
61  m_matrix[i][j][k] = m(i,j,k);
62  }
63  }
64  }
65  return *this;
66  }
67 
68  template <int NI, int NJ, int NK>
69  const double &TmplMatrix<NI,NJ,NK>::operator()(int i, int j, int k) const
70  {
71  return m_matrix[i][j][k];
72  }
73 
74  template <int NI, int NJ, int NK>
75  double &TmplMatrix<NI,NJ,NK>::operator()(int i, int j, int k)
76  {
77  return m_matrix[i][j][k];
78  }
79 
80  template <int NI, int NJ, int NK>
82  {
83  return NI;
84  }
85 
86  template <int NI, int NJ, int NK>
88  {
89  return NJ;
90  }
91 
92  template <int NI, int NJ, int NK>
94  {
95  return NK;
96  }
97 
99  : m_radius(),
100  m_minPt(),
101  m_offsetMatrix(),
102  m_dimRepeat(),
103  m_dimCount(),
104  m_dimIdx(),
105  m_dim()
106  {
107  }
108 
110  int numI,
111  int numJ,
112  int numK,
113  double sphereRadius,
114  ClosePackOrientation orientation
115  )
116  : m_radius(sphereRadius),
117  m_minPt(),
118  m_offsetMatrix(),
119  m_dimRepeat(),
120  m_dimCount(numI, numJ, numK),
121  m_dimIdx(),
122  m_dim(s_orientationDimMap[orientation])
123  {
124  for (int i = 0; i < 3; i++)
125  {
126  if (m_dimCount[i] <= 0)
127  {
128  m_dimCount[i] = 1;
129  }
130  }
131  }
132 
133  void ClosePackIterator::setDimRepeat(const Vec3L &dimRepeat)
134  {
135  m_dimRepeat = dimRepeat;
136  }
137 
139  {
140  m_offsetMatrix = offsetMatrix;
141  }
142 
144  {
145  return m_radius;
146  }
147 
149  {
150  return (m_dimIdx[2] < m_dimCount[2]);
151  }
152 
154  {
155  return m_minPt;
156  }
157 
158  double ClosePackIterator::getOffset(int i) const
159  {
160  return
162  i,
163  (m_dimIdx[(i+1) % 3]) % m_dimRepeat[i],
164  (m_dimIdx[(i+2) % 3]) % m_dimRepeat[i]
165  );
166  }
167 
169  {
170  (m_dimIdx[0])++;
171  if (m_dimIdx[0] >= m_dimCount[0])
172  {
173  m_dimIdx[0] = 0;
174  (m_dimIdx[1])++;
175  if (m_dimIdx[1] >= m_dimCount[1])
176  {
177  m_dimIdx[1] = 0;
178  (m_dimIdx[2])++;
179  }
180  }
181  }
182 
184  {
185  Vec3 centre;
186  centre[m_dim[0]] = getOffset(0) + m_dimIdx[0]*(m_radius*2.0);
187  centre[m_dim[1]] = getOffset(1) + m_dimIdx[1]*(m_radius*SQRT_3);
188  centre[m_dim[2]] = getOffset(2) + m_dimIdx[2]*(m_radius*SQRT_8_OVER_3);
190  return (getMinPt() + centre);
191  }
192  }
193 }
194 
195 #endif
esys::lsm::ClosePackIterator::getMinPt
const Vec3 & getMinPt() const
Definition: ClosePackIterator.hpp:153
esys::lsm::TmplMatrix::getNumI
int getNumI() const
Definition: ClosePackIterator.hpp:81
esys::lsm::ClosePackIterator::ClosePackIterator
ClosePackIterator()
Definition: ClosePackIterator.hpp:98
esys::lsm::ClosePackIterator::m_radius
double m_radius
Definition: ClosePackIterator.h:116
esys::lsm::TmplMatrix::getNumJ
int getNumJ() const
Definition: ClosePackIterator.hpp:87
esys::lsm::ClosePackIterator::hasNext
bool hasNext() const
Definition: ClosePackIterator.hpp:148
esys
Definition: CheckPointable.cpp:17
esys::lsm::ClosePackIterator::SQRT_3
static const double SQRT_3
Definition: ClosePackIterator.h:59
esys::lsm::TmplMatrix::operator()
const double & operator()(int i, int j, int k) const
Definition: ClosePackIterator.hpp:69
esys::lsm::ClosePackIterator::incrementDimIndex
void incrementDimIndex()
Definition: ClosePackIterator.hpp:168
esys::lsm::ClosePackIterator::m_minPt
Vec3 m_minPt
Definition: ClosePackIterator.h:117
esys::lsm::ClosePackIterator::setOffsetMatrix
void setOffsetMatrix(const OffsetMatrix &offsetMatrix)
Definition: ClosePackIterator.hpp:138
esys::lsm::ClosePackIterator::m_dimCount
Vec3L m_dimCount
Definition: ClosePackIterator.h:120
esys::lsm::ClosePackIterator::getRadius
double getRadius() const
Definition: ClosePackIterator.hpp:143
Vec3
Definition: vec3.h:47
esys::lsm::TmplMatrix::getNumK
int getNumK() const
Definition: ClosePackIterator.hpp:93
esys::lsm::ClosePackIterator::next
Vec3 next()
Definition: ClosePackIterator.hpp:183
esys::lsm::ClosePackIterator::setDimRepeat
void setDimRepeat(const Vec3L &dimRepeat)
Definition: ClosePackIterator.hpp:133
esys::lsm::ClosePackIterator::m_dimIdx
Vec3L m_dimIdx
Definition: ClosePackIterator.h:121
esys::lsm::TmplMatrix::TmplMatrix
TmplMatrix()
Definition: ClosePackIterator.hpp:22
esys::lsm::ClosePackIterator::SQRT_8_OVER_3
static const double SQRT_8_OVER_3
Definition: ClosePackIterator.h:58
esys::lsm::ClosePackIterator::m_dim
Vec3L m_dim
Definition: ClosePackIterator.h:122
esys::lsm::Vec3L
Definition: Vec3L.h:29
esys::lsm::ClosePackOrientation
ClosePackOrientation
Definition: ClosePackOrientation.h:26
esys::lsm::ClosePackIterator::m_dimRepeat
Vec3L m_dimRepeat
Definition: ClosePackIterator.h:119
esys::lsm::ClosePackIterator::m_offsetMatrix
OffsetMatrix m_offsetMatrix
Definition: ClosePackIterator.h:118
esys::lsm::TmplMatrix
Definition: ClosePackIterator.h:28
esys::lsm::ClosePackIterator::getOffset
double getOffset(int i) const
Definition: ClosePackIterator.hpp:158