ESyS-Particle  2.3.4
BoxPacker.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 #include "Geometry/GridIterator.h"
15 #include <float.h>
16 
17 namespace esys
18 {
19  namespace lsm
20  {
21  template <typename TmplPackerBase>
23  ParticlePoolPtr particlePoolPtr,
24  NTablePtr nTablePtr,
25  const BoundingBox &bBox,
26  const BoolVector &periodicDimensions,
27  double tolerance
28  ) : Inherited(particlePoolPtr, nTablePtr),
29  m_bBox(bBox),
30  m_periodicDimensions(periodicDimensions),
31  m_tolerance(tolerance)
32  {
33  }
34 
35  template <typename TmplPackerBase>
37  {
38  }
39 
40  template <typename TmplPackerBase>
42  {
43  return m_bBox;
44  }
45 
46  template <typename TmplPackerBase>
48  {
49  return m_tolerance;
50  }
51 
52  template <typename TmplPackerBase>
54  {
55  return ((getBBox().getMaxPt().Z() - getBBox().getMinPt().Z()) <= 0);
56  }
57 
58  template <typename TmplPackerBase>
59  const BoolVector &
61  {
62  return m_periodicDimensions;
63  }
64 
65  template <typename TmplPackerBase>
67  const Particle &particle
68  ) const
69  {
70  return
71  (
72  (
73  m_periodicDimensions[0]
74  ||
75  (
76  m_bBox.contains(
77  particle.getPos() - Vec3(particle.getRad(), 0, 0),
78  getTolerance()
79  )
80  &&
81  m_bBox.contains(
82  particle.getPos() + Vec3(particle.getRad(), 0, 0),
83  getTolerance()
84  )
85  )
86  )
87  &&
88  (
89  m_periodicDimensions[1]
90  ||
91  (
92  m_bBox.contains(
93  particle.getPos() - Vec3(0, particle.getRad(), 0),
94  getTolerance()
95  )
96  &&
97  m_bBox.contains(
98  particle.getPos() + Vec3(0, particle.getRad(), 0),
99  getTolerance()
100  )
101  )
102  )
103  &&
104  (
105  is2d() || m_periodicDimensions[2]
106  ||
107  (
108  m_bBox.contains(
109  particle.getPos() - Vec3(0, 0, particle.getRad()),
110  getTolerance()
111  )
112  &&
113  m_bBox.contains(
114  particle.getPos() + Vec3(0, 0, particle.getRad()),
115  getTolerance()
116  )
117  )
118  )
119  );
120  }
121 
122  template <typename TmplPackerBase>
124  const Particle &particle
125  ) const
126  {
127  const typename NTable::ParticleVector neighbours =
128  this->getNTable().getNeighbourVector(
129  particle.getPos(),
130  particle.getRad() + getTolerance()
131  );
132  typename NTable::ParticleVector::const_iterator iter = neighbours.begin();
133  for (; iter != neighbours.end(); iter++) {
134  const double interCentreDistSqrd =
135  (particle.getPos() - (*iter)->getPos()).norm2();
136  const double radiusSum =
137  ((particle.getRad() + (*iter)->getRad()) - getTolerance());
138  if (interCentreDistSqrd < (radiusSum*radiusSum)) {
139  return false;
140  }
141  }
142  return true;
143  }
144 
145  template <typename TmplPackerBase>
147  const Particle &particle
148  ) const
149  {
150  return
151  (
152  particleFitsInBBox(particle)
153  &&
154  particleFitsWithNeighbours(particle)
155  );
156  }
157  }
158 }
esys::lsm::BoxPacker::particleFitsInBBox
bool particleFitsInBBox(const Particle &particle) const
Definition: BoxPacker.hpp:66
GridIterator.h
esys::lsm::BoxPacker::particleFitsWithNeighbours
bool particleFitsWithNeighbours(const Particle &particle) const
Definition: BoxPacker.hpp:123
esys::lsm::BoxPacker::~BoxPacker
virtual ~BoxPacker()
Definition: BoxPacker.hpp:36
esys::lsm::BoxPacker::getTolerance
double getTolerance() const
Definition: BoxPacker.hpp:47
esys::lsm::BoxPacker::ParticlePoolPtr
Inherited::ParticlePoolPtr ParticlePoolPtr
Definition: BoxPacker.h:40
esys::lsm::BoxPacker::NTablePtr
Inherited::NTablePtr NTablePtr
Definition: BoxPacker.h:38
esys::lsm::BoxPacker::Particle
Inherited::Particle Particle
Definition: BoxPacker.h:36
esys::lsm::BoundingBox
3D bounding box
Definition: BoundingBox.h:28
esys
Definition: CheckPointable.cpp:17
esys::lsm::BoxPacker::getBBox
const BoundingBox & getBBox() const
Definition: BoxPacker.hpp:41
esys::lsm::BoxPacker::is2d
bool is2d() const
Definition: BoxPacker.hpp:53
esys::lsm::BoolVector
std::vector< bool > BoolVector
Definition: BlockGenerator.h:28
esys::lsm::BoxPacker::Inherited
TmplPackerBase Inherited
Definition: BoxPacker.h:35
Vec3
Definition: vec3.h:47
esys::lsm::bpu::iter
boost::python::object iter(const boost::python::object &pyOb)
Definition: Util.h:25
esys::lsm::BoxPacker::particleFitsInBBoxWithNeighbours
bool particleFitsInBBoxWithNeighbours(const Particle &particle) const
Definition: BoxPacker.hpp:146
esys::lsm::BoxPacker::getPeriodicDimensions
const BoolVector & getPeriodicDimensions() const
Definition: BoxPacker.hpp:60
ParticleVector
std::vector< SimpleParticle > ParticleVector
Definition: SimpleNTable3D.h:22
esys::lsm::BoxPacker::BoxPacker
BoxPacker(ParticlePoolPtr particlePoolPtr, NTablePtr nTablePtr, const BoundingBox &bBox, const BoolVector &periodicDimensions, double tolerance)
Definition: BoxPacker.hpp:22
getBBox
BoundingBox getBBox(const std::string &arg)
Definition: Main.cpp:24