Tutorial of how to plot residuals !

 User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 LinkBack Thread Tools Display Modes
 February 4, 2013, 09:09 #61 Member   Martin Join Date: Dec 2011 Location: Latvia Posts: 54 Rep Power: 6 Awesome tool! Thank you! P.S. This post was made since it didn't work, but I found my issue seconds after I posted

 March 14, 2013, 19:15 #62 New Member   Ben Graves Join Date: Dec 2012 Posts: 18 Rep Power: 5 Thank you very much for this awesome step by step tutorial! -Ben

April 1, 2013, 07:07
Printing subiteration residuals
#63
Member

Ilya
Join Date: Dec 2011
Location: Russia
Posts: 95
Blog Entries: 41
Rep Power: 6
Quote:
 Originally Posted by anger Hi, you could change the line extracting the pressure to read: cat log | grep 'Solving for p' | cut -d' ' -f9 | sed -n 'p;N;N;N;N' | tr -d ','" title 'p' with lines If you had two pressure iterations, you would change the argument to sed to read 'p;N'. If the final residual should be plottet, replace f9 at the cut command with f13. Best, -Thomas
Dear Thomas and other foamers.

I tried some tests with gnuplot and discover that better to use something like this:

Code:
`"< cat log | grep 'Solving for p' | cut -d' ' -f13 | sed -n 10p | tr -d ','" title 'p' with lines`
where
Code:
`sed -n 10p`
means "print tenth string" (i have 10 subiterations for p).

Anybody could do some curious experiments in terminal copying this step by step
Code:
`cat log | grep 'Solving for p'`
Code:
`cat log | grep 'Solving for p' | cut -d' ' -f13`
__________________
practice makes perfect

 April 10, 2013, 09:26 #64 New Member   wan,Bangqi Join Date: Feb 2013 Posts: 7 Rep Power: 5 Code: ```DILUPBiCG: Solving for Ux, Initial residual = 0.11902604, Final residual = 0.0070412572, No Iterations 1 DILUPBiCG: Solving for Uy, Initial residual = 0.1142661, Final residual = 0.0057272586, No Iterations 1 DILUPBiCG: Solving for Uz, Initial residual = 0.11446305, Final residual = 0.0057460693, No Iterations 1 GAMG: Solving for p, Initial residual = 0.48817918, Final residual = 0.0019587405, No Iterations 6 GAMG: Solving for p, Initial residual = 0.49249198, Final residual = 0.0038667108, No Iterations 2 GAMG: Solving for p, Initial residual = 0.059867564, Final residual = 0.00021565867, No Iterations 3 GAMG: Solving for p, Initial residual = 0.010320323, Final residual = 5.6870971e-05, No Iterations 3 time step continuity errors : sum local = 2.0630983e-07, global = -1.0375901e-07, cumulative = 1.3807206e-07 Pressure gradient source: uncorrected Ubar = 0.0010286698, pressure gradient = -1.293371e-05 ExecutionTime = 1.71 s ClockTime = 2 s``` please could somone tell me how can i plot 'pressure gradient'?

April 10, 2013, 17:12
#65
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,972
Rep Power: 41
Quote:
 Originally Posted by wanxlxg Code: ```time step continuity errors : sum local = 2.0630983e-07, global = -1.0375901e-07, cumulative = 1.3807206e-07 Pressure gradient source: uncorrected Ubar = 0.0010286698, pressure gradient = -1.293371e-05 ExecutionTime = 1.71 s ClockTime = 2 s``` please could somone tell me how can i plot 'pressure gradient'?
I'd use pyFoamPlotWatcher.py (or the Runner) from http://openfoamwiki.net/index.php/Contrib_PyFoam with a customRegexp-file like this:
Code:
```pGrad {
expr "Pressure gradient source: uncorrected Ubar = (%f%), pressure gradient = (%f%)";
titles ( Ubar pGrad);
}```
But I'm extremely subjective in that matter
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request

April 11, 2013, 05:53
#66
Member

