ESyS-Particle  4.0.1
DistConnections.h
1 
2 // //
3 // Copyright (c) 2003-2011 by The University of Queensland //
4 // Earth Systems Science Computational Centre (ESSCC) //
5 // http://www.uq.edu.au/esscc //
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 
17 #include "Geometry/CircularNeighbourTable.h"
18 #include "Geometry/BasicInteraction.h"
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 
88  ~DistConnections();
89 
90  int getNumParticles() const;
91 
92  int getNumConnections() const;
93 
94  double getMinRadius() const;
95 
96  double getMaxRadius() const;
97 
98  ParticleConstIterator getParticleIterator() const;
99 
100  BoundingBox getParticleBBox() const;
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;
118  ConstIterator(const ConnectionSet &set)
120  {
121  }
122 
123  value_type next()
124  {
125  return *(ConnectionConstIterator::next());
126  }
127 
128  value_type current() const
129  {
130  return *(ConnectionConstIterator::current());
131  }
132  };
133  typedef ConstIterator Iterator;
134 
135  Iterator getIterator() const
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 
150  ConnectionPoolPtr m_connectionPoolPtr;
151  ConnectionSet m_connectionSet;
152  NTablePtr m_nTablePtr;
153  double m_minRadius;
154  double m_maxRadius;
155  double m_maxDist;
156  Vec3 m_minPt;
157  Vec3 m_maxPt;
158  Tag m_defaultTag;
159  };
160  }
161 }
162 
163 #include "Geometry/DistConnections.hpp"
164 
165 #endif