CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (http://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   foamLog (http://www.cfd-online.com/Forums/openfoam-post-processing/98942-foamlog.html)

fferroni March 22, 2012 07:53

foamLog
 
Hello

I use foamLog for the log-file that I have, which has several thousand time-steps, and each time-step has many iterations for different parameters.

When i use foamLog, it gives me a logs folder output, however the usually just contain a single number. Rather confused, since I was expecting many thousands of values at least for each timestep with regards to residuals...

Any ideas?

F

gdeneyer March 30, 2012 16:42

1 Attachment(s)
Hello,

I got the same problem with foamLog. Finally, I did a small app(really poor programming ...) reading the log file as I wished. It's done to read the drag and lift coefficient but you can easily change it to plot the residuals.

I put my code in attachment but if you find the solution for foamLog I would be happy to have further informations ;-)

fferroni April 6, 2012 17:05

Hmm hello thank you for the script.

So if my time step was 0.01, and each time step looked like the thing below... what would i need to change? :confused:

Thank you.

Francesco

--------------

Time = 0.01

Courant Number mean: 0 max: 0.136
Iteration No 1
DILUPBiCG: Solving for Ux, Initial residual = 1, Final residual = 2.99476e-08, No Iterations 2
DILUPBiCG: Solving for Uy, Initial residual = 0, Final residual = 0, No Iterations 0
DICPCG: Solving for p, Initial residual = 1, Final residual = 9.41218e-08, No Iterations 737
time step continuity errors : sum local = 7.34978e-12, global = -2.46208e-14, cumulative = -2.46208e-14
DICPCG: Solving for p, Initial residual = 3.59809e-05, Final residual = 9.55252e-08, No Iterations 604
time step continuity errors : sum local = 1.37508e-08, global = -2.92546e-11, cumulative = -2.92792e-11
DICPCG: Solving for p, Initial residual = 4.44746e-07, Final residual = 9.49638e-08, No Iterations 4
time step continuity errors : sum local = 1.29697e-08, global = 1.91066e-10, cumulative = 1.61787e-10
DICPCG: Solving for PotE, Initial residual = 0, Final residual = 0, No Iterations 0
Iteration No 2
DILUPBiCG: Solving for Ux, Initial residual = 0.00227304, Final residual = 1.46529e-07, No Iterations 2
DILUPBiCG: Solving for Uy, Initial residual = 0.00270324, Final residual = 2.49839e-07, No Iterations 2
DICPCG: Solving for p, Initial residual = 0.000117855, Final residual = 9.99383e-08, No Iterations 451
time step continuity errors : sum local = 1.32192e-08, global = -1.70539e-09, cumulative = -1.5436e-09
DICPCG: Solving for p, Initial residual = 1.19641e-05, Final residual = 9.84828e-08, No Iterations 400
time step continuity errors : sum local = 1.30281e-08, global = 1.83845e-11, cumulative = -1.52522e-09
DICPCG: Solving for p, Initial residual = 1.42252e-06, Final residual = 8.98636e-08, No Iterations 4
time step continuity errors : sum local = 1.1888e-08, global = 1.05161e-10, cumulative = -1.42006e-09
DICPCG: Solving for PotE, Initial residual = 0, Final residual = 0, No Iterations 0
Iteration No 3
DILUPBiCG: Solving for Ux, Initial residual = 1.68533e-05, Final residual = 4.37189e-07, No Iterations 1
DILUPBiCG: Solving for Uy, Initial residual = 2.16801e-05, Final residual = 5.83916e-07, No Iterations 1
DICPCG: Solving for p, Initial residual = 1.83766e-06, Final residual = 8.53894e-08, No Iterations 10
time step continuity errors : sum local = 1.12961e-08, global = 7.52266e-11, cumulative = -1.34483e-09
DICPCG: Solving for p, Initial residual = 2.3926e-07, Final residual = 9.16602e-08, No Iterations 1
time step continuity errors : sum local = 1.21256e-08, global = 7.26966e-11, cumulative = -1.27213e-09
DICPCG: Solving for p, Initial residual = 9.89624e-08, Final residual = 9.89624e-08, No Iterations 0
time step continuity errors : sum local = 1.30916e-08, global = 7.25284e-11, cumulative = -1.19961e-09
DICPCG: Solving for PotE, Initial residual = 0, Final residual = 0, No Iterations 0
ExecutionTime = 4.13 s ClockTime = 4 s

