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

Here is a script for plotting force files in Gnuplot.

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

Like Tree2Likes
  • 2 Post By lordvon

Reply
 
LinkBack Thread Tools Display Modes
Old   May 17, 2012, 02:16
Default Here is a script for plotting force files in Gnuplot.
  #1
Senior Member
 
Robert
Join Date: Sep 2010
Posts: 155
Rep Power: 6
lordvon is on a distinguished road
I did not find a script for plotting the force file outputs (specified in controlDict), so I made one and am sharing it.

It plots whatever forces.dat file is in the same directory as the script. There are some constants and stuff that are my own, and shouldnt be too hard to tweak for your own usage. The 'truncationFactor' cuts off the first (number of lines in forces.dat)/truncationFactor lines in the forces.dat file; this is useful for transient simulations where the first few data points may be unphysically high and mess up the plot scale.

You need to enter in by line what you want to plot in 'forcesProcess' following the command 'plot'. The numbers for each force and moment as variables are just for reference; they are the indexes of each of the force/moment pressure/viscous component as listed in order on each line in the forces.dat file.

Two files, forcesProcess and forcesPlot. Currently forces.dat needs to be in same directory (can easily change to your desired relative directory), and forcesPlot is called from the shell to generate the plot.

forcesPlot:
Code:
#!/bin/bash
truncationFactor=10
name='forces.dat'

y=$(wc $name | cut -d' ' -f3)
start=$[y/truncationFactor]
echo "Lines in force file: $y"
echo "Line to start plot: $start"
sed 's/[()]//g' < $name > processed.dat
sed -i "1,${start}d" processed.dat
gnuplot forcesProcess -
forcesProcess:
Code:
cellDepth=0.00515394
omega=2400*2*pi/60
time=1
xForcePressure=2
xForceViscous=xForcePressure+3
yForcePressure=3
xForceViscous=yForcePressure+3
zForcePressure=4
xForceViscous=zForcePressure+3
xMomentPressure=8
xMomentViscous=xMomentPressure+3
yMomentPressure=9
yMomentViscous=yMomentPressure+3
zMomentPressure=10
zMomentViscous=zMomentPressure+3

plot  "processed.dat" using 1:(($2+$5)/cellDepth) title 'Drag (Newtons)', \
      "processed.dat" using 1:(($3+$6)/cellDepth) title 'Thrust (Newtons)', \
      "processed.dat" using 1:(($10+$13)/cellDepth*omega) title 'Power (Watts)'
SirWombat and GM_XIII like this.
lordvon 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgently Need the code of Lift force and VM force Kai Yan Main CFD Forum 0 July 16, 2008 07:07
plotting force magnitude force CD-adapco 6 July 11, 2008 04:19
DEFINE_CG_MOTION and pressure force Teo Fumagalli FLUENT 0 April 11, 2008 10:25
pressure force and viscous force CFD FLUENT 0 March 7, 2006 02:03
Force monitors Phil FLUENT 1 June 4, 2004 02:21


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