FluidX3D icon indicating copy to clipboard operation
FluidX3D copied to clipboard

Coriolis force implementation

Open rodionstepanov opened this issue 2 months ago • 2 comments

Hi! I wonder is there any more optimal way to model the Coriolis force than rhis

	while (true) { // main simulation loop
		lbm.u.read_from_device();
		for (uint z = 1u; z < Nz - 1u; z++) {
			for (uint y = 1u; y < Ny-1u; y++) {
				for (uint x = 1u; x < Nx - 1u; x++) {
					const uint n = x + (y + z * Ny) * Nx;
					lbm.F.x[n] = -Co * lbm.u.y[n];
					lbm.F.y[n] =  Co * lbm.u.x[n];
					lbm.F.z[n] =  0.0f;
				}
			}
		}
		lbm.F.write_to_device();
		lbm.run(1u);
	}

It slows down a thousand times :(

rodionstepanov avatar Oct 25 '25 09:10 rodionstepanov

Hi @rodionstepanov,

here you copy the data over PCIe every time step. This of course is very slow.

I recommend writing a small OpenCL kernel that does the force update, without data movement. Or you can integrate this into an existing kernel.

Kind regards, Moritz

ProjectPhysX avatar Oct 25 '25 15:10 ProjectPhysX

I recommend writing a small OpenCL kernel that does the force update, without data movement. Or you can unterste this into an existing kernel.

it sounds simple but I find no example. Do you mean to add new function similar to update_force_field?

rodionstepanov avatar Oct 25 '25 16:10 rodionstepanov