ESyS-Particle  4.0.1
ClosePackBlock.hpp
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_LSMCLOSEPACKBLOCK_HPP
00015 #define ESYS_LSMCLOSEPACKBLOCK_HPP
00016 
00017 #include "Geometry/ClosePackBlock.h"
00018 #include "Geometry/ClosePackIterator.h"
00019 
00020 namespace esys
00021 {
00022   namespace lsm
00023   {
00024     template <typename TmplClosePackIterator,typename TmplParticle>
00025     ClosePackBlockGenerator<TmplClosePackIterator,TmplParticle>::ClosePackBlockGenerator(
00026       unsigned int numX,
00027       unsigned int numY,
00028       unsigned int numZ,
00029       double radius,
00030       ClosePackOrientation orientation
00031     )
00032       : m_radius(radius),
00033         m_dimCounts(numX, numY, numZ),
00034         m_orientation(orientation)
00035     {
00036     }
00037 
00038     template <typename TmplClosePackIterator,typename TmplParticle>
00039     template <typename TmplParticleCollection>
00040     void
00041     ClosePackBlockGenerator<TmplClosePackIterator,TmplParticle>::createParticles(
00042       TmplParticleCollection &particleCollection
00043     )
00044     {
00045       int id = 0;
00046       CentrePointIterator it =
00047         CentrePointIterator(
00048           m_dimCounts[0],
00049           m_dimCounts[1],
00050           m_dimCounts[2],
00051           getRadius(),
00052           ((m_orientation == DEFAULT_ORIENT) && (m_dimCounts[2] <= 1)) ? XYZ : m_orientation
00053         );
00054 
00055       while (it.hasNext())
00056       {
00057         particleCollection.createParticle(
00058           TmplParticle(
00059             it.next(),
00060             getRadius(),
00061             id,
00062             0
00063           )
00064         );
00065         id++;
00066       }
00067     }
00068 
00069     template <typename TmplClosePackIterator,typename TmplParticle>
00070     ClosePackBlockGenerator<TmplClosePackIterator,TmplParticle>::~ClosePackBlockGenerator()
00071     {
00072     }
00073 
00074     template <typename TmplClosePackIterator,typename TmplParticle>
00075     double ClosePackBlockGenerator<TmplClosePackIterator,TmplParticle>::getRadius() const
00076     {
00077       return m_radius;
00078     }
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086     template <typename TmplClosePackIterator,typename TmplParticle>
00087     ClosePackBlock<TmplClosePackIterator,TmplParticle>::ClosePackBlock(
00088       unsigned int numX,
00089       unsigned int numY,
00090       unsigned int numZ,
00091       double radius,
00092       ClosePackOrientation orientation
00093     )
00094       : ParticleCollection<TmplParticle>(),
00095         m_generator(numX, numY, numZ, radius)
00096     {
00097       createParticles();
00098     }
00099 
00100     template <typename TmplClosePackIterator,typename TmplParticle>
00101     ClosePackBlock<TmplClosePackIterator,TmplParticle>::~ClosePackBlock()
00102     {
00103     }
00104     
00105     template <typename TmplClosePackIterator,typename TmplParticle>
00106     void ClosePackBlock<TmplClosePackIterator,TmplParticle>::createParticles()
00107     {
00108       m_generator.createParticles(*this);
00109     }
00110 
00111     template <typename TmplClosePackIterator,typename TmplParticle>
00112     double ClosePackBlock<TmplClosePackIterator,TmplParticle>::getRadius() const
00113     {
00114       return m_generator.getRadius();
00115     }
00116   }
00117 }
00118 
00119 #endif