14 #include "Geometry/GridIterator.h"
21 template <
typename TmplPackerBase>
22 BoxPacker<TmplPackerBase>::BoxPacker(
23 ParticlePoolPtr particlePoolPtr,
25 const BoundingBox &bBox,
26 const BoolVector &periodicDimensions,
28 ) : Inherited(particlePoolPtr, nTablePtr),
30 m_periodicDimensions(periodicDimensions),
31 m_tolerance(tolerance)
35 template <
typename TmplPackerBase>
36 BoxPacker<TmplPackerBase>::~BoxPacker()
40 template <
typename TmplPackerBase>
41 const BoundingBox &BoxPacker<TmplPackerBase>::getBBox()
const
46 template <
typename TmplPackerBase>
47 double BoxPacker<TmplPackerBase>::getTolerance()
const
52 template <
typename TmplPackerBase>
53 bool BoxPacker<TmplPackerBase>::is2d()
const
55 return ((getBBox().getMaxPt().Z() - getBBox().getMinPt().Z()) <= 0);
58 template <
typename TmplPackerBase>
60 BoxPacker<TmplPackerBase>::getPeriodicDimensions()
const
62 return m_periodicDimensions;
65 template <
typename TmplPackerBase>
66 bool BoxPacker<TmplPackerBase>::particleFitsInBBox(
67 const Particle &particle
73 m_periodicDimensions[0]
77 particle.getPos() -
Vec3(particle.getRad(), 0, 0),
82 particle.getPos() +
Vec3(particle.getRad(), 0, 0),
89 m_periodicDimensions[1]
93 particle.getPos() -
Vec3(0, particle.getRad(), 0),
98 particle.getPos() +
Vec3(0, particle.getRad(), 0),
105 is2d() || m_periodicDimensions[2]
109 particle.getPos() -
Vec3(0, 0, particle.getRad()),
114 particle.getPos() +
Vec3(0, 0, particle.getRad()),
122 template <
typename TmplPackerBase>
123 bool BoxPacker<TmplPackerBase>::particleFitsWithNeighbours(
124 const Particle &particle
127 const typename NTable::ParticleVector neighbours =
128 this->getNTable().getNeighbourVector(
130 particle.getRad() + getTolerance()
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)) {
145 template <
typename TmplPackerBase>
146 bool BoxPacker<TmplPackerBase>::particleFitsInBBoxWithNeighbours(
147 const Particle &particle
152 particleFitsInBBox(particle)
154 particleFitsWithNeighbours(particle)