ESyS-Particle
4.0.1
|
00001 00002 // // 00003 // Copyright (c) 2003-2011 by The University of Queensland // 00004 // Earth Systems Science Computational Centre (ESSCC) // 00005 // http://www.uq.edu.au/esscc // 00006 // // 00007 // Primary Business: Brisbane, Queensland, Australia // 00008 // Licensed under the Open Software License version 3.0 // 00009 // http://www.opensource.org/licenses/osl-3.0.php // 00010 // // 00012 00013 00014 namespace esys 00015 { 00016 namespace lsm 00017 { 00018 template <typename TmplParticleGenerator, typename TmplBoxPackerBase> 00019 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::CubicBoxPacker( 00020 ParticleGeneratorPtr particleGeneratorPtr, 00021 ParticlePoolPtr particlePoolPtr, 00022 NTablePtr nTablePtr, 00023 const BoundingBox &bBox, 00024 const BoolVector &periodicDimensions, 00025 double tolerance, 00026 double cubicPackRadius 00027 ) : Inherited( 00028 particlePoolPtr, 00029 nTablePtr, 00030 bBox, 00031 periodicDimensions, 00032 tolerance 00033 ), 00034 m_cubicPackRadius(cubicPackRadius), 00035 m_particleGeneratorPtr(particleGeneratorPtr), 00036 m_pParticleGenerator(particleGeneratorPtr.get()) 00037 { 00038 } 00039 00040 template <typename TmplParticleGenerator, typename TmplBoxPackerBase> 00041 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::~CubicBoxPacker() 00042 { 00043 } 00044 00045 template <typename TmplParticleGenerator, typename TmplBoxPackerBase> 00046 const typename CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::ParticleGenerator & 00047 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::getParticleGenerator() const 00048 { 00049 return *m_pParticleGenerator; 00050 } 00051 00052 template <typename TmplParticleGenerator, typename TmplBoxPackerBase> 00053 typename CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::ParticleGenerator & 00054 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::getParticleGenerator() 00055 { 00056 return *m_pParticleGenerator; 00057 } 00058 00059 template <typename TmplParticleGenerator, typename TmplBoxPackerBase> 00060 void 00061 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::setParticleGenerator( 00062 ParticleGenerator &particleGenerator 00063 ) 00064 { 00065 m_pParticleGenerator = &particleGenerator; 00066 m_particleGeneratorPtr = ParticleGeneratorPtr(); 00067 } 00068 00069 template <typename TmplParticleGenerator, typename TmplBoxPackerBase> 00070 void 00071 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::setParticleGenerator( 00072 ParticleGeneratorPtr particleGeneratorPtr 00073 ) 00074 { 00075 m_particleGeneratorPtr = particleGeneratorPtr; 00076 m_pParticleGenerator = m_particleGeneratorPtr.get(); 00077 } 00078 00079 template <typename TmplParticleGenerator, typename TmplBoxPackerBase> 00080 double 00081 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::getCubicPackingRadius() const 00082 { 00083 return m_cubicPackRadius; 00084 } 00085 00086 template <typename TmplParticleGenerator, typename TmplBoxPackerBase> 00087 typename CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::Particle 00088 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::getCandidateParticle( 00089 const Vec3 &point, 00090 double radius 00091 ) 00092 { 00093 return getParticleGenerator().getParticle(point, radius); 00094 } 00095 00096 template <typename TmplParticleGenerator, typename TmplBoxPackerBase> 00097 typename CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::Particle 00098 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::getCandidateParticle( 00099 const Vec3 &point 00100 ) 00101 { 00102 return getParticleGenerator().getParticle(point); 00103 } 00104 00105 template <typename TmplParticleGenerator, typename TmplBoxPackerBase> 00106 void 00107 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::generateCubicPacking() 00108 { 00109 GridIterator pointIt = GridIterator(this->getBBox(), getCubicPackingRadius()); 00110 while (pointIt.hasNext()) { 00111 const Particle candidate = 00112 getCandidateParticle(pointIt.next(), getCubicPackingRadius()); 00113 if (this->particleFitsInBBoxWithNeighbours(candidate)) { 00114 this->createAndInsertParticle(candidate); 00115 } 00116 } 00117 } 00118 00119 template <typename TmplParticleGenerator, typename TmplBoxPackerBase> 00120 void 00121 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::generate() 00122 { 00123 generateCubicPacking(); 00124 } 00125 }; 00126 };