gdeneyer April 6, 2012 19:02

as you see I begin each block with a test condition to see if I get
- DragCoefficient
- pressureDragCoefficient
- viscDragCoefficient
- liftCoefficient


the code
strstr(chaine,"DragCoefficient")
returns 1 if DragCoefficient is into the line chaine and 0 if not.

so if you want to plot the p final residual for example, you'll need to put the condition

strstr(chaine,"Solving for p") which will be equal to 1 just for the good lines and

then

index = stristr(chaine,"Final residual ="); which will return the index of the letter "F" (first letter of the subchain)

and finally

index = index + 17;
// index of the first number after Final residual
char* souschaine;
souschaine = strsub(chaine, index, index + 8);
// souschaine is the substring token from chaine with first index given by "index" and final index given by "index+8"

just don't make mistake with the initial if condition, as you have several times "Final residual", you need to put the condition well to be sure you're loading the good one

gschaider April 9, 2012 17:57

Quote:

Originally Posted by gdeneyer (Post 353531)
as you see I begin each block with a test condition to see if I get
- DragCoefficient
- pressureDragCoefficient
- viscDragCoefficient
- liftCoefficient


the code
strstr(chaine,"DragCoefficient")
returns 1 if DragCoefficient is into the line chaine and 0 if not.

so if you want to plot the p final residual for example, you'll need to put the condition

strstr(chaine,"Solving for p") which will be equal to 1 just for the good lines and

then

index = stristr(chaine,"Final residual ="); which will return the index of the letter "F" (first letter of the subchain)

and finally

index = index + 17;
// index of the first number after Final residual
char* souschaine;
souschaine = strsub(chaine, index, index + 8);
// souschaine is the substring token from chaine with first index given by "index" and final index given by "index+8"

just don't make mistake with the initial if condition, as you have several times "Final residual", you need to put the condition well to be sure you're loading the good one

Guys, I really admire you: parsing text files in C is .... something for the dedicated. That kind of job is programmed MUCH faster using some kind of scripting language (awk, perl, mighty python ...) using regular expressions (which also exist for C BTW). And even if the final C-solution is 2-3 times faster than the script .... you'll have to parse a lot of logs to make up for the extra time it took you to program it

I'm not 100% sure which intermediate iteration data you need, but maybe pyFoamPlotWatcher.py with a right cutomRegexp and the --write-files-option might be what you want (it writes multiple files if the residual of that name is there multiple times during a timestep)

fferroni May 18, 2012 06:12

Hi

I just installed pyFoam and am trying to use it on my old log files...

Installation was very easy. Now I tried "pyFoamPlotWatcher.py proc4_out" but I get the following error:

