CFD Online Logo CFD Online URL
Home > Forums > Main CFD Forum

what language is the best for CFD?

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree3Likes
  • 1 Post By robo
  • 1 Post By mprinkey
  • 1 Post By sbaffini

LinkBack Thread Tools Display Modes
Old   April 23, 2015, 14:58
Default what language is the best for CFD?
New Member
Join Date: Mar 2015
Posts: 17
Rep Power: 4
serguei is on a distinguished road
what is your opinion, which the programming language the best for CFD software? What are the pluses and minuses for, let say for the top 3? What about C# vs C++ in that sense?
serguei is offline   Reply With Quote

Old   April 23, 2015, 15:13
Join Date: May 2013
Posts: 47
Rep Power: 6
robo is on a distinguished road
(all just opinion)
If you're doing a big development with any kind of HPC component, C/C++ or Fortran. If I was writing a larger, more general purpose code, those are what I would look to.

If I was writing a code for smaller problems on a personal computer, or for early stage prototyping or school or what have you, I would use python with the various scientific packages, simply because I find those utilities so helpful and python's syntax very clear and concise. Lots of people would also use Matlab for this purpose, which is fine if you have some way around the cost.

I would generally expect someone I was hiring to be proficient in one from both sets: something for scripting and something for HPC. I have very little experience with C# but I thought it was primarily oriented towards easing development for windows apps, which is not a feature I look for in CFD applications.
serguei likes this.
robo is offline   Reply With Quote

Old   April 23, 2015, 18:01
Senior Member
Michael Prinkey
Join Date: Mar 2009
Location: Pittsburgh PA
Posts: 327
Rep Power: 16
mprinkey will become famous soon enough
I agree with the above. I will expand a bit. You will never escape Fortran. But, IMO, if you are not doing CFD on a structured mesh, most of the merits of Fortran go away and all of the ugliness and inflexibility remain.

C is fine, but its limited syntax can lead to tedious coding, and it has its own brand of ugliness too, especially if you go too crazy with macros. Of this, I am certainly guilty.

C++ on the other hand is potentially wonderful and potentially ruinous. If you use C++, you have to limit your use of many of its wonderful features. It is easy to build really high-level constructs in C++ that lead to horribly performing code. Abstraction is in direct conflict with the expressiveness required for thread-level and SIMD-level parallelism. It only works if you design your data types, functions, classes etc with that lower-level performance in mind--abstractions should only be driven up from the low-level--vector pipelines, cache friendliness, etc. Otherwise, you are just philosophizing. OpenFOAM has already made about the most elegant C++ abstractions for CFD possible. The SIMD- and thread-level parallelism of OpenFOAM do leave a lot to be desired, so it stands as both a crowning achievement and a cautionary tale.

Lastly, Python is a wonderful language and numpy and scipy give you a wonderful workshop to quickly prototype. If you are investigating high-level algorithms, start here. You won't get production speed code from it, but you will quickly glean a thorough understanding of what algorithms work the best.

If you are a starting a production-level code development project and you already know precisely the algorithms you plan to use, I'd start low-level prototyping in C++ and continuously benchmark to see how much abstraction and syntatic sugar you can included without losing significant performance--again vectorization and thread-level performance--single CPU performance is essentially immaterial now. I will note that I have had some success with operator overloading and using chunks of solution variables to lay out clean vectorization opportunities for the compiler in C++.
serguei likes this.
mprinkey is offline   Reply With Quote

Old   April 23, 2015, 18:53
Senior Member
sbaffini's Avatar
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 707
Blog Entries: 17
Rep Power: 21
sbaffini will become famous soon enough
I need to say that, unless you are an OO guru looking for very specific stuff, Fortran 2003/2008 has everything you can desire for CFD, is much less verbose than other OO languages and almost identical to MATLAB. Obviously this is s personal opinion.
serguei likes this.
sbaffini is offline   Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Software Language for Coding CFD vsookrah Main CFD Forum 5 September 15, 2013 19:34
CFX basic language ndabir CFX 5 August 17, 2011 18:43
Additional Command Language -in Workbench! Elvira_Coot CFX 11 July 14, 2011 01:32
programming language for CFD, C, C++, FORTRAN,.... hadian Main CFD Forum 15 September 9, 2008 22:19
ALGOR? Its scripting language? Compare to Fluent? Chris Bailey Main CFD Forum 2 November 16, 2005 17:58

All times are GMT -4. The time now is 05:10.