ESyS-Particle  2.3.2
CubicBoxPacker.hpp
Go to the documentation of this file.
1 
2 // //
3 // Copyright (c) 2003-2014 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.opensource.org/licenses/osl-3.0.php //
10 // //
12 
13 
14 namespace esys
15 {
16  namespace lsm
17  {
18  template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
20  ParticleGeneratorPtr particleGeneratorPtr,
21  ParticlePoolPtr particlePoolPtr,
22  NTablePtr nTablePtr,
23  const BoundingBox &bBox,
24  const BoolVector &periodicDimensions,
25  double tolerance,
26  double cubicPackRadius
27  ) : Inherited(
28  particlePoolPtr,
29  nTablePtr,
30  bBox,
31  periodicDimensions,
32  tolerance
33  ),
34  m_cubicPackRadius(cubicPackRadius),
35  m_particleGeneratorPtr(particleGeneratorPtr),
36  m_pParticleGenerator(particleGeneratorPtr.get())
37  {
38  }
39 
40  template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
42  {
43  }
44 
45  template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
48  {
49  return *m_pParticleGenerator;
50  }
51 
52  template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
55  {
56  return *m_pParticleGenerator;
57  }
58 
59  template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
60  void
62  ParticleGenerator &particleGenerator
63  )
64  {
65  m_pParticleGenerator = &particleGenerator;
66  m_particleGeneratorPtr = ParticleGeneratorPtr();
67  }
68 
69  template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
70  void
72  ParticleGeneratorPtr particleGeneratorPtr
73  )
74  {
75  m_particleGeneratorPtr = particleGeneratorPtr;
76  m_pParticleGenerator = m_particleGeneratorPtr.get();
77  }
78 
79  template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
80  double
82  {
83  return m_cubicPackRadius;
84  }
85 
86  template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
89  const Vec3 &point,
90  double radius
91  )
92  {
93  return getParticleGenerator().getParticle(point, radius);
94  }
95 
96  template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
99  const Vec3 &point
100  )
101  {
102  return getParticleGenerator().getParticle(point);
103  }
104 
105  template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
106  void
108  {
109  GridIterator pointIt = GridIterator(this->getBBox(), getCubicPackingRadius());
110  while (pointIt.hasNext()) {
111  const Particle candidate =
112  getCandidateParticle(pointIt.next(), getCubicPackingRadius());
113  if (this->particleFitsInBBoxWithNeighbours(candidate)) {
114  this->createAndInsertParticle(candidate);
115  }
116  }
117  }
118 
119  template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
120  void
122  {
123  generateCubicPacking();
124  }
125  }
126 }