r/CFD • • Feb 03 '21

[February] Programming languages for CFD

As per the discussion topic vote, February's monthly topic is "Programming languages for CFD"

User /u/SignificantCell2 asked for Rust experiences, but that sounded overly specific so i op'ed'd it into this.

Talk about your experiences and preferences with various programming languages in the context of CFD programming.

43 Upvotes

72 comments sorted by

View all comments

Show parent comment

13

u/Overunderrated Feb 03 '21

I would say the differentiation comes about at larger scale. Fortran is absolutely wonderful for all things math and array-based -- concise, clear code with great performance.

Where it starts to suck is when you wander outside of the core numerics -- user interfaces, file io, graphics, options, yadda yadda. In large scale numerics codes (million+ lines) you'll find that actual number crunching code is exceptionally small, 5% or even 1% of the total code size. So it's not so much that I opt for C++ "because it's better for CFD", but "because it's better for literally everything else i have to do, and is also acceptable for the numerics stuff."

If you're talking toy codes or even academic-sized solvers, I agree it really doesn't matter much, although that's becoming less true with accelerator-based environments leaving fortran behind.

1

u/glypo Feb 04 '21

Apologies for my delayed response. I do agree to an extent, hence the upvote. I caveat my agreement that I feel it depends on the type of CFD tool you are coding. A commercial code with a GUI, integrated pre and post, and so on would be a nightmare in Fortan and relatively a dream in C++. I neither work in academia or on toy type codes. I'm relatively experienced (13th year in industry) and every code I have used is highly bespoke and optimised to our regime. Pre and post are very much separated so the solvers I'm using don't have much of this bloat, and in fact rely on libraries for reading meshes, writing output etc. In this type of application, I stand by my comment that it matters less between C++ and Fortran. Even today in 2021 when I speak to national labs (like NASA, Onera, NLR, DLR, etc) Fortran is being used, same with airframers (I'm less willing to name them). Horses for courses.

1

u/Paul-Scholes Oct 19 '23

Hello, what is airframers?