Files Classes Functions Hierarchy
#include <cell.h>
Public Member Functions | |
| cell () | |
| Construct in bad state. | |
| cell (uintc N_) | |
| Pass the number of particles. | |
| ~cell () | |
| Memory cleanup. | |
| void | reset (uintc N_) |
| Pass the number of particles. | |
| template<typename F > | |
| void | eval (F &f) |
| Builds the data structure. | |
| template<typename F > | |
| void | getsurroundingparticles (uint *const nb, uint &sz, F &f, uintc pti) |
Public Attributes | |
| uint * | count |
| Tempory cell counts. | |
| uint * | index |
| Start of cell. | |
| uint * | vi |
| uint * | fi |
| pt->i table. | |
| uint | W |
| W columns and W rows grid. | |
| uint | WW |
| W squared. | |
| uint | N |
| Number of particles. | |
Provide access to the data structure
Definition at line 36 of file cell.h.
| cell::cell | ( | ) |
| cell::cell | ( | uintc | N_ | ) |
| cell::~cell | ( | ) |
| void cell::eval | ( | F & | f | ) | [inline] |
Builds the data structure.
Definition at line 95 of file cell.h.
References count, fi, index, N, print(), vi, W, and WW.
Referenced by test03(), and integration< D, F >::uniformgridtest().
00096 { 00097 f.W = W; 00098 assert(WW==W*W); 00099 00100 for (uint i=0; i<WW; ++i) 00101 assert(count[i]==0); 00102 00103 for (uint i=0; i<N; ++i) 00104 { 00105 fi[i] = f.index(i); 00106 ++count[fi[i]]; 00107 } 00108 00109 index[0] = 0; 00110 for (uint i=1; i<WW; ++i) 00111 index[i] = index[i-1]+count[i-1]; 00112 00113 00114 #ifdef DEBUG_CELL 00115 cout << "fi "; 00116 print(fi,fi+N); 00117 00118 cout << "count "; 00119 print(count,count+WW); 00120 00121 cout << "index "; 00122 print(index,index+WW); 00123 #endif 00124 00125 uint k; 00126 for (uint i=0; i<N; ++i) 00127 { 00128 k = fi[i]; 00129 assert(k<WW); 00130 vi[index[k] + count[k] - 1] = i; 00131 --count[k]; 00132 } 00133 00134 // count[] should be all zero. 00135 for (uint i=0; i<WW; ++i) 00136 assert(count[i]==0); 00137 00138 #ifdef DEBUG_CELL 00139 cout << "vi "; 00140 print(vi,vi+N); 00141 00142 cout << "count "; 00143 print(count,count+WW); 00144 #endif 00145 00146 }
| void cell::getsurroundingparticles | ( | uint *const | nb, | |
| uint & | sz, | |||
| F & | f, | |||
| uintc | pti | |||
| ) | [inline] |
Definition at line 150 of file cell.h.
Referenced by integration< D, F >::uniformgridtest().
00156 { 00157 uint * ci; 00158 uint n(0); 00159 uint c; 00160 uint c0; 00161 uint z(0); 00162 f.getsurroundingcells(ci,n,f.index(pti)); 00163 for (uint i=0; i<n; ++i) 00164 { 00165 // Determine how many particles in cell k 00166 c0 = index[ci[i]]; 00167 c = index[ci[i]+1]-c0; 00168 00169 for (uint k=0; k<c; ++k) 00170 nb[z++] = vi[c0+k]; 00171 } 00172 sz = z; 00173 }
| void cell::reset | ( | uintc | N_ | ) |
Pass the number of particles.
Definition at line 24 of file cell.cpp.
References count, fi, index, N, vi, W, and WW.
Referenced by cell(), and integration< D, F >::reset().
00025 { 00026 if (count) 00027 delete[] count; 00028 if (vi) 00029 delete[] vi; 00030 if (index) 00031 delete[] index; 00032 if (fi) 00033 delete[] fi; 00034 00035 N = N_; 00036 W = (uint)( sqrt((double)N) )+1; 00037 WW = W*W; 00038 count = new uint[WW]; 00039 index = new uint[WW+1]; 00040 index[WW] = N; // Sentinal value 00041 // suchthat index[k+1]-index[k] = count[k] 00042 vi = new uint[N]; 00043 00044 fi = new uint[N]; 00045 00046 for (uint i=0; i<WW; ++i) 00047 count[i]=0; 00048 }
1.5.8