ESyS-Particle  4.0.1
Packer.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_LSMPACKER_H
00015 #define ESYS_LSMPACKER_H
00016 
00017 #include "Geometry/CircularNeighbourTable.h"
00018 #include "Geometry/ParticleCollection.h"
00019 #include <boost/pool/object_pool.hpp>
00020 #include <boost/shared_ptr.hpp>
00021 
00022 #include <set>
00023 
00024 namespace esys
00025 {
00026   namespace lsm
00027   {
00031     template <typename TmplParticleCollection>
00032     class Packer
00033     {
00034     public:
00035       typedef TmplParticleCollection                     ParticleCollection;
00036       typedef Packer<ParticleCollection>                 PackerBase;
00037       typedef boost::shared_ptr<ParticleCollection>      ParticleCollectionPtr;
00038       typedef typename ParticleCollection::Particle      Particle;
00039       typedef boost::object_pool<Particle>               ParticlePool;
00040       typedef boost::shared_ptr<ParticlePool>            ParticlePoolPtr;
00041       typedef CircularNeighbourTable<Particle>           NTable;
00042       typedef boost::shared_ptr<NTable>                  NTablePtr;
00043       typedef
00044         typename ParticleCollection::ParticleIterator
00045         ParticleIterator;
00046       typedef
00047         typename ParticleCollection::ParticleConstIterator
00048         ParticleConstIterator;
00049 
00050       Packer(NTablePtr nTablePtr);
00051 
00052       Packer(ParticlePoolPtr particlePoolPtr, NTablePtr nTablePtr);
00053 
00054       virtual ~Packer();
00055 
00056       virtual void generate() = 0;
00057 
00058       int getNumParticles() const;
00059 
00060       int getNextParticleId();
00061       
00062       void setNTablePtr(NTablePtr nTablePtr);
00063       NTable &getNTable();
00064       const NTable &getNTable() const;
00065 
00066       ParticlePoolPtr getParticlePoolPtr();
00067       ParticlePool &getParticlePool();
00068       const ParticlePool &getParticlePool() const;
00069 
00070       ParticleCollection &getParticleCollection();
00071       const ParticleCollection &getParticleCollection() const;
00072 
00073       Particle &constructParticle(const Particle &particle);
00074 
00075       ParticleIterator getParticleIterator();
00076 
00077       ParticleConstIterator getParticleIterator() const;
00078 
00079       bool contains(const Particle &particle) const;
00080 
00081       Particle &createAndInsertParticle(const Particle &particle);
00082 
00083     protected:
00084 
00085       typedef std::set<int> IdSet;
00086 
00087     private:
00088       NTablePtr             m_nTablePtr;
00089       ParticlePoolPtr       m_particlePoolPtr;
00090       ParticleCollectionPtr m_particleCollectionPtr;
00091       IdSet                 m_idSet;
00092     };
00093   };
00094 };
00095 
00096 #include "Geometry/Packer.hpp"
00097 
00098 #endif