CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   plot residuals in multiregion solver (https://www.cfd-online.com/Forums/openfoam/99472-plot-residuals-multiregion-solver.html)

val46 April 4, 2012 05:53

plot residuals in multiregion solver
 
Hello,

I would like to plot the residuals from a logfile with gnuplot.
A nice tutorial for that can be found here.
With single region solvers it works nice but not with multiregion solvers.

As an example, here is a timestep of a tutorial case:

Code:

Time = 0.0469758

Solving for fluid region bottomAir
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCG:  Solving for Ux, Initial residual = 0.05933919, Final residual = 1.875811e-09, No Iterations 2
DILUPBiCG:  Solving for Uy, Initial residual = 0.07216778, Final residual = 2.727341e-09, No Iterations 2
DILUPBiCG:  Solving for Uz, Initial residual = 0.06497582, Final residual = 2.468975e-09, No Iterations 2
DILUPBiCG:  Solving for h, Initial residual = 0.1391416, Final residual = 5.374545e-08, No Iterations 2
Min/max T:300 319.7154
GAMG:  Solving for p_rgh, Initial residual = 0.1779339, Final residual = 0.0008159564, No Iterations 3
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
time step continuity errors (bottomAir): sum local = 5.094676e-07, global = -1.166084e-10, cumulative = -1.841265e-07
GAMG:  Solving for p_rgh, Initial residual = 0.008835792, Final residual = 2.173498e-07, No Iterations 1000
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
time step continuity errors (bottomAir): sum local = 1.498523e-10, global = -2.259186e-12, cumulative = -1.841288e-07

Solving for fluid region topAir
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCG:  Solving for Ux, Initial residual = 0.08491977, Final residual = 4.188711e-09, No Iterations 4
DILUPBiCG:  Solving for Uy, Initial residual = 0.1317485, Final residual = 9.808667e-08, No Iterations 4
DILUPBiCG:  Solving for Uz, Initial residual = 0.094053, Final residual = 3.943191e-08, No Iterations 4
DILUPBiCG:  Solving for h, Initial residual = 0.00873557, Final residual = 9.642108e-08, No Iterations 3
Min/max T:299.9996 300
GAMG:  Solving for p_rgh, Initial residual = 0.03020841, Final residual = 0.0001659505, No Iterations 2
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
time step continuity errors (topAir): sum local = 3.574824e-07, global = -2.221026e-07, cumulative = 0.0002244136
GAMG:  Solving for p_rgh, Initial residual = 0.003304726, Final residual = 8.552481e-08, No Iterations 13
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
time step continuity errors (topAir): sum local = 2.001775e-10, global = -5.684051e-11, cumulative = 0.0002244136

Solving for solid region heater
DICPCG:  Solving for T, Initial residual = 0.05991691, Final residual = 1.506036e-08, No Iterations 2
DICPCG:  Solving for T, Initial residual = 2.892845e-06, Final residual = 8.470107e-10, No Iterations 1
Min/max T:min(T) [0 0 0 1 0 0 0] 300 max(T) [0 0 0 1 0 0 0] 500

Solving for solid region leftSolid
DICPCG:  Solving for T, Initial residual = 0.9645239, Final residual = 1.318008e-07, No Iterations 2
DICPCG:  Solving for T, Initial residual = 1.649023e-05, Final residual = 5.392089e-09, No Iterations 1
Min/max T:min(T) [0 0 0 1 0 0 0] 300 max(T) [0 0 0 1 0 0 0] 300

Solving for solid region rightSolid
DICPCG:  Solving for T, Initial residual = 0.6954516, Final residual = 1.022314e-07, No Iterations 2
DICPCG:  Solving for T, Initial residual = 1.153665e-05, Final residual = 3.904825e-09, No Iterations 1
Min/max T:min(T) [0 0 0 1 0 0 0] 300 max(T) [0 0 0 1 0 0 0] 300
ExecutionTime = 3.04 s  ClockTime = 3 s


I'm struckling to plot for example Tmax of the heater region.

Any hint is appreciated.

Best Regards,
Toni

unnikrsn September 5, 2012 10:29

Dear Tony.

Did you find an answer. I now at this positions.
I want to plot the temperature in each Region ( solid & Fluid )
But couldnt find a GNUplot code for including the next line..

Solving for solid region led_oben
DICPCG: Solving for T, Initial residual = 1, Final residual = 0.04405201, No Iterations 2
Min/max T:406.8886 580.7125

Solving for solid region led_unten
DICPCG: Solving for T, Initial residual = 1, Final residual = 0.04022057, No Iterations 2
Min/max T:407.0093 580.5514

Solving for solid region kuehlkoerper
DICPCG: Solving for T, Initial residual = 1, Final residual = 0.01958096, No Iterations 2
Min/max T:300 439.3916

Thanks & Regards
Unni

val46 September 6, 2012 02:35

Hi,

it won't work just with gnuplot.
You need an additional script to extract the desired values before running gnuplot.

It should look somehow like this:
Code:

grep 'Solving for T:' log.chtMultiRegionFoam >log_new2
awk '(NR+1)%3==0' log_new2 >log_new3


Best Regards,

Toni

unnikrsn September 7, 2012 02:59

Thanks for the reply.. It was very helpful...

Thanks & Regards
Unni

melabbassi December 12, 2016 07:06

I tried the following simple adaptation to the tutorial and it worked nicely. The key is to use grep twice. First you output the number of lines after the line where the keyword is allocated with grep. Then you apply grep as in the tutorial.

So something like
plot "< cat logfile | grep -A2 specificRegion | grep 'Min/max T:' | cut -d' ' -f1 | tr -d ','" title 'T_specificRegion' with lines,\

where -A2 means that grep outputs 2 lines after the searched text (e.g bottomAir). For three lines, use -A3... etc...

Cheers,
Mohamed


All times are GMT -4. The time now is 00:04.