ESyS-Particle  4.0.1
Grain.hpp
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 #include "Geometry/Grain.h"
15 #include <stdexcept>
16 #include <fstream>
17 #include <sstream>
18 #include <iomanip>
19 
20 #include <boost/limits.hpp>
21 
22 namespace esys
23 {
24  namespace lsm
25  {
26  template <typename TmplParticleCollection>
27  Grain<TmplParticleCollection>::Grain() : Inherited(), m_id(-1)
28  {
29  }
30 
31  template <typename TmplParticleCollection>
32  Grain<TmplParticleCollection>::Grain(ParticlePoolPtr particlePoolPtr)
33  : Inherited(particlePoolPtr),
34  m_id(-1)
35  {
36  }
37 
38  template <typename TmplParticleCollection>
39  Grain<TmplParticleCollection>::Grain(Id id) : Inherited(), m_id(id)
40  {
41  }
42 
43  template <typename TmplParticleCollection>
44  Grain<TmplParticleCollection>::Grain(Id id, ParticlePoolPtr particlePoolPtr)
45  : Inherited(particlePoolPtr),
46  m_id(id)
47  {
48  }
49 
50  template <typename TmplParticleCollection>
51  Grain<TmplParticleCollection>::Grain(const Grain &g)
52  : Inherited(g), m_id(g.getId())
53  {
54  }
55 
56  template <typename TmplParticleCollection>
57  Grain<TmplParticleCollection> &
58  Grain<TmplParticleCollection>::operator=(const Grain &g)
59  {
60  Inherited::operator=(g);
61  setId(g.getId());
62  return *this;
63  }
64 
65  template <typename TmplParticleCollection>
66  typename Grain<TmplParticleCollection>::Id
67  Grain<TmplParticleCollection>::getId() const
68  {
69  return m_id;
70  }
71 
72  template <typename TmplParticleCollection>
73  void Grain<TmplParticleCollection>::setId(Id id)
74  {
75  m_id = id;
76  }
77 
78  template <typename TmplParticleCollection>
79  void Grain<TmplParticleCollection>::setParticleIds(
80  typename Particle::Id minId
81  )
82  {
83  ParticleIterator it = this->getParticleIterator();
84  while (it.hasNext())
85  {
86  it.next().setId(minId++);
87  }
88  }
89  }
90 }