CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   extraxt T_min out of log.sim (https://www.cfd-online.com/Forums/openfoam-post-processing/95881-extraxt-t_min-out-log-sim.html)

preibie January 6, 2012 01:53

extraxt T_min out of log.sim
 
Hallo,

I pipe the openFoam output from the shell in a file called log.sim. To plot some date I use awk like:
Code:

awk -f logs/foamLog.awk log.sim
In foamLog.awk are extractions like
Code:

# Extraction of T_min fluid or solid
/Min.max.T:/ {
    extract($0, "Min/max T:", val)
    file="./logs/T_min_" T_minCnt
    print Time "    " val[1] > file
    T_minCnt++
}

My problem now is that I want also extract the second variable after T_min. This tow variables are standing in a line like this:
Min/max T:283.05995 283.15

gschaider January 7, 2012 17:24

Quote:

Originally Posted by preibie (Post 338082)
Hallo,

I pipe the openFoam output from the shell in a file called log.sim. To plot some date I use awk like:
Code:

awk -f logs/foamLog.awk log.sim
In foamLog.awk are extractions like
Code:

# Extraction of T_min fluid or solid
/Min.max.T:/ {
    extract($0, "Min/max T:", val)
    file="./logs/T_min_" T_minCnt
    print Time "    " val[1] > file
    T_minCnt++
}

My problem now is that I want also extract the second variable after T_min. This tow variables are standing in a line like this:
Min/max T:283.05995 283.15

Wouldn't the second value be available as $2 or so? But surly you know more about awk than I do (my last experiences are year ago), I'm more a Python-person

preibie January 11, 2012 05:23

Thanks for your help, but it do not work. :confused:
A possibitity is to read bouth variables and use only the second. Another is to read the last Variable in the line.

Has anybody an Idea??

Aurelien Thinat January 11, 2012 05:56

Hi,

To extract values from output, with awk I use something like :

"cat log.out |grep 'Tmin/max ='|awk '{print $i}' > Tmin.dat"

replacing i by the number I want. In your case it should be something like 3 for Tmin and 4 for Tmax

In another case, for extracting density rho max/min : 2.14 3.16 I used :

"cat log.out |grep 'rho max/min' | cut -d' ' -f5|tr -d ',' > rhomin.dat"

preibie January 11, 2012 06:22

Thanks for your idea! it runs with this :D:

Code:

/Min.max.T:/ {
    file="./logs/T_max_" T_maxCnt
    print Time "    " $3 > file
    T_maxCnt++
}


student666 May 17, 2017 01:33

Just for the records. I have been able to plot using bash scripting only, as I don't know awk...

Code:

cp -f postProcessing/domain2/minMax/0/field* minMax.dat
sed -i -e '/p/d' minMax.dat
sed -i -e '/U/d' minMax.dat
gnuplot.exe  //.exe --> I'm running openfoam with MySYS2 on windows
set title "Max Temperatures"
set autoscale xy
set grid
set ylabel "T [K]"
set xlabel "Iterations"
plot ' path to the file minMax.dat' using 1:8 w l title "T max"



All times are GMT -4. The time now is 23:05.