CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

extraxt T_min out of log.sim

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By preibie

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 6, 2012, 01:53
Question extraxt T_min out of log.sim
  #1
Member
 
Stefan
Join Date: Jun 2009
Posts: 67
Rep Power: 16
preibie is on a distinguished road
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
preibie is offline   Reply With Quote

Old   January 7, 2012, 17:24
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by preibie View Post
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
gschaider is offline   Reply With Quote

Old   January 11, 2012, 05:23
Default
  #3
Member
 
Stefan
Join Date: Jun 2009
Posts: 67
Rep Power: 16
preibie is on a distinguished road
Thanks for your help, but it do not work.
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??
preibie is offline   Reply With Quote

Old   January 11, 2012, 05:56
Default
  #4
Senior Member
 
Aurelien Thinat
Join Date: Jul 2010
Posts: 165
Rep Power: 15
Aurelien Thinat is on a distinguished road
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"
Aurelien Thinat is offline   Reply With Quote

Old   January 11, 2012, 06:22
Lightbulb
  #5
Member
 
Stefan
Join Date: Jun 2009
Posts: 67
Rep Power: 16
preibie is on a distinguished road
Thanks for your idea! it runs with this :

Code:
/Min.max.T:/ {
    file="./logs/T_max_" T_maxCnt
    print Time "    " $3 > file
    T_maxCnt++
}
student666 likes this.
preibie is offline   Reply With Quote

Old   May 17, 2017, 01:33
Default
  #6
Senior Member
 
M. C.
Join Date: May 2013
Location: Italy
Posts: 286
Blog Entries: 6
Rep Power: 16
student666 is on a distinguished road
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"
student666 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



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