Closed trparry closed 1 year ago
Hi @trparry, thanks for the post! I am planning to replace the current slow voxelization, there is much faster algorithms on the internet. The two solutions I have currently implemented are not optimal:
voxelize_stl_hull
is on CPU and rather fast with N^2 scaling, but only voxelizes the hull and sometimes there are holeslbm.voxelize_stl
is on GPU, but it's the slow ray-cast approach that scales with N^5, where only N^3 can be parallelizedIdeally the voxelization should be way faster than an LBM time step, so coupled fluid + rigid body simulations work much faster.
I'll leave this issue open as a reminder for myself to implement it some time :)
Done! I found a quite ingenious solution that speeds up GPU voxelization by about 500x, reducing runtime from minutes to milliseconds. Details are in the v2.1 release notes.
This is awesome. Thank you!
Remesh in milliseconds 😱. This is great news ! Congrats on all this good work. My dream of creating a sandbox toy with rigid body/fluid interaction now seems more than feasible. Think Algodoo meets Powder Toy.
Hello Moritz, this is more of a feature enhancement than an issue. Due to your code's speed, I've realized that it may open doors into applications that have been under-researched.
Context: I am experimenting with getting a semi-real time (maybe 3-4s real time for every 1s simulation time) moving mesh simulation working on a Nvidia A100. This simulation involves fluid-solid interaction with the mid-grid bounce back boundaries you've implemented. During each timestep, FluidX3D sends forces and moments to my rigid body solver (with calculate_torque_on_object), and the rigid body solver calculates the resulting kinematics and sends rotation and translation matrices back to FluidX3d. I'm actually experimenting with the rigid body solver running on the same GPU using IPC. Right now I'm working on a single body pendulum to keep it simple. The end game is to do controller design on rigid body dynamics immersed in fluids. Multiphysics simulations have done similar things before, but combining control theory with fluid dynamics has been a challenge because controllers often involve trial and error. Trial and error on a simulation that takes many hours isn't practical, this is why I’m interested in LBM.
Now concerning the feature enhancement: I started with the tie fighter example where you detach a separate thread and revoxelize a new frame with the rotated mesh on CPU in parallel with LBM running on GPU. However in my scenario with fluid solid interaction we would need to solve the flow field before rotating/moving the mesh because the mesh movement is driven by the fluid and visa versa (in series). On large grids where we can't run close to real time, this isn't a big deal because LBM takes a lot longer than the revoxelization process anyways. However, if I were to try and get a simulation to run close to real time on a smaller grid (say only 4-5 million voxels), the revoxelization process on CPU could become a bottleneck and LBM would need to wait until the revoxelization process is complete in order to start on the next frame.
Do you have any thoughts on placing the revoxelization process onto the GPU as well? The two processes would still run in series with time, but each would be parallelized internally so that the overall process would be faster than doing it in series on CPU. I would appreciate your thoughts!