|
[Sponsors] |
July 23, 2009, 07:21 |
Log File too Large
|
#1 |
Member
Julian Krick
Join Date: May 2009
Location: Guelph
Posts: 88
Rep Power: 17 |
Hallo,
I do have the following, rather banal problem: I'd like to direct the residuals of my simulation to a log file, in order to be able to plot them at some time. However, since my time step is very small, the log file expands quickly. I estimated that, if I run my simulation for 24 hours, the log file will have a size of approx. 3 gigabyte. So, how do you handle the size of your log files? Is there a possibility to restrict the size of the file to a certain limit, so that, for instance, only the last 1000 residuals are written? Cheers, Julian
__________________
grid generation: ICEM CFD 13.0 solver: CFX 13.0 |
|
July 23, 2009, 08:14 |
|
#2 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
julianFoam | gzip >theLog.gz or julianFoam | tail -10000 >theLog |
||
July 23, 2009, 08:21 |
|
#3 |
Senior Member
Henrik Rusche
Join Date: Mar 2009
Location: Wernigerode, Sachsen-Anhalt, Germany
Posts: 281
Rep Power: 18 |
Bernhard,
not sure that the second option will help. I think this will simply collect the first 10000 lines, write them into theLog and then stop. However, Julian want to have the last 10000 lines dynamically. So 10-10010 which implies rewriting the file from the start. I think the system tools for log-rotation will be helpful here, but don't know more than that. Henrik |
|
July 23, 2009, 09:01 |
|
#4 | ||
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
julianFoam | head -10000 >theLog But you're right. tail won't know the last 10k lines before the simulation ended Quote:
A workaround (beware: advertisement) that could reduce the amount of data written (but would still write all residuals so it would still be a lot of data) would be to run the solver with "pyFoamRunner.py --no-log". That would not write a log-file but extract the residuals from the standard-output and write them to the .analyzed-directory. Similar things might also work with the foamLog-etc-scripts that come with OF Bernhard |
|||
July 23, 2009, 09:11 |
|
#5 | |||
Member
Julian Krick
Join Date: May 2009
Location: Guelph
Posts: 88
Rep Power: 17 |
Thank you Bernhard and Henrik for your quick reply.
I tried both commands that you posted Quote:
Quote:
Where's the Problem? Quote:
__________________
grid generation: ICEM CFD 13.0 solver: CFX 13.0 |
||||
July 23, 2009, 09:23 |
|
#6 |
Senior Member
Henrik Rusche
Join Date: Mar 2009
Location: Wernigerode, Sachsen-Anhalt, Germany
Posts: 281
Rep Power: 18 |
Bernhard,
you simply write myLog and once it contains more than x lines you flush the handle, move the file to myLog.last and start a fresh myLog. We must not use use a pipe at the exit! So something like this Code:
julianFoam | betterLogger 10000 myLog Code:
cat myLog.last myLog > myLog Actually, it should not be hard to write such a shell-filter or pyFoam? Henrik |
|
July 23, 2009, 10:05 |
|
#7 | ||
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Quote:
|
|||
July 23, 2009, 10:09 |
|
#8 | |
Member
Julian Krick
Join Date: May 2009
Location: Guelph
Posts: 88
Rep Power: 17 |
Quote:
I tried the command Code:
rhoCentralFoam | betterLogger 10000 myLog Code:
bash: betterLogger: command not found
__________________
grid generation: ICEM CFD 13.0 solver: CFX 13.0 |
||
July 23, 2009, 10:11 |
|
#9 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
What it already has is --compress-option for PyFoamRunner.py that writes the logfile as a gz (the compression ratio is not optimal). I'm just not sure whether it is already in the last released version |
||
July 23, 2009, 10:17 |
|
#10 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
|
||
July 23, 2009, 10:46 |
|
#11 |
Senior Member
Henrik Rusche
Join Date: Mar 2009
Location: Wernigerode, Sachsen-Anhalt, Germany
Posts: 281
Rep Power: 18 |
Bernhard,
you have little faith Code:
#!/usr/bin/perl use strict; my $nLines = 0; my $maxLines = shift; my $file = shift; open(OF, "> $file"); while ( <> ) { # print $_; // Uncomment for betaTee if ( $nLines++ == $maxLines ) { system("mv $file $file.last"); open(OF, ">$file"); $nLines = 1; } print OF $_; } Julien: cut & paste the code into a text file and name is "betaLogger". Then execute chmod u+x betaLogger Code:
julianFoam | betaLogger 1000 log |
|
July 23, 2009, 11:05 |
|
#12 | |
Member
Julian Krick
Join Date: May 2009
Location: Guelph
Posts: 88
Rep Power: 17 |
Quote:
__________________
grid generation: ICEM CFD 13.0 solver: CFX 13.0 |
||
June 12, 2015, 01:44 |
|
#13 |
Senior Member
Huynh Phong Thanh
Join Date: Aug 2013
Location: Ho Chi Minh City
Posts: 105
Rep Power: 13 |
Hello,
I did following step above as Henrik guide, but I met error Code:
betaLogger: command not found Thanks |
|
November 30, 2015, 07:43 |
|
#14 |
Member
|
Hi,
@Hiuluom Have you tried to execute the script directly by using julianFoam | ./betaLogger 1000 log instead ? I have a question for Henrik. First of all thank you for the script. I have a problem when I use it for parallel runs, it returns a blank file. Any idea why ? The command I run is: runParallel nameofsolver nbProcs | betaLogger 1000 log |
|
May 31, 2016, 14:52 |
|
#15 |
New Member
Hauke Stachel
Join Date: Feb 2016
Posts: 6
Rep Power: 10 |
Hi,
thanks to Henrik and Bernhard for this nice post and script, it was really helpful. I do not know if someone is still interested in this, but to run the "betaLogger" in a bash script (as faab has done I assume), I just wrote instead the "runParallel" command the proper line: Code:
mpirun -np $np solverName -parallel | ./betaLogger 1000 logFileName Cheers Hauke |
|
February 14, 2019, 14:04 |
|
#16 | |
Senior Member
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 16 |
Quote:
Hi Can you rewrite it into bash? I am running my cases on remote machine and there is no perl
__________________
best regards pblasiak |
||
February 14, 2019, 14:50 |
|
#17 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Me? Rewrite what into bash? I'm sorry: no Reasons: a) I only use bash to glue commands together. That's what it was designed for. Not "real" programming b) there is a reason that log-analysis is usually done in proper programming languages c) I don't need it and you're not a customer. These are usually the reasons why I write stuff and that is enough to fill my time
__________________
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 15, 2019, 06:56 |
|
#18 |
Senior Member
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 16 |
Ok
I thought that code of betaLogger is easy to rewrite into bash thnks for reply
__________________
best regards pblasiak |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Convection discretization schemes for LES | sek | OpenFOAM Running, Solving & CFD | 38 | July 31, 2017 15:30 |
Changing the grid on the same set-up | Katya | FLUENT | 7 | October 8, 2009 17:31 |
[OpenFOAM] Paraview command not found | hardy | ParaView | 7 | September 18, 2008 05:59 |
DxFoam reader update | hjasak | OpenFOAM Post-Processing | 69 | April 24, 2008 02:24 |
Importing I-DEAS unv file | hbetb | FLUENT | 1 | August 10, 2001 14:22 |