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

Best practices in CFD (code structure)

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

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   August 14, 2014, 14:29
Default Best practices in CFD (code structure)
  #1
Senior Member
 
Joachim
Join Date: Mar 2012
Location: Paris, France
Posts: 145
Rep Power: 15
Joachim is on a distinguished road
Hey everyone!

I would like to improve the organization of my CFD code (in Fortran 90), and I would gladly appreciate any suggestions/comments you might have!

To summarize, here is the current structure:

1. import grid / construct metrics, volumes, etc
2. initialize solution
----------------time loop---------------------
3. compute residuals
- compute roe fluxes (including turbulent terms)
- compute transport fluxes (both laminar and turbulent at same time)
- compute source terms if any
4. update solution (laminar and turbulent at same time)
5. impose new boundary conditions in ghost cells and update dependent variables
---------------------------------------------

I have constantly stored in memory the state variables, as well as dependent variables (pressure, temperature, speed of sound, viscosity, etc + turbulent quantities such as eddy viscosity, blending functions, etc). I read that in CFL3D, they only stored the primitive variables, but in FUN3D, they were basically storing everything. Which approach would you recommend?

Some people told me it might be better to separate laminar and turbulent subroutines, and put the latter in a big module. That would make things a bit more clear. However, if I consider the Roe fluxes computation for example, I will need uL and uR in for my turbulent fluxes too. It means that I either have to store them and waste memory or recompute them and waste CPU time...

I guess the new structure would look something like that:

1. import grid / construct metrics, volumes, etc
2. initialize solution
----------------time loop---------------------
3. compute NS residuals
4. add turbulent residuals
5. update solution (laminar and turbulent at same time, since my code is tighly coupled)
6. impose NS boundary conditions
7. impose turbulent boundary conditions
----------------------------------------------

I was also suggested to use structures for my grid, solution, etc. Any comment about that?

What is, in your opinion, the best way to structure a code? I know there is not a single right answer to that question, but I would gladly hear your suggestions!

Thank you very much!

Joachim
Joachim is offline   Reply With Quote

 

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
general ARCHITECTURAL structure of the code of a CFD code mecobio Main CFD Forum 0 August 12, 2013 08:04
Give me some advice CFD in Fortran code or Matlab code. tringuyenttt Main CFD Forum 4 May 29, 2013 08:32
STRUCTURE OF CFD CODE MAB Main CFD Forum 5 August 10, 2008 03:47
Structure of CFD code Shyam Main CFD Forum 5 April 26, 2006 12:04
ASME CFD Symposium Chris Kleijn Main CFD Forum 0 August 22, 2001 06:41


All times are GMT -4. The time now is 13:45.