10 minute physics tutorial part 16 (Cloth simulation) translated to Julia

Over the weekend, I translated one of the 10 minute physics tutorials by Matthias Müller for cloth simulation. It’s a fun exercise, and many things worked out easier than expected. (I was actually trying to test if Julia is the right tool compared to Cuda or Python Warp).

I’m just sharing it here as it’s a fun real-time simulation which some of you might enjoy. The Julia code is also quite reasonable (~400 lines of code):

Source code: GitHub - SteffenPL/LearnGPUParticles
(If someone spots mistakes or possible improvements, please tell me.)

My next aim is to finally implement spatial hash tables on the GPU properly, to do some particle simulations. (Maybe this is a bit related to the projects of @Ahmed_Salih, cp. SPHExample.jl.)

There was actually one question I was unsure about:

  • As far as I know, there is no easy way to directly pass a CUDA.jl array to a suitable mesh type for Makie to avoid a copy to the CPU. Is that correct?
26 Likes

It’s complicated… It should be possible, but the CUDA api is so weird for this, that we haven’t really integrated it well yet, since it would take a considerable amount of work.
This is the last example we tried:

2 Likes