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 #ifndef ESYS_LSMSPHERENEIGHBOURS_H 00015 #define ESYS_LSMSPHERENEIGHBOURS_H 00016 00017 #include "Geometry/CircularNeighbourTable.h" 00018 #include "Geometry/BasicInteraction.h" 00019 00020 #include <boost/shared_ptr.hpp> 00021 #include <boost/pool/object_pool.hpp> 00022 00023 #include <set> 00024 #include <vector> 00025 #include <float.h> 00026 00027 namespace esys 00028 { 00029 namespace lsm 00030 { 00034 template <typename TmplSphere, typename TmplIdPairVector> 00035 class SphereNeighbours 00036 { 00037 public: 00038 typedef int Id; 00039 typedef TmplSphere Sphere; 00040 typedef TmplIdPairVector IdPairVector; 00041 typedef typename IdPairVector::value_type IdPair; 00042 00043 class Cmp 00044 { 00045 public: 00046 bool operator()(const IdPair &c1, const IdPair &c2) const 00047 { 00048 return 00049 ( 00050 (c1.first < c2.first) 00051 || 00052 ( 00053 (c1.first == c2.first) 00054 && 00055 ( 00056 (c1.second < c2.second) 00057 ) 00058 ) 00059 ); 00060 } 00061 bool operator()(const IdPair *c1, const IdPair *c2) const 00062 { 00063 return (*this)(*c1, *c2); 00064 } 00065 }; 00066 public: 00067 typedef std::set<IdPair *,Cmp> IdPairSet; 00068 typedef std::set<const IdPair *,Cmp> ConstIdPairSet; 00069 typedef std::vector<Sphere *> SphereVector; 00070 typedef CircularNeighbourTable<Sphere> NTable; 00071 typedef typename NTable::ParticleIterator SphereIterator; 00072 typedef typename NTable::ParticleConstIterator SphereConstIterator; 00073 00074 public: 00075 typedef typename NTable::BoolVector BoolVector; 00076 00077 SphereNeighbours( 00078 double maxDist, 00079 const BoundingBox &bBox = BoundingBox(Vec3(-10,-10,-10), Vec3(10,10,10)), 00080 const BoolVector &circDimensions = BoolVector(3, false) 00081 ); 00082 00083 ~SphereNeighbours(); 00084 00085 int getNumSpheres() const; 00086 00087 int getNumIdPairs() const; 00088 00089 double getMinRadius() const; 00090 00091 double getMaxRadius() const; 00092 00093 SphereConstIterator getSphereIterator() const; 00094 00095 BoundingBox getSphereBBox() const; 00096 00097 template<typename TmplSphereIterator> 00098 IdPairVector getNeighbours(TmplSphereIterator it); 00099 00100 typedef ForwardConstIterator<IdPairSet> IdPairConstIterator; 00101 00102 class ConstIterator : public IdPairConstIterator 00103 { 00104 public: 00105 typedef const IdPair& value_type; 00106 typedef const IdPair& reference; 00107 ConstIterator(const IdPairSet &set) 00108 : IdPairConstIterator(set) 00109 { 00110 } 00111 00112 value_type next() 00113 { 00114 return *(IdPairConstIterator::next()); 00115 } 00116 00117 value_type current() const 00118 { 00119 return *(IdPairConstIterator::current()); 00120 } 00121 }; 00122 typedef ConstIterator Iterator; 00123 00124 Iterator getIterator() const 00125 { 00126 return Iterator(m_connectionSet); 00127 } 00128 00129 protected: 00130 void insert(Sphere &p); 00131 00132 const IdPair &createIdPair(const Sphere &p1, const Sphere &p2); 00133 00134 private: 00135 typedef boost::shared_ptr<NTable> NTablePtr; 00136 typedef boost::object_pool<IdPair> IdPairPool; 00137 typedef boost::shared_ptr<IdPairPool> IdPairPoolPtr; 00138 00139 IdPairPoolPtr m_connectionPoolPtr; 00140 IdPairSet m_connectionSet; 00141 NTablePtr m_nTablePtr; 00142 double m_minRadius; 00143 double m_maxRadius; 00144 double m_maxDist; 00145 Vec3 m_minPt; 00146 Vec3 m_maxPt; 00147 }; 00148 } 00149 } 00150 00151 #include "Geometry/SphereNeighbours.hpp" 00152 00153 #endif