OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
Vector 7 SPH Dam break simulation with Dynamic load balacing on Multi-GPU (more optimized version)

SPH with Dynamic load Balancing on GPU (More Optimized)

This example show the classical SPH Dam break simulation with load balancing and dynamic load balancing. The main difference with SPH_dlb_gpu_opt} is that here we use 2 kernel to calculate forces one for fluid and one for boundaries. Also we use the function get_indexes_by_type to get the indexes of the fluid and boundary particles and use these two set to launch two distinct kernel (one over fluid and one over boundary) to calculate forces and density change. set. Simulate 1.5 second should be duable on mobile 1050Ti in about 1 hour and 7 minutes

Simulation video 1

Simulation video 2
Simulation video 3

get_indexes_by_type

This function can be used to get the indexes of a certain type on a particle set and save such indexes in an openfpm::vector<aggregate<unsigned int>> the constructed set of indices can be used to run a kernel on a specific set of particles.

// get the particles fluid ids
get_indexes_by_type<type,type_is_fluid>(vd.getPropVectorSort(),fluid_ids,vd.size_local(),vd.getVC().getgpuContext());
// get the particles fluid ids
get_indexes_by_type<type,type_is_border>(vd.getPropVectorSort(),border_ids,vd.size_local(),vd.getVC().getgpuContext());
auto part = fluid_ids.getGPUIterator(96);
CUDA_LAUNCH(calc_forces_fluid_gpu,part,vd.toKernel_sorted(),fluid_ids.toKernel(),NN.toKernel(),W_dap,cbar);
part = border_ids.getGPUIterator(96);
CUDA_LAUNCH(calc_forces_border_gpu,part,vd.toKernel_sorted(),border_ids.toKernel(),NN.toKernel(),W_dap,cbar);

the function get_indexes_by_type has three arguments the first is the vector of the properties of the particles. In this case because we use the sorted particles to calculate forces, so we have to get the indexes for the sorted particles with vd.getPropVectorSort(). In case we want to use the non sorted we use vd.getPropVector(). The second argument is the output containing the indexes of the particles types we want to get. Because the vector can contain ghost particles and real particles setting with the third argument we indicate we want only real particles and no ghost particles The last argument is the GPU context handle

we report the full code here