ESyS-Particle  4.0.1
GeometryReader.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_LSMGEOMETRYREADER_H
15 #define ESYS_LSMGEOMETRYREADER_H
16 
17 #include "Foundation/vec3.h"
18 #include "Parallel/IterativeReader.h"
19 #include "Geometry/GeometryInfo.h"
20 #include "Geometry/SimpleParticleData.h"
21 
22 #include <string>
23 #include <vector>
24 #include <iostream>
25 
26 typedef std::vector<bool> BoolVector;
27 typedef std::vector<int> IntVector;
28 typedef std::vector<Vec3> Vec3Vector;
29 
33 namespace esys
34 {
38  namespace lsm
39  {
40  class ParticleIterator : public IStreamIterator<SimpleParticleData>
41  {
42  public:
44 
45  ParticleIterator(std::istream &iStream, int numElements, bool is2d = true)
46  : IStreamIterator<SimpleParticleData>(iStream, numElements),
47  m_is2d(is2d)
48  {
49  }
50 
51  protected:
52  virtual void readDataFromStream()
53  {
55 
56  double mass = m_data.getRadius() * m_data.getRadius();
57  if (!m_is2d)
58  {
59  mass *= m_data.getRadius();
60  }
61  m_data.setMass(mass);
62  }
63 
64  private:
65  bool m_is2d;
66  };
67 
71  class ParticleReader : public IterativeReader<ParticleIterator>
72  {
73  public:
77  ParticleReader(std::istream &iStream, bool is2d);
78 
84  virtual void initialise();
85 
89  const std::string &getParticleType();
90 
91  protected:
93 
94  private:
95  std::string m_particleType;
96  bool m_is2d;
97  };
98 
103  {
104  public:
105  typedef SimpleParticleData::Id Id;
106  typedef SimpleParticleData::Tag Tag;
107 
109 
110  SimpleConnectionData(Id p1Id, Id p2Id, Tag tag);
111 
112  bool operator==(const SimpleConnectionData &particleData) const;
113 
114  const Id &getP1Id() const;
115 
116  const Id &getP2Id() const;
117 
118  const Tag &getTag() const;
119 
120  void read(std::istream &istream);
121 
122  void write(std::ostream &write) const;
123 
124  private:
125  Id m_particle1Id;
126  Id m_particle2Id;
127  Tag m_tag;
128  };
129 
130  std::istream &operator>>(std::istream &iStream, SimpleConnectionData &connectionData);
131  std::ostream &operator<<(std::ostream &oStream, const SimpleConnectionData &connectionData);
132 
136  class ConnectionReader : public IterativeReader<IStreamIterator<SimpleConnectionData> >
137  {
138  public:
142  ConnectionReader(std::istream &iStream);
143 
149  virtual void initialise();
150 
151  private:
152  };
153 
159  {
160  public:
171  GeometryReader(const std::string &fileName);
172 
181  GeometryReader(std::istream &iStream);
182 
186  virtual ~GeometryReader();
187 
192  const std::string &getFileName() const;
193 
197  const std::string &getParticleType();
198 
203  const GeometryInfo &getGeometryInfo() const;
204 
209 
214 
215  protected:
219  void initialise();
220 
221  private:
222  GeometryReader(const GeometryReader &geoReader);
223  GeometryReader &operator=(const GeometryReader &geoReader) const;
224 
225  class Impl;
226 
227  Impl *m_pImpl;
228  };
229  }; // namespace lsm
230 }; // namespace esys
231 
232 #endif