|
[Sponsors] |
June 8, 2016, 11:59 |
Debugging technics - CFD code developing
|
#1 |
Member
Join Date: Apr 2012
Posts: 71
Rep Power: 14 |
Good night.
I am attending to a CFD course at my masters and the main projects of this course involve programming finite-difference solvers in 2D (~500 : 2000 lines of code). I have some programming background, enough to feel comfortable while programming in compiled languages such as C or fortran, but when dealing with CFD the trouble with debugging started. It's a very common tip to always increment your codes very slowly and to test it as soon as possible. Unfortunately some of the algorithms in CFD does not allow you to do this. For example, implementing an Euler implicit time-step in some simple model equations results in a lot of lines before you can actually compile and plot anything. My main question in this post was born when debugging one of the CFD course projects with (GDB). Actually, I spent more time debugging than programming anything (really frustrating process). For the purpose of debugging a CFD code is there any technique, tool and/or academic research that is focused in increase the efficiency of the debugging process for this applications (CFD code developing) ? (I heard about manufactured solutions but it seems to be very invasive approach). thank you all. |
|
June 8, 2016, 13:00 |
|
#2 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,882
Rep Power: 73 |
Usually, a student starts by learning to code simple linear model (for example a time depending convection-diffusion equation) in 1D and 2D cases. That helps to understand the main programming lines and using the compiler debuging options (very important). The same the students do for the elliptic equation.
At the end of this stages of learning, the student has the main verified subroutines for coding a simple NS solver. It still requires to take into account the coupling of the equations and the non-linearity but the time spent before helps in accelerating the coding of these further stages. |
|
June 9, 2016, 12:22 |
|
#3 |
Member
Kaya Onur Dag
Join Date: Apr 2013
Posts: 94
Rep Power: 13 |
here s my 2 cents
after about 2 years of struggle I developed a highly parallel pseudo-spectral NS solver for wind energy les applications. I am not as experienced as some ppl in the forum but I can confidently say that I am good at coding cfd. I ve tried debuggers, I like GUI of Totalview - but wasn't that useful to me with mpi. I ended up using Matlab and excel aside of fortran and found it being the best I had to write my code from scratch for I don't know how many times and found out that it actually takes less time in total if I code both in matlab and fortran because debugging becomes easier and manageable in terms of time. You can estimate how long the whole process will take and kind of plan it in advance. I run both fortran and matlab codes for a single time step and compare a specific column of a specific array at the end of one single time step by manually copy-pasting to excel from matlab and fortran output. You can try saving a whole array and read it from matlab, substract and take the max absolute error-which must be machine if you're same on both sides. It is very unlikely that you end up with the same exact bug in both sides (this may not be true if you cheat and apply copy-paste-translate method). The problem with coding fortran alone was that you sometimes can't be sure if you have more bugs inside or its just the methodology you're using causing some troubles. But when you have another (preferably user friendly) language aside, see 1e-14 on difference of all arrays and the code still doesn't work, then you are confident that there's something else. Without matlab its hard to make that call and you just burn your eyes inside out in between fortran lines. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
CFD Code with Fortran | murat | Main CFD Forum | 0 | October 11, 2009 18:05 |
Where do we go from here? CFD in 2001 | John C. Chien | Main CFD Forum | 36 | January 24, 2001 22:10 |
CFD JOBS and Expected Salary.... | Noel Harrison | Main CFD Forum | 11 | November 22, 2000 08:15 |
CFD for fans & blower housings | David Carroll | Main CFD Forum | 8 | August 24, 2000 18:25 |
educational software package recommendations | Allan Morrison | Main CFD Forum | 5 | April 5, 1999 13:07 |