ESyS-Particle  2.3.4
CubicBoxPacker.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 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 }
esys::lsm::CubicBoxPacker::ParticlePoolPtr
Inherited::ParticlePoolPtr ParticlePoolPtr
Definition: CubicBoxPacker.h:39
esys::lsm::CubicBoxPacker::generate
virtual void generate()
Definition: CubicBoxPacker.hpp:121
esys::lsm::CubicBoxPacker::Inherited
TmplBoxPackerBase Inherited
Definition: CubicBoxPacker.h:33
esys::lsm::CubicBoxPacker::generateCubicPacking
void generateCubicPacking()
Definition: CubicBoxPacker.hpp:107
esys::lsm::BoundingBox
3D bounding box
Definition: BoundingBox.h:28
esys
Definition: CheckPointable.cpp:17
esys::lsm::CubicBoxPacker::ParticleGenerator
TmplParticleGenerator ParticleGenerator
Definition: CubicBoxPacker.h:31
esys::lsm::CubicBoxPacker::getCandidateParticle
Particle getCandidateParticle(const Vec3 &point)
Definition: CubicBoxPacker.hpp:98
esys::lsm::CubicBoxPacker::setParticleGenerator
void setParticleGenerator(ParticleGenerator &particleGenerator)
Definition: CubicBoxPacker.hpp:61
esys::lsm::CubicBoxPacker::getCubicPackingRadius
double getCubicPackingRadius() const
Definition: CubicBoxPacker.hpp:81
esys::lsm::CubicBoxPacker::~CubicBoxPacker
virtual ~CubicBoxPacker()
Definition: CubicBoxPacker.hpp:41
esys::lsm::CubicBoxPacker::getParticleGenerator
const ParticleGenerator & getParticleGenerator() const
Definition: CubicBoxPacker.hpp:47
esys::lsm::BoolVector
std::vector< bool > BoolVector
Definition: BlockGenerator.h:28
esys::lsm::CubicBoxPacker::ParticleGeneratorPtr
boost::shared_ptr< ParticleGenerator > ParticleGeneratorPtr
Definition: CubicBoxPacker.h:32
Vec3
Definition: vec3.h:47
esys::lsm::CubicBoxPacker::CubicBoxPacker
CubicBoxPacker(ParticleGeneratorPtr particleGeneratorPtr, ParticlePoolPtr particlePoolPtr, NTablePtr nTablePtr, const BoundingBox &bBox, const BoolVector &periodicDimensions, double tolerance, double cubicPackRadius)
Definition: CubicBoxPacker.hpp:19
esys::lsm::CubicBoxPacker::NTablePtr
Inherited::NTablePtr NTablePtr
Definition: CubicBoxPacker.h:37
esys::lsm::GridIterator::hasNext
bool hasNext() const
Definition: GridIterator.h:207
esys::lsm::CubicBoxPacker::Particle
Inherited::Particle Particle
Definition: CubicBoxPacker.h:35
esys::lsm::GridIterator::next
Vec3 next()
Definition: GridIterator.h:255
getBBox
BoundingBox getBBox(const std::string &arg)
Definition: Main.cpp:24
esys::lsm::GridIterator
Definition: GridIterator.h:29