ESyS-Particle  2.3.2
GrainCollection.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 #ifndef ESYS_LSMGRAINCOLLECTION_H
14 #define ESYS_LSMGRAINCOLLECTION_H
15 
16 #include "Foundation/StlIterator.h"
17 #include <boost/shared_ptr.hpp>
18 #include <boost/pool/object_pool.hpp>
19 
20 #include <vector>
21 
22 namespace esys
23 {
24  namespace lsm
25  {
29  template <typename TmplGrain>
31  {
32  public:
33  typedef TmplGrain Grain;
34  typedef typename Grain::Particle Particle;
40  typedef boost::object_pool<Grain> GrainPool;
41  typedef boost::shared_ptr<GrainPool> GrainPoolPtr;
42  typedef std::vector<Grain *> GrainVector;
43 
44  protected:
47 
48  public:
49 
51  {
52  public:
53  typedef Grain& value_type;
55  : VectorIterator(it)
56  {
57  }
58 
60  {
61  return *(VectorIterator::next());
62  }
63 
65  {
66  return *(VectorIterator::current());
67  }
68  };
69 
71  {
72  public:
73  typedef const Grain& value_type;
76  {
77  }
78 
81  {
82  }
83 
85  {
86  return *(VectorConstIterator::next());
87  }
88 
90  {
91  return *(VectorConstIterator::current());
92  }
93  };
94 
96 
97  GrainCollection(ParticlePoolPtr particlePoolPtr);
98 
99  GrainCollection(ParticlePoolPtr particlePoolPtr, GrainPoolPtr grainPoolPtr);
100 
101  virtual ~GrainCollection();
102 
106  int getNumGrains() const;
107 
112  int getNumParticles() const;
113 
121  void insertRef(Grain &g);
122 
127  Grain &createGrain();
128 
134  Grain &createGrain(typename Grain::Id id);
135 
141  Grain &createGrain(const Grain &g);
142 
143  GrainIterator getGrainIterator();
144 
145  GrainConstIterator getGrainIterator() const;
146 
147  protected:
149 
151 
152  private:
156  };
157  }
158 }
159 
161 
162 #endif