proj home

Files   Classes   Functions   Hierarchy  

cell Class Reference

Order a list of points in linear time. More...

#include <cell.h>

Collaboration diagram for cell:

List of all members.

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

uintcount
 Tempory cell counts.
uintindex
 Start of cell.
uintvi
uintfi
 pt->i table.
uint W
 W columns and W rows grid.
uint WW
 W squared.
uint N
 Number of particles.


Detailed Description

Order a list of points in linear time.

Provide access to the data structure

Definition at line 36 of file cell.h.


Constructor & Destructor Documentation

cell::cell (  ) 

Construct in bad state.

Definition at line 14 of file cell.cpp.

References count, fi, index, vi, W, and WW.

00015   : N(0)
00016 {
00017   W = WW = 0;
00018   count = 0;
00019   index = 0;
00020   vi = 0;
00021   fi = 0;
00022 }

cell::cell ( uintc  N_  ) 

Pass the number of particles.

Definition at line 50 of file cell.cpp.

References reset().

00051 {
00052   reset(N_);
00053 }

cell::~cell (  ) 

Memory cleanup.

Definition at line 6 of file cell.cpp.

References count, fi, index, and vi.

00007 {
00008   delete[] vi;
00009   delete[] fi;
00010   delete[] count;
00011   delete[] index;
00012 }


Member Function Documentation

template<typename F >
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 }

template<typename F >
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 }


Member Data Documentation

Tempory cell counts.

Definition at line 41 of file cell.h.

Referenced by cell(), eval(), reset(), and ~cell().

pt->i table.

Definition at line 46 of file cell.h.

Referenced by cell(), eval(), reset(), and ~cell().

Start of cell.

Definition at line 43 of file cell.h.

Referenced by cell(), eval(), reset(), and ~cell().

Number of particles.

Definition at line 53 of file cell.h.

Referenced by eval(), and reset().

Definition at line 44 of file cell.h.

Referenced by cell(), eval(), reset(), and ~cell().

W columns and W rows grid.

Definition at line 49 of file cell.h.

Referenced by cell(), eval(), and reset().

W squared.

Definition at line 51 of file cell.h.

Referenced by cell(), eval(), and reset().


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:49:51 2011 for Chelton Evans Source by  doxygen 1.5.8