1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
/////////////////////////////////////////////////////////////
// //
// Copyright (c) 2003-2011 by The University of Queensland //
// Earth Systems Science Computational Centre (ESSCC) //
// http://www.uq.edu.au/esscc //
// //
// Primary Business: Brisbane, Queensland, Australia //
// Licensed under the Open Software License version 3.0 //
// http://www.opensource.org/licenses/osl-3.0.php //
// //
/////////////////////////////////////////////////////////////
namespace esys
{
namespace lsm
{
template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::CubicBoxPacker(
ParticleGeneratorPtr particleGeneratorPtr,
ParticlePoolPtr particlePoolPtr,
NTablePtr nTablePtr,
const BoundingBox &bBox,
const BoolVector &periodicDimensions,
double tolerance,
double cubicPackRadius
) : Inherited(
particlePoolPtr,
nTablePtr,
bBox,
periodicDimensions,
tolerance
),
m_cubicPackRadius(cubicPackRadius),
m_particleGeneratorPtr(particleGeneratorPtr),
m_pParticleGenerator(particleGeneratorPtr.get())
{
}
template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::~CubicBoxPacker()
{
}
template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
const typename CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::ParticleGenerator &
CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::getParticleGenerator() const
{
return *m_pParticleGenerator;
}
template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
typename CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::ParticleGenerator &
CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::getParticleGenerator()
{
return *m_pParticleGenerator;
}
template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
void
CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::setParticleGenerator(
ParticleGenerator &particleGenerator
)
{
m_pParticleGenerator = &particleGenerator;
m_particleGeneratorPtr = ParticleGeneratorPtr();
}
template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
void
CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::setParticleGenerator(
ParticleGeneratorPtr particleGeneratorPtr
)
{
m_particleGeneratorPtr = particleGeneratorPtr;
m_pParticleGenerator = m_particleGeneratorPtr.get();
}
template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
double
CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::getCubicPackingRadius() const
{
return m_cubicPackRadius;
}
template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
typename CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::Particle
CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::getCandidateParticle(
const Vec3 &point,
double radius
)
{
return getParticleGenerator().getParticle(point, radius);
}
template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
typename CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::Particle
CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::getCandidateParticle(
const Vec3 &point
)
{
return getParticleGenerator().getParticle(point);
}
template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
void
CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::generateCubicPacking()
{
GridIterator pointIt = GridIterator(this->getBBox(), getCubicPackingRadius());
while (pointIt.hasNext()) {
const Particle candidate =
getCandidateParticle(pointIt.next(), getCubicPackingRadius());
if (this->particleFitsInBBoxWithNeighbours(candidate)) {
this->createAndInsertParticle(candidate);
}
}
}
template <typename TmplParticleGenerator, typename TmplBoxPackerBase>
void
CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::generate()
{
generateCubicPacking();
}
};
};
|