I have a log file like this:
Starting time loop
Courant Number mean: 0 max: 0
deltaT = 0.0012
Time = 0.0012
DILUPBiCGStab: Solving for Ux, Initial residual = 1, Final residual = 4.8276e-08, No Iterations 1
DILUPBiCGStab: Solving for Uy, Initial residual = 1, Final residual = 2.23172e-07, No Iterations 1
DILUPBiCGStab: Solving for Uz, Initial residual = 1, Final residual = 2.80701e-08, No Iterations 1
DILUPBiCGStab: Solving for T, Initial residual = 0.999922, Final residual = 4.3295e-07, No Iterations 1
DICPCG: Solving for p_rgh, Initial residual = 1, Final residual = 0.00904671, No Iterations 163
time step continuity errors : sum local = 8.39133e-07, global = -8.63793e-09, cumulative = -8.63793e-09
DILUPBiCGStab: Solving for epsilon, Initial residual = 0.00291157, Final residual = 2.1992e-06, No Iterations 1
DILUPBiCGStab: Solving for k, Initial residual = 1, Final residual = 0.00101111, No Iterations 1
ExecutionTime = 2.53 s ClockTime = 3 s
Courant Number mean: 0.00447015 max: 0.356735
deltaT = 0.00143547
Time = 0.00263547
DILUPBiCGStab: Solving for Ux, Initial residual = 0.334632, Final residual = 3.26106e-05, No Iterations 1
DILUPBiCGStab: Solving for Uy, Initial residual = 0.325756, Final residual = 1.62512e-05, No Iterations 1
DILUPBiCGStab: Solving for Uz, Initial residual = 0.379719, Final residual = 2.45476e-05, No Iterations 1
DILUPBiCGStab: Solving for T, Initial residual = 0.110323, Final residual = 1.51228e-05, No Iterations 1
DICPCG: Solving for p_rgh, Initial residual = 0.135502, Final residual = 0.00128893, No Iterations 152
time step continuity errors : sum local = 3.78267e-06, global = 5.94272e-08, cumulative = 5.07892e-08
DILUPBiCGStab: Solving for epsilon, Initial residual = 0.0132143, Final residual = 9.90056e-06, No Iterations 1
DILUPBiCGStab: Solving for k, Initial residual = 0.27268, Final residual = 0.000279373, No Iterations 1
ExecutionTime = 3.86 s ClockTime = 4 s
and my gnuplot script is like this:
set terminal png
set output 'res.png'
set logscale y
set title "Residuals"
set ylabel 'Residual'
set xlabel 'Time [s]'
dt = 0.001
plot "< cat log | grep 'Solving for Ux' | cut -d' ' -f9 | tr -d ','" using ($0*dt):1 title 'Ux' with lines,\
"< cat log | grep 'Solving for Uy' | cut -d' ' -f9 | tr -d ','" using ($0*dt):1 title 'Uy' with lines,\
"< cat log | grep 'Solving for Uz' | cut -d' ' -f9 | tr -d ','" using ($0*dt):1 title 'Uz' with lines,\
"< cat log | grep 'Solving for T' | cut -d' ' -f9 | tr -d ','" using ($0*dt):1 title 'T' with lines,\
"< cat log | grep 'Solving for p' | cut -d' ' -f9 | tr -d ','" using ($0*dt):1 title 'p' with lines
set terminal x11
set output
replot
pause 1
reread
Basically, it grabs the "Solving for Ux", then get the 1st number at "Initial residual" then plot it. Each block (starting from Courant Number mean to Clocktime) is 1 iteration. The real time is iteration * deltaT. So, 1st iteration is 0.0012 sec, 2nd, iteration is 2*0.00143547 = 0.0028 sec....etc.
If the deltaT is constant, then I can just set it like the script above and multiply it when plotting, e.g. using ($0*dt):1. Then from above, I just set a single value for dt.
However, my deltaT changes so how do we contribute this to the code? I can use the following bash command to get the values for deltaT:
cat log | grep -v -e 'ClockTime =' -e 'ExecutionTime = ' -e 'Solving for' -e 'time step' -e 'Courant' -e 'Time' | cut -d' ' -f3 | tr -cd '[:digit:].\n'
But I do not know how to set these as variables to plot. I tried:
dt = "cat log | grep -v -e 'ClockTime =' -e 'ExecutionTime = ' -e 'Solving for' -e 'time step' -e 'Courant' -e 'Time' | cut -d' ' -f3 | tr -cd '[:digit:].\n'"
but couldnt plot it. Gnuplot gave something like "error in piping".