Ilya
Join Date: Dec 2011
Location: Russia
Posts: 95
Blog Entries: 41
Rep Power: 6
Quote:
 Originally Posted by wanxlxg Code: ```DILUPBiCG: Solving for Ux, Initial residual = 0.11902604, Final residual = 0.0070412572, No Iterations 1 DILUPBiCG: Solving for Uy, Initial residual = 0.1142661, Final residual = 0.0057272586, No Iterations 1 DILUPBiCG: Solving for Uz, Initial residual = 0.11446305, Final residual = 0.0057460693, No Iterations 1 GAMG: Solving for p, Initial residual = 0.48817918, Final residual = 0.0019587405, No Iterations 6 GAMG: Solving for p, Initial residual = 0.49249198, Final residual = 0.0038667108, No Iterations 2 GAMG: Solving for p, Initial residual = 0.059867564, Final residual = 0.00021565867, No Iterations 3 GAMG: Solving for p, Initial residual = 0.010320323, Final residual = 5.6870971e-05, No Iterations 3 time step continuity errors : sum local = 2.0630983e-07, global = -1.0375901e-07, cumulative = 1.3807206e-07 Pressure gradient source: uncorrected Ubar = 0.0010286698, pressure gradient = -1.293371e-05 ExecutionTime = 1.71 s ClockTime = 2 s``` please could somone tell me how can i plot 'pressure gradient'?
Just replace one of standart gnuplot's strings on this

cat log | grep 'Pressure gradient'
and add it to the end of gnuplot file.
__________________
practice makes perfect

 April 11, 2013, 07:08 #67 New Member   wan,Bangqi Join Date: Feb 2013 Posts: 7 Rep Power: 5 Thanks,all of you. i used this and it works Code: `plot "< cat log | grep 'Pressure gradient' | cut -d' ' -f11 | tr -d ','" title 'p' with lines` i have a question here, the code runs only with -f11, but it should be -f8 or not? from where should i start to count the pieces? thanks again, you are all good people

 July 29, 2013, 10:47 Problems with the Force Coefficients #68 Member   Join Date: Jul 2013 Posts: 48 Rep Power: 5 Hello everybody!! The threat is very old, but it was helpful anyway. THANK YOU!. I am using paraFOAM just since some weeks ago, and I am still learning the basics. The version that I am using is the 2.2.0 I managed to plot the Residuals and the Forces, but I am not able to get the Force Coefficients... I have the following lines calling to the functions in ControlDict: functions ( #include "forces" //to load the file as a function #include "forceCoeff" ); And the forceCoeff function is as follows: forceCoeffs { type forceCoeffs; enabled true; functionObjectLibs ("libforces.so"); outputControl timeStep; outputInterval 1; patches ("SPHERE"); //change to your patch name pName p; UName U; rhoName rhoInf; log true; rhoInf 998.2; CofR (0 0 0); liftDir (0 1 0); dragDir (1 0 0); pitchAxis (0 0 0); magUInf 0.001; lRef 1; Aref 1; } ); The folder with the required data is not even created! The case is the most simple, just a ball inside a laminar flux, nothing else... It is just to learn using the software. ANY HELP WOULD BE NICE!! THANK YOU VERY MUCH!

July 29, 2013, 13:21
#69
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,972
Rep Power: 41
Quote:
 Originally Posted by HHOS Hello everybody!! The threat is very old, but it was helpful anyway. THANK YOU!.
THANK YOU. Replacing a "D" with a "T" in this really made my day!

