ESyS-Particle  4.0.1
TempPartStore.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 
22 template<typename T>
23 TTempPartStore<T>::TTempPartStore(const Vec3& min,const Vec3& max, int nx,int ny,int nz)
24 {
25  // minimum corner
26  m_xmin=min.X();
27  m_ymin=min.Y();
28  m_zmin=min.Z();
29  // size of a block
30  m_xsize=(max.X()-min.X())/double(nx);
31  m_ysize=(max.Y()-min.Y())/double(ny);
32  m_zsize=(max.Z()-min.Z())/double(nz);
33  // number of blocks
34  m_nx=nx;
35  m_ny=ny;
36  m_nz=nz;
37 }
38 
47 template<typename T>
48 int TTempPartStore<T>::coordsToIndex(int x,int y,int z)
49 {
50  return x*m_ny*m_nz+y*m_nz+z;
51 }
52 
59 template<typename T>
60 int TTempPartStore<T>::posToIndex(const Vec3& pos)
61 {
62  int posx=int(floor((pos.X()-m_xmin)/m_xsize));
63  int posy=int(floor((pos.Y()-m_ymin)/m_ysize));
64  int posz=int(floor((pos.Z()-m_zmin)/m_zsize));
65  return coordsToIndex(posx,posy,posz);
66 }
67 
76 template<typename T>
77 void TTempPartStore<T>::addSlaveID(int cx,int cy,int cz,int rank)
78 {
79  int idx=coordsToIndex(cx,cy,cz);
80  m_slave_id_map.insert(make_pair(idx,rank));
81 }
82 
88 template<typename T>
90 {
91  int idx=posToIndex(p.getPos());
92  int sl_id=m_slave_id_map[idx];
93  cout << "Inserting particle at pos " << p.getPos() << " index " << idx << "slave " << sl_id << endl;
94  typename multimap<int,T>::iterator it=m_mmap.insert(make_pair(sl_id,p));
95  m_by_id.insert(make_pair(p.getID(),it));
96 }
97 
107 template<typename T>
108 void TTempPartStore<T>::addConnection(int id1,int id2,int tag)
109 {}