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

extraxt T_min out of log.sim

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   January 6, 2012, 02:53
Question extraxt T_min out of log.sim
  #1
Member
 
Stefan
Join Date: Jun 2009
Posts: 67
Rep Power: 8
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, 18:24
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
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, 06:23
Default
  #3
Member
 
Stefan
Join Date: Jun 2009
Posts: 67
Rep Power: 8
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, 06:56
Default
  #4
Senior Member
 
Aurelien Thinat
Join Date: Jul 2010
Posts: 154
Rep Power: 7
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, 07:22
Lightbulb
  #5
Member
 
Stefan
Join Date: Jun 2009
Posts: 67
Rep Power: 8
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++
}
preibie is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 07:36.