CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (https://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   How to visualize polyhedron mesh in paraview (https://www.cfd-online.com/Forums/openfoam-pre-processing/130861-how-visualize-polyhedron-mesh-paraview.html)

gejiabin March 5, 2014 07:21

How to visualize polyhedron mesh in paraview
 
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 March 7, 2014 03:59

python solution
 
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()
#----------------------------------------------------

akrasemann March 7, 2014 08:09

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 http://www.cfd-online.com/Forums/engrid/128987-exporting-mesh-openfoam-chtmultiregion-case.html#post471822 that one has to tick the check box "Use VTKPolyhedron" to display the mesh properly.

Ship Designer August 8, 2020 21:09

5 Attachment(s)
Where can I find the "Use VTKPolyhedron" button in ParaView? I'm using ParaView for Mac 5.7.0 and I can't find any reference in the ParaView user guide.

I'm investigating with a very simple example how OpenFOAM makes transitions between refinement levels in hexahedral meshes. I made a mesh of 2 cells and then refined one of them. After refinement, checkMesh reports 9 cells as expected, of which 8 are hexahedrons and 1 is a 9-faced polyhedron. When I open the mesh in ParaView however, the polyhedron gets subdivided in 13 bodies, of which 6 are tetrahedrons and 7 pyramids, see attached picture. I would like to see what difference it makes with the VTKPolyhedron option switched on, because I think that this decompositions of polyhedrons create disturbances in the wave patterns of ship resistance calculations, see attached picture of wave pattern. It is essential that I know whether this is a mesh quality issue or just ParaView visualizing it wrong.

Thanks!

Ship Designer August 11, 2020 22:33

2 Attachment(s)
I accidentally found what I was looking for… The checkbox has changed label from "Use VTKPolyhedron" to "Decompose polyhedra". It is only visible after clicking the gear on the top right which displays more controls in the properties panel. After months of using ParaView I somehow never noticed that gear over there… I don't know but I think that there ought to be User Interface Guidelines for Linux applications too… Terrible GUIs at times.


All times are GMT -4. The time now is 07:51.