Fluid-Sim icon indicating copy to clipboard operation
Fluid-Sim copied to clipboard

different cells map to the same key

Open flabowski opened this issue 2 years ago • 1 comments

Hei, is there a reason you are working with hashes rather than a flattened cell index? As I understand, the domain (the box that contains the particles) is always finite and there are never indefinitely many cells. Instead of (cell.x * hashK1) + (cell.y * hashK2) + (cell.z * hashK3) you could compute the flattened index and use it as a unique cell id: cell_key = cell.z * (n_x * n_y) +cell.y *n_x + cell.x. With n_x = ceil(domain_size.x/smoothingRadius). Not sure what your domain is called, is it boundsSize? So instead of

	int3 cell = GetCell3D(PredictedPositions[index], smoothingRadius);
	uint hash = HashCell3D(cell);
	uint key = KeyFromHash(hash, numParticles);

you could do something like:

	int3 cell = GetCell3D(PredictedPositions[index], smoothingRadius);
	uint key = FlatIndex(cell, domain_size);

No reason to call KeyFromHash anymore, because all cell_key's are already smaller than tableSize (tableSize=n_x*n_y*n_z, which is smaller than numParticles).

flabowski avatar Nov 24 '23 13:11 flabowski

...

kailando avatar May 05 '24 19:05 kailando