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

Which program do you use to plot CD and CL from the forceCoeffs_bins file?

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

Reply
 
LinkBack Thread Tools Display Modes
Old   June 18, 2013, 03:35
Default Which program do you use to plot CD and CL from the forceCoeffs_bins file?
  #1
New Member
 
woodwick's Avatar
 
Alessandro
Join Date: Feb 2013
Location: Italia
Posts: 15
Rep Power: 4
woodwick is on a distinguished road
Once you have the forceCoeffs_bins given as output from the OpenFOAM2.2 motorBike simulation, how do you create the following picture?
Can you create the colored bars directly in Paraview? Do you have a quick creation procedure that does not require to open the forceCoeffs_bins, copy-paste its data, create the bars in LibreOffice, superpose the motorbike.png taken from paraview and scale it to the width of the bars...

(picture taken from http://www.openfoam.org/version2.2.0...processing.php)
woodwick is offline   Reply With Quote

Old   November 19, 2014, 04:54
Default Python script for forceCoeffs_bins.dat to .csv conversion
  #2
Member
 
Petr Furmanek
Join Date: Jan 2012
Location: Prague, Czech Republic
Posts: 60
Rep Power: 5
petr.f. is on a distinguished road
You can use this python script. Save it as e.g. dat2csv.py and chmod to executable. It converts the forceCoeffs_bins.dat into a plain csv format. Then use Excel, Spreadsheet, whatever

PHP Code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import ossys

axis
='x'
header=[]

filename='forceCoeffs_bins.dat'
file_list=open(filename,'r').readlines()

for 
file_line in file_list:
  if 
'# bins       :' in file_line:
    
header.append('nBins'+','file_line.split(':')[-1].strip())
  if 
axis+' co-ords' in file_line:
    
coords_list=file_line.split(':')[-1].split()
  if 
'# delta      :' in file_line:
    
header.append('delta '+axis+','file_line.split(':')[-1].strip())
header.append('Time'+','+file_list[-1].split()[0])
header.append(axis+','+'Cm'+','+'Cd'+','+'Cl')

out_list=[]
out_list.extend(header)
for 
item in range(len(coords_list)):
  
out_list.append(coords_list[item]+','+file_list[-1].split()[1::3][item]+','+file_list[-1].split()[2::3][item]+','+file_list[-1].split()[3::3][item])
#print out_list
print>>open(filename.replace('.dat','.csv'),'w'),'\n'.join(out_list

Last edited by petr.f.; December 12, 2014 at 12:07.
petr.f. 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 20:43.