ESyS-Particle  4.0.1
ClosePackBlock.hpp
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_LSMCLOSEPACKBLOCK_HPP
15 #define ESYS_LSMCLOSEPACKBLOCK_HPP
16 
17 #include "Geometry/ClosePackBlock.h"
18 #include "Geometry/ClosePackIterator.h"
19 
20 namespace esys
21 {
22  namespace lsm
23  {
24  template <typename TmplClosePackIterator,typename TmplParticle>
25  ClosePackBlockGenerator<TmplClosePackIterator,TmplParticle>::ClosePackBlockGenerator(
26  unsigned int numX,
27  unsigned int numY,
28  unsigned int numZ,
29  double radius,
30  ClosePackOrientation orientation
31  )
32  : m_radius(radius),
33  m_dimCounts(numX, numY, numZ),
34  m_orientation(orientation)
35  {
36  }
37 
38  template <typename TmplClosePackIterator,typename TmplParticle>
39  template <typename TmplParticleCollection>
40  void
41  ClosePackBlockGenerator<TmplClosePackIterator,TmplParticle>::createParticles(
42  TmplParticleCollection &particleCollection
43  )
44  {
45  int id = 0;
46  CentrePointIterator it =
47  CentrePointIterator(
48  m_dimCounts[0],
49  m_dimCounts[1],
50  m_dimCounts[2],
51  getRadius(),
52  ((m_orientation == DEFAULT_ORIENT) && (m_dimCounts[2] <= 1)) ? XYZ : m_orientation
53  );
54 
55  while (it.hasNext())
56  {
57  particleCollection.createParticle(
58  TmplParticle(
59  it.next(),
60  getRadius(),
61  id,
62  0
63  )
64  );
65  id++;
66  }
67  }
68 
69  template <typename TmplClosePackIterator,typename TmplParticle>
70  ClosePackBlockGenerator<TmplClosePackIterator,TmplParticle>::~ClosePackBlockGenerator()
71  {
72  }
73 
74  template <typename TmplClosePackIterator,typename TmplParticle>
75  double ClosePackBlockGenerator<TmplClosePackIterator,TmplParticle>::getRadius() const
76  {
77  return m_radius;
78  }
79 
80 
81 
82 
83 
84 
85 
86  template <typename TmplClosePackIterator,typename TmplParticle>
87  ClosePackBlock<TmplClosePackIterator,TmplParticle>::ClosePackBlock(
88  unsigned int numX,
89  unsigned int numY,
90  unsigned int numZ,
91  double radius,
92  ClosePackOrientation orientation
93  )
94  : ParticleCollection<TmplParticle>(),
95  m_generator(numX, numY, numZ, radius)
96  {
97  createParticles();
98  }
99 
100  template <typename TmplClosePackIterator,typename TmplParticle>
101  ClosePackBlock<TmplClosePackIterator,TmplParticle>::~ClosePackBlock()
102  {
103  }
104 
105  template <typename TmplClosePackIterator,typename TmplParticle>
106  void ClosePackBlock<TmplClosePackIterator,TmplParticle>::createParticles()
107  {
108  m_generator.createParticles(*this);
109  }
110 
111  template <typename TmplClosePackIterator,typename TmplParticle>
112  double ClosePackBlock<TmplClosePackIterator,TmplParticle>::getRadius() const
113  {
114  return m_generator.getRadius();
115  }
116  }
117 }
118 
119 #endif