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

CFD and programming

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 20, 2009, 22:39
Default CFD and programming
  #1
Member
 
Join Date: Mar 2009
Posts: 62
Rep Power: 17
RenardP is on a distinguished road
Hello,

I would like to see your opinions about choosing a programming language for CFD.

I think that for simple 1D application a language like Matlab, Maple or Mathematica can be used as a starting point, after all when you learn CFD you want to test algorithms and not to became a professional programmer. Same considerations can be applied to the new "managed" languages C# ...

For "simple" 2D and 3D applications any compiled language (C/C++, Fortran ...) that allows you to use MPI or OpenMP will do.

In the actual stage of computer development I don't think we can use an interpreted language for large applications. Sure the companies that sold Matlab, Maple or Mathematica will claim their software can use efficiently the new multi core architectures. But I ask, has anyone tried to implement for example in Matlab a large CFD code ( a small 2D application can easily have more then 10000 lines of code) ?

An advanced CFD application will actually use a combination of interpreted and compiled code in order to remain flexible.

What do you think of combinations like Python and C/C++ (Fortran) or (my favorite) Ruby and C/C++ ?
RenardP is offline   Reply With Quote

Old   March 20, 2009, 23:19
Lightbulb Characteristics of programming language
  #2
New Member
 
Prakash Ayappan
Join Date: Mar 2009
Posts: 25
Rep Power: 17
technocrat.prakash is on a distinguished road
Hi,

I believe any programmer like to write codes with small size with maximum features.

IN that manner C/FORTRAN is a good friend but lacks the visualisation feature. In that manner MATLAB has fantastic visualisation features. But the problem with that it ahs lot of unnecessary components ( with respect to CFD programming) that is needed. Other softwares I dont have any knowledge.

I recommend you

1) if you are going to practice/personnel go for CFD.
2) If you are going for writting softwares for another person / party its better to go for C/ FORTRAN
technocrat.prakash is offline   Reply With Quote

Old   March 20, 2009, 23:36
Default
  #3
Member
 
Join Date: Mar 2009
Posts: 62
Rep Power: 17
RenardP is on a distinguished road
I don't want to discuss the visualisation part now, only a CFD solver. For visualisation you can always use a free program (Paraview, Gnuplot) or some commercial program (Tecplot, FieldView).

BTW, I've already used Fortran 90 for a medium size 2D CFD solver, and C++ for a 3D version.
RenardP is offline   Reply With Quote

Old   March 21, 2009, 09:41
Default
  #4
New Member
 
Prakash Ayappan
Join Date: Mar 2009
Posts: 25
Rep Power: 17
technocrat.prakash is on a distinguished road
Its better to go for C/C++
technocrat.prakash is offline   Reply With Quote

Old   March 23, 2009, 03:02
Default Matlab for CFD programing
  #5
New Member
 
Join Date: Mar 2009
Posts: 4
Rep Power: 17
Hochola is on a distinguished road
Currently I am using MATLAB for CFD calculations. I solve the 2D and 3D problems with compressible flow with combustion.
Since I didn't have any programing experience in advance I find it very convinient to use a high level programing languange. Using short single line commands gives short programing time.
The total calculation time should include the code development time, and high level PL is favorable for codes used by one - four people and for special cases. Codes used by many people and many cases without the need for large modifications favors the fast and efficient PL like C++ and Fortran.
MATLAB has also very good debugging and visualization tools.

This is my opinion
Hochola is offline   Reply With Quote

Old   March 23, 2009, 04:15
Default
  #6
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,152
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
No offense, but i hardly believe that Matlab could ever be used for any serious CFD code. Matlab is invaluable for some things, as testing new ideas, simple visualizations, etc.

But, why use it for CFD when, with almost the same effort, a much more efficient and fast code could be developed in fortran?

Probably, with the new parallel environment, it will be faster, but the brute force computing will still be based on an interpreted language.

What size of grids do you usually use for a 3D computation and what is a typical time to solution for such a grid?
sbaffini is offline   Reply With Quote

Old   March 23, 2009, 08:13
Default Visualisation in Paraview
  #7
New Member
 
Prakash Ayappan
Join Date: Mar 2009
Posts: 25
Rep Power: 17
technocrat.prakash is on a distinguished road
Dear Renard,

Presently I am doing a 2D-variable duct prblem. I have written codes in C and got the reults in text. Next I like to visualize the results in Paraview. But I dont know how to format the file to give as the input to the paraview.

I checked a lot of trainning manuals for the formatting of input file. I startesd with VTK file extension and lot of hard work I didn't get any useful results.

So I need your help to give some advice on the formatting of the input file. I want to see the velocity, pressure contour & stream traces.

I have attached the problem & the results. Help Me.

Thanks in advance.
Attached Images
File Type: jpg Duct.JPG (14.0 KB, 11 views)
Attached Files
File Type: txt Results.txt (52.1 KB, 8 views)
technocrat.prakash is offline   Reply With Quote

Old   March 23, 2009, 09:04
Default
  #8
Member
 
Newton KF
Join Date: Mar 2009
Posts: 36
Rep Power: 17
NewtonKF is on a distinguished road
Hi Guys,

I'm developing my own code for my masters, and I used C++. My code purpose is to solve 3D NS with LES and combustion models. I'm using something like tecplot to view the variables and I had no bad experience with that. As you can imagine, my problems are in 3M volumes or more, so a fast code is necessary. Today I'm using a king of openMP and is it enough for now, but MPI is better for this size of domain, since it is very difficult to find big SMP machines.

I dont think programs like Matlab or Mapple can handle this size of problems... But i've never tested... So, again, if you are thinking about to use 1M or more volumes, I think it is best if you use C++ or fortran....

good luck...
NewtonKF is offline   Reply With Quote

Old   March 23, 2009, 18:20
Default
  #9
Member
 
Join Date: Mar 2009
Posts: 62
Rep Power: 17
RenardP is on a distinguished road
What was your experience with OpenMP ? I've just start to use it in C++, did you noticed some visible increase in performance versus a single core program ?

Paul
RenardP is offline   Reply With Quote

Old   March 23, 2009, 18:41
Default
  #10
Member
 
Newton KF
Join Date: Mar 2009
Posts: 36
Rep Power: 17
NewtonKF is on a distinguished road
Dear Paul,

I'm runing my code in a server with 8 cores and it showed a good increase of performance compared to the one core system... As I said before, I'm working with 3M or more volumes, so using openMP or MPI is very important to achieve results in reasonable time.

OpenMP is better for loops in the program, it is easy to implement and works fine.. But, if you have a DMP cluster, it is still better to work with MPI. I think, the better choice is to do MPI to interconnect nodes and use OpenMP in those nodes to use multiple cores.

Good luck...
NewtonKF is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming language for ICEM CFD? Michael B CFX 2 January 11, 2007 09:06
Programming knowledges for CFD users Everton Main CFD Forum 3 September 7, 2006 07:09
Programming in CFD Lam Main CFD Forum 7 May 27, 2004 05:12
new CFD Programming Forum Thinker Main CFD Forum 14 November 19, 2002 16:03
Where do we go from here? CFD in 2001 John C. Chien Main CFD Forum 36 January 24, 2001 21:10


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