ESyS-Particle
4.0.1
|
00001 00002 // // 00003 // Copyright (c) 2003-2011 by The University of Queensland // 00004 // Earth Systems Science Computational Centre (ESSCC) // 00005 // http://www.uq.edu.au/esscc // 00006 // // 00007 // Primary Business: Brisbane, Queensland, Australia // 00008 // Licensed under the Open Software License version 3.0 // 00009 // http://www.opensource.org/licenses/osl-3.0.php // 00010 // // 00012 00022 template<typename T> 00023 TTempPartStore<T>::TTempPartStore(const Vec3& min,const Vec3& max, int nx,int ny,int nz) 00024 { 00025 // minimum corner 00026 m_xmin=min.X(); 00027 m_ymin=min.Y(); 00028 m_zmin=min.Z(); 00029 // size of a block 00030 m_xsize=(max.X()-min.X())/double(nx); 00031 m_ysize=(max.Y()-min.Y())/double(ny); 00032 m_zsize=(max.Z()-min.Z())/double(nz); 00033 // number of blocks 00034 m_nx=nx; 00035 m_ny=ny; 00036 m_nz=nz; 00037 } 00038 00047 template<typename T> 00048 int TTempPartStore<T>::coordsToIndex(int x,int y,int z) 00049 { 00050 return x*m_ny*m_nz+y*m_nz+z; 00051 } 00052 00059 template<typename T> 00060 int TTempPartStore<T>::posToIndex(const Vec3& pos) 00061 { 00062 int posx=int(floor((pos.X()-m_xmin)/m_xsize)); 00063 int posy=int(floor((pos.Y()-m_ymin)/m_ysize)); 00064 int posz=int(floor((pos.Z()-m_zmin)/m_zsize)); 00065 return coordsToIndex(posx,posy,posz); 00066 } 00067 00076 template<typename T> 00077 void TTempPartStore<T>::addSlaveID(int cx,int cy,int cz,int rank) 00078 { 00079 int idx=coordsToIndex(cx,cy,cz); 00080 m_slave_id_map.insert(make_pair(idx,rank)); 00081 } 00082 00088 template<typename T> 00089 void TTempPartStore<T>::addParticle(const T& p) 00090 { 00091 int idx=posToIndex(p.getPos()); 00092 int sl_id=m_slave_id_map[idx]; 00093 cout << "Inserting particle at pos " << p.getPos() << " index " << idx << "slave " << sl_id << endl; 00094 typename multimap<int,T>::iterator it=m_mmap.insert(make_pair(sl_id,p)); 00095 m_by_id.insert(make_pair(p.getID(),it)); 00096 } 00097 00107 template<typename T> 00108 void TTempPartStore<T>::addConnection(int id1,int id2,int tag) 00109 {}