CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Main CFD Forum

programming language for CFD, C, C++, FORTRAN,....

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

Like Tree2Likes
  • 1 Post By hadian
  • 1 Post By pc

Reply
 
LinkBack Thread Tools Display Modes
Old   August 26, 2008, 08:00
Default programming language for CFD, C, C++, FORTRAN,....
  #1
hadian
Guest
 
Posts: n/a
Hi i have developed CFD codes for years using Fortran. but some of the researchers believe that c or c++ are more robust for this purpose. since i want to recommend my students about this and all of them should follow the same language, i needs to get sure about the best programming language for this purpose. i prefer if the language has the capability of crating some plots (to show the residuals as the code is run) and be portable to be run on both windows and linux.

milad_ghiyami likes this.
  Reply With Quote

Old   August 26, 2008, 08:57
Default Re: programming language for CFD, C, C++, FORTRAN,
  #2
Jed
Guest
 
Posts: n/a
How ``HPC-oriented'' is the class? What sort of background do the students have? Have you considered python? It might be easier for students to become familiar with and you can call some high performance code with libraries such as petsc4py and pytrilinos (these interface to the corresponding parallel domain-decomposition packages). Otherwise my preference is for C. A lot of numerics libraries are now written in C, it is a reasonably small language that doesn't do strange symbol mangling, it's easy to link with external packages (many do not offer a Fortran interface, but you can always call Fortran from C).