sh: gnuplot: command not found
sh: gnuplot: command not found
sh: gnuplot: command not found
Traceback (most recent call last):
File "/usr/local/bin/pyFoamPlotWatcher.py", line 5, in <module>
PlotWatcher()
File "/Library/Python/2.6/site-packages/PyFoam/Applications/PlotWatcher.py", line 35, in __init__
nr=1)
File "/Library/Python/2.6/site-packages/PyFoam/Applications/PyFoamApplication.py", line 213, in __init__
result=self.run()
File "/Library/Python/2.6/site-packages/PyFoam/Applications/PlotWatcher.py", line 132, in run
run.start()
File "/Library/Python/2.6/site-packages/PyFoam/Execution/BasicWatcher.py", line 73, in start
self.lineHandle(line)
File "/Library/Python/2.6/site-packages/PyFoam/Execution/AnalyzedCommon.py", line 75, in lineHandle
self.analyzer.analyzeLine(line)
File "/Library/Python/2.6/site-packages/PyFoam/LogAnalysis/FoamLogAnalyzer.py", line 125, in analyzeLine
self.analyzers[nm].doAnalysis(line)
File "/Library/Python/2.6/site-packages/PyFoam/LogAnalysis/TimeLineAnalyzer.py", line 43, in doAnalysis
self.notifyNewTime(m)
File "/Library/Python/2.6/site-packages/PyFoam/LogAnalysis/TimeLineAnalyzer.py", line 32, in notifyNewTime
self.notify(float(m.group(2)))
File "/Library/Python/2.6/site-packages/PyFoam/LogAnalysis/LogLineAnalyzer.py", line 65, in notify
f(*data)
File "/Library/Python/2.6/site-packages/PyFoam/LogAnalysis/FoamLogAnalyzer.py", line 71, in setTime
listener.timeChanged()
File "/Library/Python/2.6/site-packages/PyFoam/Execution/StepAnalyzedCommon.py", line 32, in timeChanged
self.timeHandle()
File "/Library/Python/2.6/site-packages/PyFoam/Execution/GnuplotRunner.py", line 271, in timeHandle
self.plots[p].redo()
File "/Library/Python/2.6/site-packages/PyFoam/Basics/GeneralPlotTimelines.py", line 112, in redo
self.doReplot()
File "/Library/Python/2.6/site-packages/PyFoam/Basics/GnuplotTimelines.py", line 115, in doReplot
self.replot()
File "/Library/Python/2.6/site-packages/PyFoam/ThirdParty/Gnuplot/_Gnuplot.py", line 333, in replot
self.refresh()
File "/Library/Python/2.6/site-packages/PyFoam/ThirdParty/Gnuplot/_Gnuplot.py", line 226, in refresh
self(self.plotcmd + ' ' + string.join(plotcmds, ', '))
File "/Library/Python/2.6/site-packages/PyFoam/ThirdParty/Gnuplot/_Gnuplot.py", line 210, in __call__
self.gnuplot(s)
File "/Library/Python/2.6/site-packages/PyFoam/ThirdParty/Gnuplot/gp_macosx.py", line 144, in __call__
self.flush()
IOError: [Errno 32] Broken pipe

Ideas?

I see you're one of the developers... awesome stuff!!

F

fferroni May 18, 2012 06:42

Dear Bernhard,

It appears to have done something if I use 'pyFoamStandardLogAnalyzer.py'

I get separate files with continuity and many other variables that I was logging, in columns of time, local, global, and cumulative.

Just to check, I get 9 separate files for i.e. pressure. Is that because it gives a separate file for each time in runs DICPGG (3 x 3 iterations)?

Thank you,

F

wyldckat May 18, 2012 11:11

Greetings to all!

Quote:

Originally Posted by fferroni (Post 361830)
sh: gnuplot: command not found

Well, I would say the first few lines are self explanatory... you don't have "gnuplot" installed! Either that, or the gnuplot command is something like gnuplot44.

I haven't got much experience (yet) with pyFoam, so I can't answer your latest post...

Best regards,
Bruno

gschaider May 21, 2012 17:05

Quote:

Originally Posted by fferroni (Post 361832)
Dear Bernhard,

It appears to have done something if I use 'pyFoamStandardLogAnalyzer.py'

I get separate files with continuity and many other variables that I was logging, in columns of time, local, global, and cumulative.

Just to check, I get 9 separate files for i.e. pressure. Is that because it gives a separate file for each time in runs DICPGG (3 x 3 iterations)?

Thank you,

F

Exactly. Usually you'll want to use the first because it should have the "worst" residual (the pyFoamPlotWatcher.py uses this for instance)

About your other problem: I agree with wyldcat: probably there is no gnuplot installed. Or under a different name


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