Quote:
 Originally Posted by HHOS I am using paraFOAM just since some weeks ago, and I am still learning the basics. The version that I am using is the 2.2.0 I managed to plot the Residuals and the Forces, but I am not able to get the Force Coefficients... I have the following lines calling to the functions in ControlDict: functions ( #include "forces" //to load the file as a function #include "forceCoeff" ); And the forceCoeff function is as follows: forceCoeffs { type forceCoeffs; enabled true; functionObjectLibs ("libforces.so"); outputControl timeStep; outputInterval 1; patches ("SPHERE"); //change to your patch name pName p; UName U; rhoName rhoInf; log true; rhoInf 998.2; CofR (0 0 0); liftDir (0 1 0); dragDir (1 0 0); pitchAxis (0 0 0); magUInf 0.001; lRef 1; Aref 1; } ); The folder with the required data is not even created!
Can't help you very concretely here.
a. Where do you expect the data to be created? Starting with 2.2 such stuff is written to a folder called postProcessing in the case, not the the case-directory itself
b. To make sure that the FO is actually read introduce an error that would make it fail (for instance "enabled neitherTrueNorFalse;")
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request

 July 30, 2013, 07:43 I got it! #70 Member   Join Date: Jul 2013 Posts: 48 Rep Power: 5 Yes, you are right gschaider, the data should be in the folder called postProcessing; and actually I managed to achieve it! When I was changing the "forces" file to check if OF was actually reading it, as you suggested, I noticed that the file was ending like: Code: ```... rhoInf 998.2; //Reference density for fluid } );``` So OF read it and not the next function which was actually the one for the coefficients.

 August 13, 2013, 23:31 How to generate residual plots for transient runs #71 New Member   Ravi Duggirala Join Date: Feb 2013 Posts: 2 Rep Power: 0 I have used the same method to plot residuals but how to plot "Time" in x-axis rather than timestep number. Regards Ravi

 September 10, 2013, 20:53 Rayleigh Benard Convection Problem #72 Member   Lucas Mutti Join Date: Aug 2013 Posts: 47 Rep Power: 6 Hello Wolfgang, First of all thank you very much for releasing this module that speeds us our research significantly. Second, I recognize that it has been a while since you last posted in this page. I am currently working on simulating a Rayleigh Benard Convection Problem and I am trying to do a mesh convergence analysis so I may know how long it takes my code to converge and consequently approach my stipulated tolerance of 10^-3. After going over your files I have noticed that the Residuals.txt do not include parameters such as temperature. As a beginner in OpenFOAM, I am not sure how I should modify your file to incorporate the temperature distribution. Would you be able to show me how to do so? Also, with regards to your other files (functions and forceCoeffs) are they applicable to every problem in fluid mechanics or only under aerodynamic problems? Thank you very much, Lucas Mutti

 September 11, 2013, 03:21 #73 Member   Join Date: Jul 2013 Posts: 48 Rep Power: 5 Hello Iramutti: I am completely new with OpenFOAM too, so I don't know if my reply will be useful. Besides I have never run a case where temperature is involved. Anyway, I guess that you can check the log file, and find the line where the Temperature residual is shown (maybe something like "Solving for T" ???), then, you just have to search for the correct string analogously to the example, with which I am reading the residuals for different variables (you have to remove all the # and all the explanations in the end of each line): Code: ```# plot "< cat log | grep 'Solving for Ux' | cut -d' ' -f9 | tr -d ','" title 'Ux' with lines,\ # Ux residuals # "< cat log | grep 'Solving for Uy' | cut -d' ' -f9 | tr -d ','" title 'Uy' with lines,\ # Uy residuals # "< cat log | grep 'Solving for Uz' | cut -d' ' -f9 | tr -d ','" title 'Uz' with lines,\ # Uz residuals # "< cat log | grep 'Solving for nuTilda' | cut -d' ' -f9 | tr -d ','" title 'nuTilda' with lines,\ # nuTilda residuals # "< cat log | grep 'Solving for omega' | cut -d' ' -f9 | tr -d ','" title 'omega' with lines,\ # omega residuals # "< cat log | grep 'Solving for k' | cut -d' ' -f9 | tr -d ','" title 'k' with lines,\ # k residuals # "< cat log | grep 'Solving for p' | cut -d' ' -f9 | tr -d ','" title 'p' with lines # p residuals``` I hope it will be OK. Regards

 October 24, 2013, 06:32 #74 Member   chen long Join Date: Dec 2012 Posts: 32 Rep Power: 5 where to find the residuals plot? it will generate automatically?

October 24, 2013, 06:50
#75
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,972
Rep Power: 41
Quote:
 Originally Posted by Jackie Chen where to find the residuals plot?
In the standard output of the solver
Quote:
 Originally Posted by Jackie Chen it will generate automatically?
No. That is the point of this whole thread
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request

 October 24, 2013, 23:14 #76 Member   chen long Join Date: Dec 2012 Posts: 32 Rep Power: 5 Hi Bernhard Thanks for your reply. Actually when i type the code "gnuplot Residuals", it shws "Residulas", line XXX: warning:skipping data file with no valid points". DO you have any idea about this?

October 27, 2013, 19:12
#77
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,972
Rep Power: 41
Quote:
 Originally Posted by Jackie Chen Hi Bernhard Thanks for your reply. Actually when i type the code "gnuplot Residuals", it shws "Residulas", line XXX: warning:skipping data file with no valid points". DO you have any idea about this?
I don't use the way of plotting described above. Check what is in the Residuals-file
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request

 February 9, 2014, 16:08 #78 New Member   Stephan Join Date: Feb 2014 Posts: 2 Rep Power: 0 Hey all, i have a problem according to plotting the residuals. After the command gnuplot Residuals i got the following error: Code: ```at: write error: Broken pipe plot "< cat log | grep 'Solving for Ux' | cut -d' ' -f9 | tr -d ','" title 'Ux' with lines, "< cat log | grep 'Solving for Uy' | cut -d' ' -f9 | tr -d ','" title 'Uy' with lines, "< cat log | grep 'Solving for k' | cut -d' ' -f9 | tr -d ','" title 'k' with lines, "< cat log | grep 'Solving for p' | cut -d' ' -f9 | tr -d ','" title 'p' with lines ^ "Residuals", line 8: warning: Skipping data file with no valid points plot "< cat log | grep 'Solving for Ux' | cut -d' ' -f9 | tr -d ','" title 'Ux' with lines, "< cat log | grep 'Solving for Uy' | cut -d' ' -f9 | tr -d ','" title 'Uy' with lines, "< cat log | grep 'Solving for k' | cut -d' ' -f9 | tr -d ','" title 'k' with lines, "< cat log | grep 'Solving for p' | cut -d' ' -f9 | tr -d ','" title 'p' with lines ^ "Residuals", line 8: warning: Skipping data file with no valid points plot "< cat log | grep 'Solving for Ux' | cut -d' ' -f9 | tr -d ','" title 'Ux' with lines, "< cat log | grep 'Solving for Uy' | cut -d' ' -f9 | tr -d ','" title 'Uy' with lines, "< cat log | grep 'Solving for k' | cut -d' ' -f9 | tr -d ','" title 'k' with lines, "< cat log | grep 'Solving for p' | cut -d' ' -f9 | tr -d ','" title 'p' with lines ^ "Residuals", line 8: warning: Skipping data file with no valid points plot "< cat log | grep 'Solving for Ux' | cut -d' ' -f9 | tr -d ','" title 'Ux' with lines, "< cat log | grep 'Solving for Uy' | cut -d' ' -f9 | tr -d ','" title 'Uy' with lines, "< cat log | grep 'Solving for k' | cut -d' ' -f9 | tr -d ','" title 'k' with lines, "< cat log | grep 'Solving for p' | cut -d' ' -f9 | tr -d ','" title 'p' with lines ^ "Residuals", line 8: warning: Skipping data file with no valid points plot "< cat log | grep 'Solving for Ux' | cut -d' ' -f9 | tr -d ','" title 'Ux' with lines, "< cat log | grep 'Solving for Uy' | cut -d' ' -f9 | tr -d ','" title 'Uy' with lines, "< cat log | grep 'Solving for k' | cut -d' ' -f9 | tr -d ','" title 'k' with lines, "< cat log | grep 'Solving for p' | cut -d' ' -f9 | tr -d ','" title 'p' with lines ^ "Residuals", line 8: x range is invalid``` Last edited by wyldckat; February 10, 2014 at 17:13. Reason: Added [CODE][/CODE]

February 10, 2014, 02:42
#79
Member

Ilya
Join Date: Dec 2011
Location: Russia
Posts: 95
Blog Entries: 41
Rep Power: 6
Quote:
 Originally Posted by Stephan8 Hey all, plot "< cat log | grep 'Solving for Ux' | cut -d' ' -f9 | tr -d ','" title 'Ux' with lines, "< cat log | grep 'Solving for Uy' | cut -d' ' -f9 | tr -d ','" title 'Uy' with lines, "< cat log | grep 'Solving for k' | cut -d' ' -f9 | tr -d ','" title 'k' with lines, "< cat log | grep 'Solving for p' | cut -d' ' -f9 | tr -d ','" title 'p' with lines ^ "Residuals", line 8: warning: Skipping data file with no valid points
RTFM.
Gnuplot documentation will help you. At least you can try to use command promt of GNU Plot and feed it there string by string. The result will surprize you.
__________________
practice makes perfect

 February 11, 2014, 05:57 does not work any more? #80 New Member   fabi Join Date: Jan 2014 Posts: 5 Rep Power: 4 skript does not work with OpenFoam 2.1.1

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Khan FLUENT 1 February 1, 2007 13:35 HS FLUENT 1 November 7, 2005 06:45 Madhukar Rapaka FLUENT 1 October 14, 2005 10:28 anindya Main CFD Forum 2 September 17, 2003 12:00 Karl CFX 2 June 24, 2003 23:13

All times are GMT -4. The time now is 20:34.

 Contact Us - CFD Online - Top