95 for (
unsigned int level = startLevel; level < grid->
cellSizes_.size(); occupiedLevelsMask >>= 1, level++)
98 if (occupiedLevelsMask == 0)
break;
101 if ((occupiedLevelsMask & 1) == 0)
continue;
103 if (level == startLevel)
111 CheckCell(x+1, y-1, z , level, obj, grid);
113 CheckCell(x+1, y+1, z , level, obj, grid);
115 CheckCell(x+1, y-1, z+1, level, obj, grid);
116 CheckCell(x+1, y, z+1, level, obj, grid);
117 CheckCell(x+1, y+1, z+1, level, obj, grid);
119 CheckCell(x+1, y-1, z-1, level, obj, grid);
120 CheckCell(x+1, y, z-1, level, obj, grid);
121 CheckCell(x+1, y+1, z-1, level, obj, grid);
123 CheckCell(x , y+1, z , level, obj, grid);
125 CheckCell(x , y+1, z-1, level, obj, grid);
126 CheckCell(x , y+1, z+1, level, obj, grid);
130 int xs,ys,zs,xe,ye,ze;
155 for (
unsigned int level = 0; level <=startLevel; occupiedLevelsMask >>= 1, level++)
158 if (occupiedLevelsMask == 0)
break;
161 if ((occupiedLevelsMask & 1) == 0)
continue;
163 if (level == startLevel)
171 CheckCell(x+1, y-1, z , level, obj, grid);
173 CheckCell(x+1, y+1, z , level, obj, grid);
175 CheckCell(x+1, y-1, z+1, level, obj, grid);
176 CheckCell(x+1, y, z+1, level, obj, grid);
177 CheckCell(x+1, y+1, z+1, level, obj, grid);
179 CheckCell(x+1, y-1, z-1, level, obj, grid);
180 CheckCell(x+1, y, z-1, level, obj, grid);
181 CheckCell(x+1, y+1, z-1, level, obj, grid);
183 CheckCell(x , y+1, z , level, obj, grid);
185 CheckCell(x , y+1, z-1, level, obj, grid);
186 CheckCell(x , y+1, z+1, level, obj, grid);
190 int xs,ys,zs,xe,ye,ze;
229 #ifdef ContactListHgrid
239 getPossibleContactList().remove_ParticlePosibleContacts(obj);
252 InsertObjAgainstGrid(
grid, obj);
294 while (Test && p!=NULL)
318 for (
unsigned int level = 0; level < grid->
cellSizes_.size() && Test; occupiedLevelsMask >>= 1, level++)
321 if (occupiedLevelsMask == 0)
break;
324 if ((occupiedLevelsMask & 1) == 0)
continue;
334 &&
TestCell(x , y , z , level, obj, grid)
335 &&
TestCell(x , y-1, z , level, obj, grid)
336 &&
TestCell(x , y+1, z , level, obj, grid)
337 &&
TestCell(x-1, y , z , level, obj, grid)
338 &&
TestCell(x+1, y , z , level, obj, grid)
339 &&
TestCell(x-1, y-1, z , level, obj, grid)
340 &&
TestCell(x-1, y+1, z , level, obj, grid)
341 &&
TestCell(x+1, y-1, z , level, obj, grid)
342 &&
TestCell(x+1, y+1, z , level, obj, grid)
344 &&
TestCell(x , y , z-1, level, obj, grid)
345 &&
TestCell(x , y-1, z-1, level, obj, grid)
346 &&
TestCell(x , y+1, z-1, level, obj, grid)
347 &&
TestCell(x-1, y , z-1, level, obj, grid)
348 &&
TestCell(x+1, y , z-1, level, obj, grid)
349 &&
TestCell(x-1, y-1, z-1, level, obj, grid)
350 &&
TestCell(x-1, y+1, z-1, level, obj, grid)
351 &&
TestCell(x+1, y-1, z-1, level, obj, grid)
352 &&
TestCell(x+1, y+1, z-1, level, obj, grid)
354 &&
TestCell(x , y , z+1, level, obj, grid)
355 &&
TestCell(x , y-1, z+1, level, obj, grid)
356 &&
TestCell(x , y+1, z+1, level, obj, grid)
357 &&
TestCell(x-1, y , z+1, level, obj, grid)
358 &&
TestCell(x+1, y , z+1, level, obj, grid)
359 &&
TestCell(x-1, y-1, z+1, level, obj, grid)
360 &&
TestCell(x-1, y+1, z+1, level, obj, grid)
361 &&
TestCell(x+1, y-1, z+1, level, obj, grid)
362 &&
TestCell(x+1, y+1, z+1, level, obj, grid);
368 #ifdef ContactListHgrid
369 void HGRID_3D::InsertCell(
int x,
int y,
int z,
int l,
BaseParticle *obj,
HGrid *grid)
379 getPossibleContactList().add_PossibleContact(obj,p);
402 for (
int level = 0; level < grid->HGRID_MAX_LEVELS; occupiedLevelsMask >>= 1, level++)
405 if (occupiedLevelsMask == 0)
break;
408 if ((occupiedLevelsMask & 1) == 0)
continue;
411 inv_size = grid->inv_size[level];
413 xmin=(
int)floor(ownXMin*inv_size-0.5);
414 xmax=(
int)ceil(ownXMax*inv_size+0.5);
415 ymin=(
int)floor(ownYMin*inv_size-0.5);
416 ymax=(
int)ceil(ownYMax*inv_size+0.5);
417 zmin=(
int)floor(ownZMin*inv_size-0.5);
418 zmax=(
int)ceil(ownZMax*inv_size+0.5);
423 for(
int i=xmin;i<
xmax;i++)
424 for(
int j=ymin;j<
ymax;j++)
425 for(
int k=zmin;k<
zmax;k++)
426 InsertCell(i, j, k, level, obj, grid);
HGridMethod getHGridMethod()
void set_HGRID_x(const int _new)
void set_HGRID_PrevObject(BaseParticle *_new)
BaseParticle * get_HGRID_PrevObject() const
void HGRID_UpdateParticleInHgrid(BaseParticle *obj)
This adds a partcile to the Grid, called in the grid setup routies.
Mdouble get_InteractionRadius() const
BaseParticle * get_PeriodicFromParticle() const
virtual void CheckCell(int x, int y, int z, int l, BaseParticle *obj, HGrid *grid)
Check collisions for a general cell.
void set_HGRID_z(const int _new)
void HGRID_RemoveParticleFromHgrid(BaseParticle *obj)
BaseParticle * get_HGRID_NextObject() const
std::vector< double > invCellSizes_
std::vector< double > cellSizes_
bool TestCell(int x, int y, int z, int l, BaseParticle *obj, HGrid *grid)
Tests obj against all particles in cell similar to CheckCell, but links to TestObject instead of comp...
bool TestObjAgainstGrid(HGrid *grid, BaseParticle *obj)
Tests obj against all neighbouring particles similar to CheckObjAgainstGrid, but links to TestCell in...
This is the HGRID class - This is the actually HGRID code.
virtual bool TestObject(BaseParticle *pI, BaseParticle *pJ)
criterium for inserting a particle (returns false, if particles overlap;)
void set_HGRID_y(const int _new)
int ComputeHashBucketIndex(int x, int y, int z, int l)
Computes hash bucket index in range [0, NUM_BUCKETS-1].
void CheckObjAgainstGrid(HGrid *grid, BaseParticle *obj)
Check if an Particle has a collision in the grid; avoids multiple checks.
const Vec3D & get_Position() const
bool * bucketIsChecked
bucketIsChecked[b] stores if hash bucket b is checked already; initially all zero ...
int occupiedLevelsMask
l-th bit of occupiedLevelsMask is 1 if level l is contains particles; initially zero (Implies max 32 ...
Mdouble xmin
These store the size of the domain, assume walls at the ends.
void set_HGRID_NextObject(BaseParticle *_new)
virtual void CheckCell_current(int x, int y, int z, int l, HGrid *grid)
Checks for a collision in the particles own cell.
int get_HGRID_Level() const
virtual void compute_internal_forces(BaseParticle *i)
Computes the forces between particles (internal in the sence that the sum over all these forces is ze...
BaseParticle ** objectBucket
objectBucket[b] stores pointer to first element in hash bucket b; initially all NULL ...