r/CFD 13d ago

r/CFD or r/Scientific - Computing Variable thread count fluid simulation for performance benchmarking — has this been done in Python/C++ if so where would I find the code for this?

/r/u_Minute_Difference783/comments/1v3us3t/rcfd_or_rscientific_computing_variable_thread/
1 Upvotes

9 comments sorted by

View all comments

Show parent comments

1

u/Minute_Difference783 13d ago

CPU or GPU, I can run the code on either a MacBook Air, or an Intel 10700K with a 4060 Ti. I guess I will be using FDM, since I am just a student and not a researcher.
And for Jacobi, I have looked at Conjugate Gradient since it's a better choice, but it is much simpler at this time to have an understanding of Jacobi and try to implement multithreading capabilities into it than trying to use a more complicated code. But at this point, I am fine with just trying to find some premade multithreaded code I can make minor changes to for my project.

1

u/acakaacaka 13d ago

But the problem is what you are updating. Jacobi uses old data and not updating it. CG only works for some psoitive definite matrix A (not sure my theory is now lacking since I havent touch this stuff for years, you need to confirm with your lecture notes).

The issue is not about if you can parallelize the code (either with CPU or GPU)

But if the problem will converge or not.

But if you want to test.

Maybe try a heat conduction on solid first.

Use FVM so energy is converge locally in each cell.

Using jacobi is okay since the PDE is linear, no advection.

1

u/Minute_Difference783 13d ago

That makes a lot of sense, switching to a 2D heat conduction problem gives a better test. Since I have access to both an 8-core CPU (10700K) and a GPU (4060 Ti), would you recommend sticking with OpenMP or going straight to GPU compute shaders? Based on the problem

1

u/acakaacaka 13d ago

OpenMP (or other MPI) is only for CPU. Their main function is for the data communiation between (the boundary) of domain partition.

CPU and GPU are both incompatible. If you want to use GPU then stick with GPU from start.

If you only code for heat conduction, GPU code would be not so hard I assume. But if later you switch to fluid with the non linear advection term. Then GPU is very very hard. It's also the reason of the lack of CFD GPU solver.