CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Main CFD Forum (http://www.cfd-online.com/Forums/main/)
-   -   Software Language for Coding CFD (http://www.cfd-online.com/Forums/main/123448-software-language-coding-cfd.html)

vsookrah September 13, 2013 02:06

Software Language for Coding CFD
 
Hi All,

I am a new member to the CFD-Online Forums. I am a mechanical engineer and I have just started my Masters in Mechanical Engineering at the University of Toronto. I am taking a CFD course where our professor has allowed us to choose a software language to code our CFD projects in. We will not be using commercial software packages for this as we will develop the method for solving CFD problems from scratch. Each project will build upon the previous project and eventually we will solve a basic 2-D Navier Stokes problem. As I said above, we choose the language we would like to code in.

So, me being a ME with little coding background and the last time I really had to code anything was back in 1st year (7year ago), I am kind of in a tough spot. Our Professor suggested FORTRAN, or C/C++ and he also discouraged the use of MATLAB, which I am okay with because I know its not the greatest, while it is good. I am familiar with C++, but that was 7 years ago. That being said, I have read that FORTRAN is the best language to code in for CFD, especially for homemade code like this.

This leads me to why Im posting here. I would like to know if you have anyone can help me start using FORTRAN and if you have any ideas or comments on the language choice.

Jonas Holdeman September 13, 2013 09:42

The words "CFD course" and "from scratch" beg for Matlab. The first means you have a limited time to produce results. With Matlab you have a complete, integrated development, debugging, equation-solving, and visualization system working for you. I would suggest that you work out each problem in Matlab, get it working, and then translate to C++ or Fortran to show your instructor. "From scratch" is not exactly that. I assume you would be using solver and visualization packages or libraries in the higher languages. The question is, do you want to spend your time developing CFD algorithms or mucking around with programming details?

Alex C. September 13, 2013 10:56

Matlab looks also to me a really good development tool for starting use. With reasonable mesh size, calculation will be fast (especially for 1D and 2D case), even though the coding language is not itself fast.

Just make sure every feature that are unique to matlab are only used for debugging and are not involved in the algorithms you use, in order to avoid having translating issues.

levivad September 15, 2013 13:36

I would also suggest Matlab. When I took several similar courses it was a huge advantage being able to compare a linear equation solver I wrote to the correct solutions found in Matlab using A\b. The ability to test the code by replacing my routines with ones i know are correct saves hours of debugging.

cfdnewbie September 15, 2013 17:30

As a grad student, my professor gave us exactly the same task: Writing a 2D NS solver (Finite volume) from scratch and running it for 2D problems. He made us use Fortran or C, and while I realize that it is not as comfortable as Matlab, I would still start in Fortran. It gives you the speed you need, is not too difficult and arcane, and will prepare you for bigger codes to come. If you do use C or Fortran, just write a simple text-based export to Matlab and use the nice plotting features it has to do contour plots / line plots or animations.

Matlab is great for 1D schemes and playing around with the basic concepts, but beyond one dimension can become to slow to bear.

Another option would be to use Matlab and include C parts where you need the speed.

All the best!

jchawner September 15, 2013 19:34

If your professor discouraged the use of Matlab, don't do it.

Then begin writing code in the language you're more comfortable with: C/C++ or Fortran.


All times are GMT -4. The time now is 14:01.