ESyS-Particle  2.3.4
SphereNeighbours.h
Go to the documentation of this file.
1 // //
3 // Copyright (c) 2003-2017 by The University of Queensland //
4 // Centre for Geoscience Computing //
5 // http://earth.uq.edu.au/centre-geoscience-computing //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.apache.org/licenses/LICENSE-2.0 //
10 // //
12 
13 
14 #ifndef ESYS_LSMSPHERENEIGHBOURS_H
15 #define ESYS_LSMSPHERENEIGHBOURS_H
16 
19 
20 #include <boost/shared_ptr.hpp>
21 #include <boost/pool/object_pool.hpp>
22 
23 #include <set>
24 #include <vector>
25 #include <float.h>
26 
27 namespace esys
28 {
29  namespace lsm
30  {
34  template <typename TmplSphere, typename TmplIdPairVector>
36  {
37  public:
38  typedef int Id;
39  typedef TmplSphere Sphere;
40  typedef TmplIdPairVector IdPairVector;
41  typedef typename IdPairVector::value_type IdPair;
42 
43  class Cmp
44  {
45  public:
46  bool operator()(const IdPair &c1, const IdPair &c2) const
47  {
48  return
49  (
50  (c1.first < c2.first)
51  ||
52  (
53  (c1.first == c2.first)
54  &&
55  (
56  (c1.second < c2.second)
57  )
58  )
59  );
60  }
61  bool operator()(const IdPair *c1, const IdPair *c2) const
62  {
63  return (*this)(*c1, *c2);
64  }
65  };
66  public:
67  typedef std::set<IdPair *,Cmp> IdPairSet;
68  typedef std::set<const IdPair *,Cmp> ConstIdPairSet;
69  typedef std::vector<Sphere *> SphereVector;
73 
74  public:
75  typedef typename NTable::BoolVector BoolVector;
76 
78  double maxDist,
79  const BoundingBox &bBox = BoundingBox(Vec3(-10,-10,-10), Vec3(10,10,10)),
80  const BoolVector &circDimensions = BoolVector(3, false)
81  );
82 
84 
85  int getNumSpheres() const;
86 
87  int getNumIdPairs() const;
88 
89  double getMinRadius() const;
90 
91  double getMaxRadius() const;
92 
94 
95  BoundingBox getSphereBBox() const;
96 
97  template<typename TmplSphereIterator>
98  IdPairVector getNeighbours(TmplSphereIterator it);
99 
101 
103  {
104  public:
105  typedef const IdPair& value_type;
106  typedef const IdPair& reference;
108  : IdPairConstIterator(set)
109  {
110  }
111 
113  {
114  return *(IdPairConstIterator::next());
115  }
116 
118  {
119  return *(IdPairConstIterator::current());
120  }
121  };
122  typedef ConstIterator Iterator;
123 
125  {
126  return Iterator(m_connectionSet);
127  }
128 
129  protected:
130  void insert(Sphere &p);
131 
132  const IdPair &createIdPair(const Sphere &p1, const Sphere &p2);
133 
134  private:
135  typedef boost::shared_ptr<NTable> NTablePtr;
136  typedef boost::object_pool<IdPair> IdPairPool;
137  typedef boost::shared_ptr<IdPairPool> IdPairPoolPtr;
138 
142  double m_minRadius;
143  double m_maxRadius;
144  double m_maxDist;
147  };
148  }
149 }
150 
152 
153 #endif
esys::lsm::SphereNeighbours::Id
int Id
Definition: SphereNeighbours.h:38
esys::lsm::SphereNeighbours::IdPairPool
boost::object_pool< IdPair > IdPairPool
Definition: SphereNeighbours.h:136
esys::lsm::SphereNeighbours::IdPair
IdPairVector::value_type IdPair
Definition: SphereNeighbours.h:41
BasicInteraction.h
esys::lsm::VectorPy
Definition: VectorPy.h:26
esys::lsm::SphereNeighbours::~SphereNeighbours
~SphereNeighbours()
Definition: SphereNeighbours.hpp:59
esys::lsm::ForwardConstIterator::next
reference next()
Definition: StlIterator.h:112
esys::lsm::SphereNeighbours::getIterator
Iterator getIterator() const
Definition: SphereNeighbours.h:124
esys::lsm::SphereNeighbours::IdPairPoolPtr
boost::shared_ptr< IdPairPool > IdPairPoolPtr
Definition: SphereNeighbours.h:137
esys::lsm::SphereNeighbours::getSphereBBox
BoundingBox getSphereBBox() const
Definition: SphereNeighbours.hpp:271
esys::lsm::SphereNeighbours::NTablePtr
boost::shared_ptr< NTable > NTablePtr
Definition: SphereNeighbours.h:135
esys::lsm::SphereNeighbours::insert
void insert(Sphere &p)
Definition: SphereNeighbours.hpp:240
esys::lsm::SphereNeighbours::NTable
CircularNeighbourTable< Sphere > NTable
Definition: SphereNeighbours.h:70
esys::lsm::SphereNeighbours::Cmp
Definition: SphereNeighbours.h:44
esys::lsm::SphereNeighbours::Iterator
ConstIterator Iterator
Definition: SphereNeighbours.h:122
esys::lsm::SphereNeighbours::IdPairConstIterator
ForwardConstIterator< IdPairSet > IdPairConstIterator
Definition: SphereNeighbours.h:100
esys::lsm::SphereNeighbours::createIdPair
const IdPair & createIdPair(const Sphere &p1, const Sphere &p2)
Definition: SphereNeighbours.hpp:96
esys::lsm::SphereNeighbours::SphereVector
std::vector< Sphere * > SphereVector
Definition: SphereNeighbours.h:69
esys::lsm::SphereNeighbours::SphereIterator
NTable::ParticleIterator SphereIterator
Definition: SphereNeighbours.h:71
esys::lsm::SphereNeighbours::SphereConstIterator
NTable::ParticleConstIterator SphereConstIterator
Definition: SphereNeighbours.h:72
esys::lsm::SphereNeighbours::m_maxDist
double m_maxDist
Definition: SphereNeighbours.h:144
esys::lsm::ForwardConstIterator::value_type
TmplIteratable::value_type value_type
Definition: StlIterator.h:78
esys::lsm::SphereNeighbours::SphereNeighbours
SphereNeighbours(double maxDist, const BoundingBox &bBox=BoundingBox(Vec3(-10,-10,-10), Vec3(10, 10, 10)), const BoolVector &circDimensions=BoolVector(3, false))
Definition: SphereNeighbours.hpp:23
esys::lsm::BoundingBox
3D bounding box
Definition: BoundingBox.h:28
esys
Definition: CheckPointable.cpp:17
esys::lsm::SphereNeighbours::Cmp::operator()
bool operator()(const IdPair &c1, const IdPair &c2) const
Definition: SphereNeighbours.h:46
esys::lsm::SphereNeighbours::m_maxRadius
double m_maxRadius
Definition: SphereNeighbours.h:143
esys::lsm::SphereNeighbours::Cmp::operator()
bool operator()(const IdPair *c1, const IdPair *c2) const
Definition: SphereNeighbours.h:61
esys::lsm::SphereNeighbours::getMinRadius
double getMinRadius() const
Definition: SphereNeighbours.hpp:76
CircularNeighbourTable.h
esys::lsm::SphereNeighbours::m_maxPt
Vec3 m_maxPt
Definition: SphereNeighbours.h:146
esys::lsm::SphereNeighbours::ConstIterator
Definition: SphereNeighbours.h:103
esys::lsm::SphereNeighbours::IdPairVector
TmplIdPairVector IdPairVector
Definition: SphereNeighbours.h:40
esys::lsm::SphereNeighbours::ConstIterator::next
value_type next()
Definition: SphereNeighbours.h:112
SphereNeighbours.h
esys::lsm::SphereNeighbours::getSphereIterator
SphereConstIterator getSphereIterator() const
Definition: SphereNeighbours.hpp:89
esys::lsm::SphereNeighbours::m_minRadius
double m_minRadius
Definition: SphereNeighbours.h:142
Vec3
Definition: vec3.h:47
esys::lsm::ForwardIterator
Definition: StlIterator.h:30
esys::lsm::SphereNeighbours::BoolVector
NTable::BoolVector BoolVector
Definition: SphereNeighbours.h:75
esys::lsm::ForwardConstIterator
Definition: StlIterator.h:76
esys::lsm::CircularNeighbourTable::BoolVector
std::vector< bool > BoolVector
Definition: CircularNeighbourTable.h:42
esys::lsm::SphereNeighbours::ConstIterator::reference
const IdPair & reference
Definition: SphereNeighbours.h:106
esys::lsm::SphereNeighbours::m_connectionPoolPtr
IdPairPoolPtr m_connectionPoolPtr
Definition: SphereNeighbours.h:139
esys::lsm::SphereNeighbours::getNumIdPairs
int getNumIdPairs() const
Definition: SphereNeighbours.hpp:70
esys::lsm::ForwardConstIterator::current
reference current() const
Definition: StlIterator.h:105
esys::lsm::SphereNeighbours::ConstIdPairSet
std::set< const IdPair *, Cmp > ConstIdPairSet
Definition: SphereNeighbours.h:68
SphereNeighbours.hpp
esys::lsm::SphereNeighbours::IdPairSet
std::set< IdPair *, Cmp > IdPairSet
Definition: SphereNeighbours.h:67
esys::lsm::SphereNeighbours::m_nTablePtr
NTablePtr m_nTablePtr
Definition: SphereNeighbours.h:141
esys::lsm::SphereNeighbours::ConstIterator::current
value_type current() const
Definition: SphereNeighbours.h:117
esys::lsm::SphereNeighbours::m_connectionSet
IdPairSet m_connectionSet
Definition: SphereNeighbours.h:140
esys::lsm::SphereNeighbours::ConstIterator::ConstIterator
ConstIterator(const IdPairSet &set)
Definition: SphereNeighbours.h:107
Sphere
Definition: Sphere.h:28
esys::lsm::SphereNeighbours::getNumSpheres
int getNumSpheres() const
Definition: SphereNeighbours.hpp:64
esys::lsm::SphereNeighbours
Definition: SphereNeighbours.h:36
esys::lsm::SphereNeighbours::m_minPt
Vec3 m_minPt
Definition: SphereNeighbours.h:145
esys::lsm::SphereNeighbours::getNeighbours
IdPairVector getNeighbours(TmplSphereIterator it)
Definition: SphereNeighbours.hpp:137
esys::lsm::SphereNeighbours::ConstIterator::value_type
const IdPair & value_type
Definition: SphereNeighbours.h:105
esys::lsm::SphereNeighbours::getMaxRadius
double getMaxRadius() const
Definition: SphereNeighbours.hpp:82
esys::lsm::CircularNeighbourTable
Definition: CircularNeighbourTable.h:34
esys::lsm::SphereNeighbours::Sphere
TmplSphere Sphere
Definition: SphereNeighbours.h:39