ESyS-Particle  2.3.2
DistConnections.h
Go to the documentation of this file.
1 
2 // //
3 // Copyright (c) 2003-2014 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.opensource.org/licenses/osl-3.0.php //
10 // //
12 
13 
14 #ifndef ESYS_LSMDISTCONNECTIONS_H
15 #define ESYS_LSMDISTCONNECTIONS_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 TmplParticle, typename TmplConnection>
36  {
37  public:
38  typedef TmplParticle Particle;
39  typedef TmplConnection Connection;
40  typedef int Tag;
41 
42  class Cmp
43  {
44  public:
45  bool operator()(const Connection &c1, const Connection &c2) const
46  {
47  return
48  (
49  (c1.first() < c2.first())
50  ||
51  (
52  (c1.first() == c2.first())
53  &&
54  (
55  (c1.second() < c2.second())
56  ||
57  (
58  (c1.second() == c2.second())
59  &&
60  (c1.getTag() < c2.getTag())
61  )
62  )
63  )
64  );
65  }
66  bool operator()(const Connection *c1, const Connection *c2) const
67  {
68  return (*this)(*c1, *c2);
69  }
70  };
71  public:
72  typedef std::set<Connection *,Cmp> ConnectionSet;
73  typedef std::vector<Particle *> ParticleVector;
77 
78  public:
79  typedef typename NTable::BoolVector BoolVector;
80 
82  double maxDist,
83  Tag defaultTag = 0,
84  const BoundingBox &bBox = BoundingBox(Vec3(-10,-10,-10), Vec3(10,10,10)),
85  const BoolVector &circDimensions = BoolVector(3, false)
86  );
87 
89 
90  int getNumParticles() const;
91 
92  int getNumConnections() const;
93 
94  double getMinRadius() const;
95 
96  double getMaxRadius() const;
97 
99 
101 
102  template<typename TmplParticleIterator>
103  void create(TmplParticleIterator it);
104 
105  template<typename TmplParticleIterator>
106  void create(TmplParticleIterator it, Tag tag);
107 
108  Tag getDefaultTag() const;
109  void setDefaultTag(Tag defaultTag);
110 
112 
114  {
115  public:
116  typedef const Connection& value_type;
117  typedef const Connection& reference;
120  {
121  }
122 
124  {
125  return *(ConnectionConstIterator::next());
126  }
127 
129  {
131  }
132  };
133  typedef ConstIterator Iterator;
134 
136  {
137  return Iterator(m_connectionSet);
138  }
139 
140  protected:
141  void insert(Particle &p);
142 
143  void createConnection(const Particle &p1, const Particle &p2, Tag tag);
144 
145  private:
146  typedef boost::shared_ptr<NTable> NTablePtr;
147  typedef boost::object_pool<Connection> ConnectionPool;
148  typedef boost::shared_ptr<ConnectionPool> ConnectionPoolPtr;
149 
153  double m_minRadius;
154  double m_maxRadius;
155  double m_maxDist;
159  };
160  }
161 }
162 
164 
165 #endif