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

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

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread 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: 13
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, 03:54
Default Python script for forceCoeffs_bins.dat to .csv conversion
  #2
Member
 
Petr Furmanek
Join Date: Jan 2012
Location: Faenza, Italy
Posts: 66
Rep Power: 14
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 11:07.
petr.f. 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 16:21.