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

How to plot this by gnuplot?

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 3 Post By Ruli
  • 1 Post By Ruli

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 11, 2014, 01:56
Default How to plot this by gnuplot?
  #1
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 838
Rep Power: 17
sharonyue is on a distinguished road
Hi guys,

I got this force.dat by openfoam function. But I dont know know to plot it.
Code:
0.01	((175.11 -29.1481 -7.68548e-16),(2.75129 -0.0949126 -1.23933e-18),(0 0 0)) ((146.469 879.927 -836.51),(0.476936 13.8252 0.612752),(0 0 0))
0.02	((179.722 -75.9252 -3.0539e-16),(2.34419 -0.060192 -1.06484e-18),(0 0 0)) ((381.524 903.101 -931.303),(0.302465 11.7796 0.402727),(0 0 0))
0.03	((203.615 -106.208 -7.78895e-17),(2.10338 -0.0642538 -7.93942e-19),(0 0 0)) ((533.698 1023.17 -1123.37),(0.322875 10.5695 0.378691),(0 0 0))
0.04	((221.76 -131.418 6.27871e-17),(1.94296 -0.0816487 -8.28315e-19),(0 0 0)) ((660.373 1114.34 -1293.77),(0.410285 9.76335 0.453646),(0 0 0))
I want to set the green part in x axis. and the red one in y axis. how can I get it in terminal?

Thanks
sharonyue is offline   Reply With Quote

Old   March 12, 2014, 05:18
Default
  #2
Member
 
Julian Langowski
Join Date: May 2011
Location: Bremen, Germany
Posts: 91
Rep Power: 14
Ruli is on a distinguished road
Dear Dongyue,

try this:

1.) Copy the forces.dat for saftey

Code:
cp postProcessing/forces/0/forces.dat postProcessing/forces/0/forces_plot.dat
2.) Replace "((" with "(( "

Code:
sed -i 's/((/(( /g' postProcessing/forces/0/forces_plot.dat
3.) Plot

Code:
gnuplot
plot    "postProcessing/forces/0/forces_plot.dat" u 1:($3) w l t "x-force" axis x1y2
Should work...

Best regards
Julian
panda, sharonyue and Richal Sun like this.
__________________
πάντα ῥεῖ - Heraclitus
Ruli is offline   Reply With Quote

Old   March 12, 2014, 08:48
Default
  #3
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 838
Rep Power: 17
sharonyue is on a distinguished road
Quote:
Originally Posted by Ruli View Post
Dear Dongyue,

try this:

1.) Copy the forces.dat for saftey

Code:
cp postProcessing/forces/0/forces.dat postProcessing/forces/0/forces_plot.dat
2.) Replace "((" with "(( "

Code:
sed -i 's/((/(( /g' postProcessing/forces/0/forces_plot.dat
3.) Plot

Code:
gnuplot
plot    "postProcessing/forces/0/forces_plot.dat" u 1:($3) w l t "x-force" axis x1y2
Should work...

Best regards
Julian
Awesome! That works, but im a little confused about this :

Code:
plot    "postProcessing/forces/0/forces_plot.dat" u 1:($3) w l t "x-force" axis x1y2
I have tried to change the paramater to another, but failed. So if I wanna the y axis to be the second column. what should I do? Thanks.
sharonyue is offline   Reply With Quote

Old   March 12, 2014, 08:59
Default
  #4
Member
 
Julian Langowski
Join Date: May 2011
Location: Bremen, Germany
Posts: 91
Rep Power: 14
Ruli is on a distinguished road
Code:
plot    "postProcessing/forces/0/forces_plot.dat" u 1:2 w l t "x-force" axis x1y1
The 1 is the first column for x values, the 2 is the second column for y values.
sharonyue likes this.
__________________
πάντα ῥεῖ - Heraclitus
Ruli is offline   Reply With Quote

Old   March 12, 2014, 09:35
Default
  #5
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
Quote:
Originally Posted by Ruli View Post
Dear Dongyue,

try this:

1.) Copy the forces.dat for saftey

Code:
cp postProcessing/forces/0/forces.dat postProcessing/forces/0/forces_plot.dat
2.) Replace "((" with "(( "

Code:
sed -i 's/((/(( /g' postProcessing/forces/0/forces_plot.dat
3.) Plot

Code:
gnuplot
plot    "postProcessing/forces/0/forces_plot.dat" u 1:($3) w l t "x-force" axis x1y2
Should work...

Best regards
Julian
You might want to use "sed -i.bak", which gives you the back-up file right away.

If you want to plot multiple columns, there is no need to retype the filename, i.e.

Code:
plot "filename" using 1:2, "" using 1:5, "" using 1:8
will work for you, probably.
Bernhard is offline   Reply With Quote

Old   March 12, 2014, 09:42
Default
  #6
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 838
Rep Power: 17
sharonyue is on a distinguished road
Code:
plot "w.dat" using 1:3 w l,"" using 1:11 w l, "" using 1:4 w l
Thank you guys! this would be more clear.
sharonyue is offline   Reply With Quote

Old   March 20, 2014, 02:24
Default
  #7
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 838
Rep Power: 17
sharonyue is on a distinguished road
Code:
0.01	((122.847 3.11355 1.99776e-16),(2.35502 0.0580908 -6.78944e-19),(0 0 0)) ((-0.0778387 3.07116 -647.967),(-0.00145227 0.0588756 -3.40765),(0 0 0))
Right now I wanna add 122.847 with 2.35502. How can I get this value in terminal?

Solved:
Code:
awk '{print $2}' forces > t
extract the second column.
sharonyue 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[swak4Foam] Foam warnings - related to swak4Foam Salam-H OpenFOAM Community Contributions 20 August 2, 2015 15:40
to plot Mach contour using GNUPLOT killtimm Main CFD Forum 2 December 28, 2009 11:15
how to plot contour or vector with "GNUPLOT" ztdep Main CFD Forum 2 June 19, 2006 12:26
how to plot isotherms in gnuplot? sivasamy Main CFD Forum 0 December 19, 2005 01:26
To plot a grid using Gnuplot Jim Main CFD Forum 5 September 3, 2004 16:32


All times are GMT -4. The time now is 10:37.