ESyS-Particle  4.0.1
CircularNeighbourTable.h
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 #ifndef ESYS_LSMCIRCULARNEIGHBOURTABLE_H
00015 #define ESYS_LSMCIRCULARNEIGHBOURTABLE_H
00016 
00017 #include "Geometry/NeighbourTable.h"
00018 #include <boost/pool/object_pool.hpp>
00019 #include <boost/shared_ptr.hpp>
00020 
00021 #include <sstream>
00022 #include <stdexcept>
00023 #include <set>
00024 
00025 namespace esys
00026 {
00027   namespace lsm
00028   {
00032     template <class TmplParticle>
00033     class CircularNeighbourTable : public NeighbourTable<TmplParticle>
00034     {
00035     public:
00036       typedef NeighbourTable<TmplParticle>                  Inherited;
00037       typedef typename Inherited::Particle                  Particle;
00038       typedef typename Inherited::ParticleVector            ParticleVector;
00039       typedef std::set<typename ParticleVector::value_type> ParticleSet;
00040       typedef boost::object_pool<Particle>                  ParticlePool;
00041       typedef boost::shared_ptr<ParticlePool>               ParticlePoolPtr;
00042       typedef std::vector<bool>                             BoolVector;
00043 
00044     public:
00045       CircularNeighbourTable(
00046         const BoundingBox  &bBox,
00047         double             gridSpacing,
00048         const BoolVector   &periodicDimensions = BoolVector(3, false),
00049         double             circBorderWidth = 0.0
00050       );
00051 
00052       CircularNeighbourTable(
00053         const BoundingBox  &bBox,
00054         double             gridSpacing,
00055         ParticlePoolPtr    particlePoolPtr,
00056         const BoolVector   &periodicDimensions = BoolVector(3, false),
00057         double             circBorderWidth = 0.0
00058       );
00059 
00060     public:
00061       void checkPeriodicDimensions();
00062 
00063       virtual ~CircularNeighbourTable();
00064 
00065       void setCircularBorderWidth(
00066         double circBorderWidth,
00067         double gridSpacing
00068       );
00069       
00070       void setCircularBorderWidth(double circBorderWidth);
00071 
00072       void resize(
00073         const BoundingBox &bBox,
00074         double gridSpacing,
00075         double circBorderWidth
00076       );
00077 
00078       void resize(
00079         const BoundingBox &bBox,
00080         double gridSpacing
00081       );
00082       
00083       void insertClone(Particle *pParticle, const Vec3 &newPosition);
00084 
00085       bool havePeriodicDimensions() const;
00086 
00087       Vec3 getModdedPosn(const Vec3 &posn) const;
00088       
00089       void insert(Particle *pParticle);
00090 
00091       void insert(Particle &particle);
00092 
00093       size_t getNumClonedParticles() const;
00094 
00095       size_t getNumParticles() const;
00096 
00097       const BoolVector &getPeriodicDimensions() const;
00098 
00099     protected:
00100       bool isClone(Particle *p) const;
00101       
00102       ParticleVector getNonClonedParticles();
00103       
00104       void clearClonedParticles();
00105 
00106     private:
00107       BoolVector      m_periodicDimensions;
00108       ParticlePoolPtr m_particlePoolPtr;
00109       ParticleSet     m_clonedParticleSet;
00110       int             m_circGridWidth;
00111       int             m_periodicDimIndex;
00112     };
00113   };
00114 };
00115 
00116 #include "Geometry/CircularNeighbourTable.hpp"
00117 
00118 #endif