
次のログファイルがあります。
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
私のgnuplotスクリプトは次のようになります。
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
デフォルトでは「Solved Ux」を取得し、「初期残差」から最初の数字を取得してプロットします。各ブロック(Courant Numberの平均からClocktimeまで)は1回繰り返されます。実際の時間は繰り返し*deltaTです。したがって、最初の反復は0.0012秒で、2番目の反復は2 * 0.00143547 = 0.0028秒...などです。
deltaTが定数の場合は、上記のスクリプトのように設定し、プロットするとき($ 0 * dt):1を使用して乗算できます。その後、上記でdt値を設定しました。
しかし、私のdeltaTが変更された場合、これをコードにどのように反映しますか?次のbashコマンドを使用して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'
しかし、これを描く変数に設定する方法がわかりません。私は試した:
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'"
しかし、描くことはできません。 Gnuplotでは、「パイプエラー」などのエラーが発生します。
答え1
cut|tr
gnuplot部分を少し単純化できます。なぜなら、sumを経ずに8列で数字を見つけることができるからですcat
。例えば、
plot \
"< <log grep 'Solving for Ux'" using ($0*dt):8 title 'Ux' with lines,\
ダミーグラフを作成して「deltaT」のみを検索し、setdt()
行番号「$ 0」(行が0から始まるので、+ 1)と列3の番号を使用して関数を呼び出すことができます。
plot \
"< <log grep 'deltaT'" using (setdt($0+1,$3)):NaN notitle with lines,\
数値以外の値を使用すると、NaN
このデータのプロットを回避できます。
この関数は値を配列に格納し、値0を返します。
array dt[99]
setdt(row,value) = (dt[row] = row*value,0)
行番号で配列を索引付けして、プロットコマンドでこれらの値を使用します。
plot \
"< <log grep 'deltaT'" using (setdt($0+1,$3)):NaN notitle with lines,\
"< <log grep 'Solving for Ux'" using (dt[$0+1]):8 title 'Ux' with lines,\
...