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

Structure of CFD code

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

LinkBack Thread Tools Display Modes
Old   April 25, 2006, 04:52
Default Structure of CFD code
Posts: n/a
Hi all,

I am planning to start writing up a CFD code for my phd. Since mine is Higher Order, i need to develop the code from the scratch. Hence I thought it would be better to ask the experts to advise me of the structure of the code.

Is it advisable to store the variables as a bunch of arrays, or to store them in a structure

Also, is it recommendable to have a one dimensional array or a 3D array for storing the variables?

Scheme: FVM, Explicit time integration, LES/RANS (DES)

  Reply With Quote

Old   April 25, 2006, 05:12
Default Re: Structure of CFD code
Posts: n/a
structure of the code is very simple Start: Starting code Middle: Lot of middle code, and then some more lot of code. End: In the end there is some more code, its not important you can keep it empty and put this code in middle code part.
  Reply With Quote

Old   April 25, 2006, 06:29
Default Re: Structure of CFD code
Posts: n/a
First of all, any scientific code have 3 major parts :

- Pre-processing : user's data entry (input)

- Processing : code's core (calculus using numerical methods)

- Post-processing : display results (ouput)

For the pre-processing u can choose between 3 ways :

- classical step by step user entry : like when you use a dos or unix terminal

- file user entry : u'll have to specify a language or use a predifined one like CGNS and program an interpreter which will read the file and puts datas in their structures.

- graphical interface user entry : u'll have to build a GUI.

Same thing for the post-processing.

Of course you choice depend on your programming level and the language you choosed (c, c++, ada, java, fortran...)

Concerning data's structures there's many ways, and another time, that's depend on your programming level. U can use structures or classes (oriented object programming).

For arrays the best technique is to use chained lists, but it's really a hard way. But that's must not be your first priority. When your program will run correctly, then you'll try to improve and optimize it. But for now, I think it's preferable to use the techniques you master.

My advice : search for a good book on software engineering and another one on data's structures and algorithmics, that's will really help you to build a good code and save time.

Well, hope that will help you a little bit. If you have other questions you can send me an email.

PS : look for "Code Complete - A Practical Handbook Of Software Construction" by Steve McConnell.
  Reply With Quote

Old   April 25, 2006, 08:50
Default Re: Structure of CFD code
Posts: n/a
To answer the question posed (unlike the two previous responses)...

Structures are great for holding all the relevant data together in the right place. And also great for traversing networks (i.e. pointers to neighbours and all that). But I suspect your solver will work best on big arrays, so you'll need to build them up by pulling data from your structures each time you want to solve and then stuffing results back into the structures after each solution step.
  Reply With Quote

Old   April 25, 2006, 21:01
Default Re: Structure of CFD code
Posts: n/a
Thanks Steve.. Yes... Thats what i was worried about... Accessing the variabes through a structure requires extra work of pointing to the structure first.

As speed is the first priori, I will try to incorporate array blocks.

The next thing is the choice of 1D or 3D array for holding 3 dimensinal data set. I heard from my friends that in case of explicit schemes with fixed computational stencils, if properly programmed, 1D array can be much faster, as accessing any variable inside that array mostly involves atmost two additions, whereas in 3D (dynamic) array, it involves pointing to the base pointer, then next, then to the variable.

But, when the memory involved is huge, it is often advisable to have smaller chunks of memory allocated (as in 3D array) than a huge chunk as in 1D array.

What is your opinion?

Is the additional computational time involved in these access negligible when compared to the actual calculation involved?

  Reply With Quote

Old   April 26, 2006, 12:04
Default Re: Structure of CFD code
Posts: n/a
Well, you can make one more step of abstraction and try to see which solution is best. The user of your storage structure should not see whether it operates on 1D-arrays or 3D-arrays.
  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
STRUCTURE OF CFD CODE MAB Main CFD Forum 5 August 10, 2008 03:47
ASME CFD Symposium Chris Kleijn Main CFD Forum 0 August 22, 2001 06:41
user friendly cfd code waqar Main CFD Forum 19 August 18, 2000 16:31
cfd job Dr. Don I anyanwu Main CFD Forum 20 May 17, 1999 15:13
Commercial CFD code Hanson G. He Main CFD Forum 1 October 15, 1998 08:49

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