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

How to visualize polyhedron mesh in paraview

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

Reply
 
LinkBack Thread Tools Display Modes
Old   March 5, 2014, 08:21
Smile How to visualize polyhedron mesh in paraview
  #1
New Member
 
Jinbin Ge
Join Date: Mar 2013
Posts: 6
Rep Power: 4
gejiabin is on a distinguished road
Recently,I use the "polyDualMesh" to produce polyhedron mesh,then I visualize it in paraview by "foamToVTK".But the "foamToVTK" decomposes the
Polyhedra into pramid type.paraFoam is not work on my computer and I have to use foamToVTK for post-processing
gejiabin is offline   Reply With Quote

Old   March 7, 2014, 04:59
Default python solution
  #2
New Member
 
Jinbin Ge
Join Date: Mar 2013
Posts: 6
Rep Power: 4
gejiabin is on a distinguished road
I have one solution.Since I need only to observe polymesh,I convert the openfoam mesh format to paraview unstructed grid format .vtk using python.
It is tedious,is there any more simple way?

#!/usr/bin/vtkpython
datapath_read_points="constant/polyMesh/points"
datapath_read_faces="constant/polyMesh/faces"
datapath_write="VTK/1.vtk"

file_read_points=open(datapath_read_points,'r')
file_read_faces=open(datapath_read_faces,'r')
file_write=open(datapath_write,'w')
#----------------------------------------------------
#Header
file_write.write("# vtk DataFile Version 3.1\n" )
file_write.write("Visualization for polyMesh\n" )
file_write.write("ASCII\n" )
file_write.write("DATASET UNSTRUCTURED_GRID\n" )

#----------------------------------------------------

l_points=file_read_points.readlines()
numPoints=l_points[18]
numPoints=numPoints.replace("\n"," ")
file_write.write("POINTS " + numPoints + "float\n" )
for line in l_points[20:20+int(numPoints)]:
line=line.replace("(","")
line=line.replace(")","")
file_write.write(line)

#----------------------------------------------------
l_cells_=file_read_faces.readlines()
numCells=l_cells_[18]
numCells=numCells.replace("\n"," ")
#------------------------------------------
l_cells_=l_cells_[20:]

while l_cells_[-1]!=')\n':
l_cells_.pop()

l_cells=[]
for line in l_cells_:

if line=="(\n":
l_cells[-1]+="("
continue

if line==")\n":
l_cells[-1]+=")\n"
continue

if line=="\n":
l_cells.append("")
continue

if len( line.split('(') )>1:
l_cells.append(line)
continue

if len(l_cells)==0:
l_cells.append(line.replace("\n"," "))
continue

l_cells[-1]+=line.replace("\n"," ")

#------------------------------------------
numSize=0;
for line in l_cells:
if line=="":
continue
line=line.split('(');
numSize+=int(line[0])+1;

file_write.write("CELLS " + numCells + str(numSize) +"\n")
for line in l_cells:
if line=="":
continue
line=line.replace("("," ")
line=line.replace(")","")
file_write.write(line)

#----------------------------------------------------
file_write.write("CELL_TYPES "+numCells + "\n" )
file_write.write("7 "*int(numCells))

file_read_points.close()
file_read_faces.close()
file_write.close()
#----------------------------------------------------
gejiabin is offline   Reply With Quote

Old   March 7, 2014, 09:09
Default
  #3
New Member
 
akrasemann
Join Date: Dec 2013
Posts: 17
Rep Power: 3
akrasemann is on a distinguished road
I'm not sure weather this helps, but I had difficulties displaying a polyhedral mesh created by enGrid. If your problem is displaying, the following might help:

wyldckat pointed out to me in this post Exporting mesh for an OpenFOAM chtMultiRegion casethat one has to tick the check box "Use VTKPolyhedron" to display the mesh properly.
akrasemann is offline   Reply With Quote

Reply

Tags
foamtovtk, paraview, polydualmesh, polyhedron

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
[ICEM] surface mesh merging problem everest ANSYS Meshing & Geometry 39 June 5, 2013 19:02
Paraview 3.98.0 does not update list of mesh regions letzel OpenFOAM Paraview & paraFoam 4 January 31, 2013 06:32
ParaView: Number of cells/points in mesh and field don't match Jaggy_Snake OpenFOAM Bugs 1 December 9, 2012 10:01
[ICEM] Problem making structured mesh on a surface froztbear ANSYS Meshing & Geometry 4 November 10, 2011 09:52
gmshToFoam problem: not the same mesh in Gmsh vs. paraview zhernadi Open Source Meshers: Gmsh, Netgen, CGNS, ... 8 July 7, 2011 02:28


All times are GMT -4. The time now is 14:01.