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

bug in FV code

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

Reply
 
LinkBack Thread Tools Display Modes
Old   December 12, 2008, 19:23
Default bug in FV code
  #1
Alex
Guest
 
Posts: n/a
Hi all,

I'm trying to find a bug in my code. My code seems to work for a range of cases (airfoil in a channel) but messes up on the most simple! I have a uniform 2D Cartesian grid with U=10 and V=0 on the left boundary. All other boundaries are set to zero gradient. Obviously the converged solution should be U=10, V=0, P=const. everywhere (I did say it was a simple case!). I initialise my solution to U=10 etc. (so the initialised solution is actually the correct result!) and set it going. After 10 iterations or so, the two right corners of the domain have a large pressure. This pressure alternates between +ve and -ve from one iteration to the next and keeps increasing in magnitude until NAN (after 10,000 iterations of so).

I've been trying to find whats up with this for some time now with no luck so any tests or suggestions you can think of to try and isolate the problem would be much appreciated.

FYI: the code is steady, 2D, finite volume, SIMPLE, with Rhie-Chow.

Thanks in advance

  Reply With Quote

Old   December 13, 2008, 17:52
Default Re: bug in FV code
  #2
Harish
Guest
 
Posts: n/a
Have you tried debugging the code using gdb or any other debugger ?
  Reply With Quote

Old   December 14, 2008, 14:09
Default Re: bug in FV code
  #3
pc
Guest
 
Posts: n/a
Sounds like a boundary condition problem. What boundary conditions are being applied at these corners? Is everything being extrapolated or is something anchored?
  Reply With Quote

Old   December 14, 2008, 16:46
Default Re: bug in FV code
  #4
Alex
Guest
 
Posts: n/a
Hi, thanks for the replies. I do use gdb but have not found it to be helpful in this case as I don't really know what to be looking for.

As for boundary conditions, I have simply set U(i,j)=U(i-1,j) on the right boundary, U(i,j)=U(i,j-1) on the top boundary and similarly for the bottom boundary and similarly for the V BC's. On the left boundary, U=10, V=0 is used. Pressure is extrapolated on to all boundaries.

Upon further investigation, I've found that writing all the x,y values of each node to a file and then re-reading this information from the file strangely works SOMETIMES. The only difference this step makes is in the floating point values being slightly different e.g. 1.000000000 becomes 0.9999999999. It seems that some tiny computational round-off error is causing a pressure gradient that should not be there and for some reason this grows over several thousand iterations to become problematic. As I mentioned, the pressure goes from +ve to -ve from one iteration to the next so it seems the pressure correction step may be over correcting (despite it being under-relaxed). Humm, this one has really got me!

Thanks for any help again.

  Reply With Quote

Old   December 15, 2008, 21:09
Default Re: bug in FV code
  #5
fluent-user
Guest
 
Posts: n/a
"he only difference this step makes is in the floating point values being slightly different e.g. 1.000000000 becomes 0.9999999999"

I can assure you this is not the cause of your very ligh values at the corners.

It seems you are doing some very silly mistake somewhere. (which is difficult for me to point out).

Check your code again very carefully, you might be skipping something thinking that it is obviously correct.

(once it took me 2 weeks to figure out what was wrong with my code, and the mistake was instead of 'i' i typed 'ii' in the loop (ii was another int defined). I kept overlooking it thinking this part is correct) and kept wondering where the bug is).

Check again. Pressure is very sensitive to mass imbalance and AP values. (I feel you are getting your AP values wrong).
  Reply With Quote

Old   December 16, 2008, 04:25
Default Re: bug in FV code
  #6
Ananda Himansu
Guest
 
Posts: n/a
You should not extrapolate the pressure on ALL boundaries. Either you should arbitrarily set the pressure to be zero at some arbitrary point of the domain, or else if you want only Neumann boundary conditions on the pressure, you should make sure that the pressure satisfies satisfies an integral condition. Check the literature for this latter condition.

Also, try setting v=5 boundary conditions at the inflow, and initialize v=5 everywhere accordingly.

  Reply With Quote

Reply

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
The FOAM Documentation Project - SHUT-DOWN holger_marschall OpenFOAM 242 March 7, 2013 13:30
Debugging Unsteady 2-D Panel Method Code: Wake Modeling RajeshAero Main CFD Forum 5 November 10, 2011 06:48
Design Integration with CFD? John C. Chien Main CFD Forum 19 May 17, 2001 15:56
What is the Better Way to Do CFD? John C. Chien Main CFD Forum 54 April 23, 2001 08:10
public CFD Code development Heinz Wilkening Main CFD Forum 38 March 5, 1999 12:44


All times are GMT -4. The time now is 16:24.