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

Debugging technics - CFD code developing

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By FMDenaro

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 8, 2016, 10:59
Default Debugging technics - CFD code developing
  #1
Member
 
Join Date: Apr 2012
Posts: 71
Rep Power: 14
leo_NM is on a distinguished road
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.
leo_NM is offline   Reply With Quote

Old   June 8, 2016, 12:00
Default
  #2
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,764
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
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.
mprinkey likes this.
FMDenaro is offline   Reply With Quote

Old   June 9, 2016, 11:22
Default
  #3
Member
 
Kaya Onur Dag
Join Date: Apr 2013
Posts: 94
Rep Power: 13
kaya is on a distinguished road
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.
kaya 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
CFD Code with Fortran murat Main CFD Forum 0 October 11, 2009 17:05
Where do we go from here? CFD in 2001 John C. Chien Main CFD Forum 36 January 24, 2001 21:10
CFD JOBS and Expected Salary.... Noel Harrison Main CFD Forum 11 November 22, 2000 07:15
CFD for fans & blower housings David Carroll Main CFD Forum 8 August 24, 2000 17:25
educational software package recommendations Allan Morrison Main CFD Forum 5 April 5, 1999 12:07


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