It is slightly easier to write fast code in Fortran mostly because it is easier for the compiler to prove that pointers are not aliased (hance the `restrict' keyword in C99). The differences are very small however.

If you decide to use a C++ library in a critical way, it would make sense to use C++, but bear in mind that ``good'' C++ design involves wildly templated code which is really hard to understand and takes much longer to compile. Also, the language is complicated enough that students would pretty much have to know it already.

My $.02
  Reply With Quote

Old   August 26, 2008, 09:28
Default Re: programming language for CFD, C, C++, FORTRAN,
  #3
hadian
Guest
 
Posts: n/a
the students are Msc students and they major is hydraulic engineering. they are a little familiar with Fortran but not so good that can be considerable, so i can ask them to learn any other languages that is better for their researches. for python i am worry about the cpu time. python codes run very slow in comparison with compilers like c or Fortran. till now, it seems i should forget about c++. right?

  Reply With Quote

Old   August 26, 2008, 11:27
Default Re: programming language for CFD, C, C++, FORTRAN,
  #4
pc
Guest
 
Posts: n/a
Keep it simple.

You don't absolutely have to make plots as the code runs, so don't let that dictate your choice. You say you've used Fortran for years, so your learning curve is nil. It's an easy language for students to pick up. Go with it. The focus here should be on the methods, not on learning a language. Students can learn other languages later if they need to.

My own $0.02...
milad_ghiyami likes this.
  Reply With Quote

Old   August 26, 2008, 11:35
Default Re: programming language for CFD, C, C++, FORTRAN,
  #5
RNE
Guest
 
Posts: n/a
I'd sticky with Fortran90/95 or C.

Keep in mind that Fortran is much simpler to learn than C and, for a didatic purpose, your students would spend less time learning a programming language and, possibly, more time in your class.

I'd discard C++. It's pretty complex to have a good and fast C++ code running. Not to mention the hell of interfacing C++ with other languages. I'd let C++ for the computer scientists or scientist programmers.

Regarding Python, it would be slow only if you code the entire program using it. As Jed said, you can interface Python with Fortran or C, in the core parts, and your program would be as fast as the "pure" Fortran or C versions.
  Reply With Quote

Old   August 26, 2008, 11:37
Default Re: programming language for CFD, C, C++, FORTRAN,
  #6
RNE
Guest
 
Posts: n/a
I forgot to mention. My DSc program was made entirely in Fortran 90 and I've used GNUPlot to produce residual plots in run time without any problem (in Unix or Windows). You just need to write the files and call GNUPlot to load them in runtime.
  Reply With Quote

Old   August 26, 2008, 12:35
Default Re: programming language for CFD, C, C++, FORTRAN,
  #7
Fred
Guest
 
Posts: n/a
an old disscusion!

i think that when u develop from scratch, selection is no matter, CFD codes are not so large that we have to decopule and design it under an oop framework (need expert designer, else leads to useless codes as we see for several opensources), procedural can be quit sufficient

but if u develop on top of some tools, you may prefare to select a consistent language

further, depends on your goal, e.g. mathematicians that develop state-of-the-art methods, usually use script language (python, matlab, etc.), but they just solve some toy problems without cpu concern.

if u are fortran programmer, and happy with it, i think u can use it for future too
  Reply With Quote

Old   August 26, 2008, 21:09
Default Re: programming language for CFD, C, C++, FORTRAN,
  #8
prog
Guest
 
Posts: n/a
I do not have much to add but i personally work with C++. (But i do not mind working with any other language, i have programmed in many of them already).

The reason that i work with C++ is re-usability of code. This one point everyone seem to forget when talk about fortran or C, C++.

Over last few years i have written codes those are plug and play types. (its very easy to do this in C++). SO when i need to develop anything further i do not need to write most of the code, just use previously written code and concetrate on main thing. for example, there is a class for file utilities. I can just include this in header and use it in most of my programs. (No need to write it again).

Further on more complicated note. I have a graph type data structure class. (cell and its neighbours, control volume and nodes it has or control volume and the faces it has etc etc.).

Then there is a class for multigrid solver that constructs matrix based on this graph data structure. This multigrid solver is plug and play types.

So what is the use, well I can use the same two classes in unstructured grid solver. I used the same in cartesian type solver for immersed boundary method.

I used same in meshless type solver. Can use it many places without writing everything all over again.

This is why object oriented programming has advantages and C++ is my choice.

  Reply With Quote

Old   August 26, 2008, 21:23
Default Re: programming language for CFD, C, C++, FORTRAN,
  #9
prog
Guest
 
Posts: n/a
a stupid person can take most efficient language and still write most inefficient of code.

Languages are just tool, they are just syntax to tell computer to do what you wish.

The most important thing to learn is to learn to think and plan. Students should understand algorithms and they should know why this algo is best or what could be improved etc etc.

Suggest them to spend time planning their work, this is best thing you can teach them as teacher.

  Reply With Quote

Old   August 27, 2008, 00:15
Default Re: programming language for CFD, C, C++, FORTRAN,
  #10
Fred
Guest
 
Posts: n/a
notice that such reuseability r already possible in fortran, of course maybe by more effort which is neglegible in contrast to total developing time

PS: do not forget that several libraries r available in fortran and r quit reuseable
  Reply With Quote

Old   August 27, 2008, 00:37
Default Re: programming language for CFD, C, C++, FORTRAN,
  #11
prog
Guest
 
Posts: n/a
Agreed.

I am certainly not against fortran. In fact i am one of few guys who think language is just a tool. One should use what he feels comfortable with.

with newer versions of fortran, one can do a lot more than what people usually perceive.

And yes, it takes more effort and understanding. The bigger impediment for using fortran is availability of codes those use these new ideas and are easy to understand for learner.

Personally, if I were to tell my students to learn, I would definitely make them write a small flex/lex based parser compliler. This one exercise teaches so much about how langauge work that he will never feel need to worry about learning language. And shifting from one langauge to other will be easy.

  Reply With Quote

Old   August 28, 2008, 02:20
Default Re: programming language for CFD, C, C++, FORTRAN,
  #12
A.S.
Guest
 
Posts: n/a
Fred,

I am also a fortran 90 fan for CFD coding, but industry prefers C++. I feel its the graphics part where fortran is lacking.

I need a help from you, do you have any 2D grid generator with NURBS ( with curve discretization).

Thanks

Apoorv
  Reply With Quote

Old   August 28, 2008, 08:09
Default Re: programming language for CFD, C, C++, FORTRAN,
  #13
Steve
Guest
 
Posts: n/a
C++ has zero graphics capabilities. Nothing about graphics is mentioned in the language standard.
  Reply With Quote

Old   September 1, 2008, 07:15
Default Re: programming language for CFD, C, C++, FORTRAN,
  #14
Oh No another languege
Guest
 
Posts: n/a
The average C++ book is heavier than my computer, a good reason for me to stick to fortran.
  Reply With Quote

Old   September 4, 2008, 08:20
Default Re: programming language for CFD, C, C++, FORTRAN,
  #15
chenzhi
Guest
 
Posts: n/a
RNE: "Use GNUPlot to produce residual plots in run time without any problem (in Unix or Windows)" That sounds great, how do you manage to do that?
  Reply With Quote

Old   September 9, 2008, 22:19
Default Re: programming language for CFD, C, C++, FORTRAN,
  #16
HekLeR
Guest
 
Posts: n/a
Fortran is a great language. I love it's simplicity.

However, I think you might be in error in saying that the same reusability is available in fortran.

Many of the features in C++ addresss "generic programming" which is what the poster meant. The usage of templating together with function overloading & operator overloading, are immensely powerful capabilities just not available in fortran. I know fortran has some overloading capability but this on it's own is sort of handicapped without templating as well.

In this instance the poster has written a 'graph' class. If it is properly templated then that class can be used on *any* type he dreams up and the compiler does the rest. In FORTRAN you have to write a separate set of functions for each type.... I always thought this was kind of nasty.
  Reply With Quote

Reply

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
CFX11 + Fortran compiler ? Mohan CFX 20 March 30, 2011 18:56
GUI programming with FORTRAN ztdep Main CFD Forum 1 August 30, 2007 13:22
new programming language? m Main CFD Forum 7 December 28, 2005 23:11
Fortran programming and 64 bit machine Q Main CFD Forum 4 November 7, 2005 06:18
selection of Programming Language Masood Main CFD Forum 1 April 20, 2004 08:26


All times are GMT -4. The time now is 08:24.