CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   How to plot a value kurve of a Variable during a calculation (https://www.cfd-online.com/Forums/openfoam-solving/173118-how-plot-value-kurve-variable-during-calculation.html)

peterhess June 13, 2016 17:43

How to plot a value kurve of a Variable during a calculation
 
Hello everybody,

I am trying to plot the value of the maximum (or avarage) temperature in a region during the calculation, as indecator of convergence...

In this link is clearly cemonstrated how to plot the residuals:

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

But not the value of a varable...

I tried to find in forum an answer without success...

Regards

Peter

t.oliveira June 13, 2016 18:19

That tutorial is based on the processing of the file 'log'. Building upon that solution, you can print the desired temperature to the output, which will sent to 'log' and processed by grep.
To print the temperature to the output, you can include a line like
Info << variable_name << endl;
in the application code and recompile it.
Replace variable_name by the relevant variable and max() operation. I guess it will look like max(T.internalField()) but I haven't tested.
Remember that T is most probably a volScalarField, and you can look for the methods available for this type of object.

peterhess June 13, 2016 18:36

Thanks a lot, I will try it and send a feedback

peterhess June 13, 2016 20:22

hello Thomas,

It seems we talk here about diffenert things.

It is my mistake not giving sufficient information.

I use chtMultiRegionFoam in parallel using:

mpirun np -14 chtMultiRegionFoam -parallel > log

The Results will be worte like that to the log file.

gnuplot in the above given code is then (as you know) getting the needed informations included in log and plot them on a grafical...

The Tmax I am talking about is allready included in the log file because chtMultiRegionFoam give it automaticlly as an output to terminal or log file as in our case...


It looks like this (one complate iteration is shown here):



Solving for fluid region bauteil_3-um_1
diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCG: Solving for Ux, Initial residual = 0.079954561, Final residual = 3.5802619e-08, No Iterations 6
DILUPBiCG: Solving for Uy, Initial residual = 0.020681034, Final residual = 9.5775808e-09, No Iterations 6
DILUPBiCG: Solving for Uz, Initial residual = 0.18888757, Final residual = 1.1096136e-08, No Iterations 6
DILUPBiCG: Solving for h, Initial residual = 3.8215072e-05, Final residual = 4.8838867e-08, No Iterations 3
Min/max T:300 554.28437
GAMG: Solving for p_rgh, Initial residual = 0.22631753, Final residual = 0.0012730539, No Iterations 3
GAMG: Solving for p_rgh, Initial residual = 0.0029054573, Final residual = 1.7563679e-05, No Iterations 7
GAMG: Solving for p_rgh, Initial residual = 0.0006402583, Final residual = 3.3393418e-06, No Iterations 4
diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
time step continuity errors (bauteil_3-um_1): sum local = 6.1733796e-07, global = -1.8383875e-09, cumulative = -2.3500638e-07
GAMG: Solving for p_rgh, Initial residual = 0.22639056, Final residual = 0.0012736502, No Iterations 3
GAMG: Solving for p_rgh, Initial residual = 0.004369804, Final residual = 2.6429418e-05, No Iterations 7
GAMG: Solving for p_rgh, Initial residual = 0.0009625297, Final residual = 9.32754e-08, No Iterations 20
diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
time step continuity errors (bauteil_3-um_1): sum local = 1.1455491e-08, global = 3.8230634e-11, cumulative = -2.3496815e-07

Solving for solid region bauteil_3-quelle_1
DICPCG: Solving for h, Initial residual = 0.00014244993, Final residual = 9.0399703e-07, No Iterations 4
Min/max T:554.20161 554.30021
ExecutionTime = 63.23 s ClockTime = 64 s

Region: bauteil_3-um_1 Courant Number mean: 0.32417571 max: 7.1889456
Region: bauteil_3-quelle_1 Diffusion Number mean: 0.001547934 max: 0.0052691487
Time = 8005.65


My problem here is to finde a "code" that take out the value marked with red above and plot it in for every iteration as a curve on the monitor...

This code ploting as example Ux residuals:

set logscale y
set title "Residuals"
set ylabel 'Residual'
set xlabel 'Iteration'
plot "< cat log | grep 'Solving for Ux' | cut -d' ' -f9 | tr -d ','" title 'Ux' with lines
pause 1
reread

How should I change this code to plot the value marked in red above?

Regards

Peter

t.oliveira June 13, 2016 21:14

I'm sorry, I didn't know that this information was already available at the log file.

Replace
cat log | grep 'Solving for Ux' | cut -d' ' -f9 | tr -d ','
by
cat log | grep 'Min/max T' | cut -d' ' -f3

For further explanation, look for the Linux commands grep, cut and tr.

peterhess June 13, 2016 21:27

Hello Thomas,

Works :)

Thanks a lot

yes you are right, I need to have a deeper look to those commands

Regards

Peter


All times are GMT -4. The time now is 12:46.