|
[Sponsors] |
April 25, 2006, 05:52 |
Structure of CFD code
|
#1 |
Guest
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) Shyam |
|
April 25, 2006, 06:12 |
Re: Structure of CFD code
|
#2 |
Guest
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.
|
|
April 25, 2006, 07:29 |
Re: Structure of CFD code
|
#3 |
Guest
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. |
|
April 25, 2006, 09:50 |
Re: Structure of CFD code
|
#4 |
Guest
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. |
|
April 25, 2006, 22:01 |
Re: Structure of CFD code
|
#5 |
Guest
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? |
|
April 26, 2006, 13:04 |
Re: Structure of CFD code
|
#6 |
Guest
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.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
STRUCTURE OF CFD CODE | MAB | Main CFD Forum | 5 | August 10, 2008 04:47 |
ASME CFD Symposium | Chris Kleijn | Main CFD Forum | 0 | August 22, 2001 07:41 |
user friendly cfd code | waqar | Main CFD Forum | 19 | August 18, 2000 17:31 |
cfd job | Dr. Don I anyanwu | Main CFD Forum | 20 | May 17, 1999 16:13 |
Commercial CFD code | Hanson G. He | Main CFD Forum | 1 | October 15, 1998 09:49 |