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 problem (http://www.cfd-online.com/Forums/openfoam-post-processing/79570-foamlog-problem.html)

Rickard.Solsjo August 27, 2010 04:53

foamLog problem
 
I everyone!
I want to plot my residuals, however when i run the command foamLog log I receive the output

Executing: awk -f ./logs/foamLog.awk log
awk: ./logs/foamLog.awk:29: N-DODECANECnt=0
awk: ./logs/foamLog.awk:29: ^ syntax error
awk: ./logs/foamLog.awk:30: N-DODECANEFinalResCnt=0
awk: ./logs/foamLog.awk:30: ^ syntax error
awk: ./logs/foamLog.awk:31: N-DODECANEItersCnt=0
awk: ./logs/foamLog.awk:31:

Generated XY files for:
C
CFinalRes
CIters
CO2
CO2FinalRes
CO2Iters
contCumulative
contGlobal
contLocal
CourantMax
CourantMean
executionTime
h
H2O
H2OFinalRes
H2OIters
hFinalRes
hIters
k
kFinalRes
kIters
N-DODECANE
N-DODECANEFinalRes
N-DODECANEIters
O2
O2FinalRes
O2Iters
p
pFinalRes
pIters
rho
rhoFinalRes
rhoIters
Separator
Time
Ux
UxFinalRes
UxIters
Uy
UyFinalRes
UyIters
Uz
UzFinalRes
UzIters[/SIZE]

Okay, so it looks like the n-dodecane doesnt work, I dont care.
But when i open the logs folder

foamLog.awk

This is all I have. Can it be a problem if the run was stopped before the endtime or whatever? Someone who got an idea?

camille.yvin August 30, 2010 09:01

try this :

http://www.cfd-online.com/Forums/ope...residuals.html

Rickard.Solsjo August 30, 2010 12:29

Fixed it.
Removed the fuel n-dodecane

sed -e "/$N-DODECANE/d" log > newLog
then use diff log newlog to make sure

paka September 22, 2010 23:03

I also step into some trouble...


-------- output --------
users-macbook:cavity user$ foamLog log
Using:
log : log
database : /Users/user/OpenFOAM/OpenFOAM-1.7.x/bin/foamLog.db
awk file : ./logs/foamLog.awk
files to : ./logs

Executing: awk -f ./logs/foamLog.awk log
awk: ./logs/pFinalRes_1 makes too many open files
input record number 47, file log
source line number 72

Generated XY files for:
CourantMax
CourantMean
Separator
Time
Ux
UxFinalRes
UxIters
Uy
UyFinalRes
UyIters
contCumulative
contGlobal
contLocal
executionTime
p
pFinalRes
pIters
users-macbook:cavity user$
-------- end of output --------------

I tried to run it on different cases, sometimes it will say 'too many open files' on different log file.

For example, for icoFoam/cavity tutorial, Ux_0 log (cat logs/Ux_0) looks like that:
0.005 1

just one line, nothing else. Other log files look similarly. They are all _0.

Any tip here?

Thanks,
K

paka September 23, 2010 07:25

Greetings all!

Reading more about awk I learned it cannot handle too big files. Appears the whole 'log' file is just too large.

Somebody must have had similar problem. I'm not running large cases, for example, one from icoFoam/cavity tutorial. That case is quite small, but the awk error appears anyway.

Does anyone here use foamLog?

Any workaround for this problem?

Thanks,
K

paka September 23, 2010 08:00

OK. Problem solved.

In each loop for each of output variables (i.e. Ux_0) the files were not closed, so AWK was getting "stuck" or whatever you call it. The result was the AWK error message saying "too many files opened".

Reading more about AWK I learned each time something is written into file the files should be closed properly, which means, use 'close(file)' command.

I modified slightly the foamLog file adding at line 395 the following statement:
echo " close(file)" >> $AWKFILE

This solves the problem and all the residuals are in logs/ folder.

I think this should be added as a fix into distribution.

Best,
K

paka September 23, 2010 16:11

1 Attachment(s)
'close(file)' syntax should be also added to lines 366, 373, 380. I think it is easier to substitute your own foamLog with the one attached here. Put it in OpenFOMA-X.X.X/bin/ folder.

Have a wonderful day everyone,
K

paka September 23, 2010 16:28

Hmm... I just tried to use the tool with interFoam and it seems the error still persists. When I run the tool it produces logs, but each of the log file has only one line with only one initial sample. All the files are the same, i.e.:


users:inflowtest user$ du -sh logs/*
4.0K logs/CourantMax_0
4.0K logs/CourantMax_1
4.0K logs/CourantMax_2
4.0K logs/CourantMean_0
4.0K logs/CourantMean_1
4.0K logs/CourantMean_2
4.0K logs/Separator_0
4.0K logs/Time_0
4.0K logs/alpha1FinalRes_0
4.0K logs/alpha1FinalRes_1
4.0K logs/alpha1Iters_0
4.0K logs/alpha1Iters_1
4.0K logs/alpha1_0
4.0K logs/alpha1_1
4.0K logs/contCumulative_0
4.0K logs/contCumulative_1
4.0K logs/contCumulative_2
4.0K logs/contGlobal_0
4.0K logs/contGlobal_1
4.0K logs/contGlobal_2
4.0K logs/contLocal_0
4.0K logs/contLocal_1
4.0K logs/contLocal_2
4.0K logs/executionTime_0
4.0K logs/foamLog.awk
4.0K logs/p_rghFinalRes_0
4.0K logs/p_rghFinalRes_1
4.0K logs/p_rghFinalRes_2
4.0K logs/p_rghIters_0
4.0K logs/p_rghIters_1
4.0K logs/p_rghIters_2
4.0K logs/p_rgh_0
4.0K logs/p_rgh_1
4.0K logs/p_rgh_2
4.0K logs/pcorrFinalRes_0
4.0K logs/pcorrIters_0
4.0K logs/pcorr_0
users:inflowtest user$

robdeb February 13, 2013 18:36

Quote:

Originally Posted by paka (Post 276240)
I also step into some trouble...


-------- output --------
users-macbook:cavity user$ foamLog log
Using:
log : log
database : /Users/user/OpenFOAM/OpenFOAM-1.7.x/bin/foamLog.db
awk file : ./logs/foamLog.awk
files to : ./logs

Executing: awk -f ./logs/foamLog.awk log
awk: ./logs/pFinalRes_1 makes too many open files
input record number 47, file log
source line number 72

Generated XY files for:
CourantMax
CourantMean
Separator
Time
Ux
UxFinalRes
UxIters
Uy
UyFinalRes
UyIters
contCumulative
contGlobal
contLocal
executionTime
p
pFinalRes
pIters
users-macbook:cavity user$
-------- end of output --------------

I tried to run it on different cases, sometimes it will say 'too many open files' on different log file.

For example, for icoFoam/cavity tutorial, Ux_0 log (cat logs/Ux_0) looks like that:
0.005 1

just one line, nothing else. Other log files look similarly. They are all _0.

Any tip here?

Thanks,
K

Hello paka,

I know it's an old post but I got the same error.
Do you finally find a solution?
I try to use your foamLog but OpenFOAM can't read it.

Thank you

Bernhard February 14, 2013 03:10

If this error is clearly reproducable for multiple cases, you may want to file a bugreport: http://www.openfoam.org/bugs/

banji October 12, 2013 06:33

With regards to paka's problem, I had a similar problem but i only modified the foamLog file adding at line 395 the following statement:
echo " close(file)" >> $AWKFILE

as he said. It works fine. (Thanks so much, Paka)

Modifying other lines created a new problem - printed the result for the last iteration, only i.e. just one line.

Fine November 19, 2014 21:57

foamLog fix
 
1 Attachment(s)
Hi

ran into the same problem of having too many files open. Fixed with a trick similar to that of Paka:

Change 1:
In foamLog file place a single "close file" command:
Code:

varName=varNameVal[1] "Iters"
        file=varName "_" subIter[varName]++
        file="$outputDir/" file
        extract(\$0, "No Iterations ", val)
        print $timeName "\t" val[1] > file
        close(file)

Change 2:
awk uses ">" to place a value in a file an overwrite any previous data in it. If you wish to append data to an existing file use ">>": I.e. the following section:
Code:

echo "    print $timeName \"\\t\" val[1] > file" >> $AWKFILE
should be replaced with:
Code:

echo "    print $timeName \"\\t\" val[1] >> file" >> $AWKFILE
Change 3 is the one that paka proposed the first time: place an
Code:

echo "    close(file)" >> $AWKFILE
after
Code:

echo "    ${counter}++" >> $AWKFILE
Attached is the modified foamLog file which works with OpenFOAM221. This can be extracted and copied and pasted in the $WM_PROJECT_DIR/bin folder.


All times are GMT -4. The time now is 13:53.