CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Meshing & Mesh Conversion (http://www.cfd-online.com/Forums/openfoam-meshing/)
-   -   vtk to OpenFoam (or something else that can reach after OpenFoam) (http://www.cfd-online.com/Forums/openfoam-meshing/86416-vtk-openfoam-something-else-can-reach-after-openfoam.html)

cristina87 March 22, 2011 10:42

vtk to OpenFoam (or something else that can reach after OpenFoam)
 
Hi,

I have a vtk file - unstructered grid type (with points and cells - I don't no exactly if it is mesh or only geometry and I should to obtain the mesh firstly - I'm beginer). However I want to do a simulation with OpenFoam - but no idea how to change the .vtk file in .OpenFoam file - I tryed many ways, but is to complicated. Last time I tried to obtain .stl from .vtk with vtkSTLWriter and after that I would change .stl in gambit to OpenFoam. But it seems to me that I can't write the unstructured grid to a .stl file (it requires vtkPolyData and I see I can't obtain this - it pass the compilation step but it has problems at running).

If I generate the mesh with blockMesh then I need a blockMeshDict and i don't know how to obtain it from the vtk file...

Cristina

elvis March 23, 2011 03:20

Hi,

i wrote a pythonvtk script to convert unstructuredgrid vtk-files into STL-files.
If you send me your VTK-file in an email elvis-the-pelvis (at) hotmail dot de i will try to convert your vtk-file into an STL-file. I will also post my script here when i come back from work.

From the STL-file you can take several ways to get a mesh for CFD-simulations with Openfoam.
=>SnappyHexMesh (SHM) http://www.openfoam.com/docs/user/sn...#x26-1490005.4
=>Engrid
http://engits.eu/en/documentation
=>discretizer (Discretizer-Setup)
http://www.discretizer.org/node/21 (a screencast)

and lots of other ways (salome , blender, calculix)
there used to be some descriptions on the http://www.openfoamworkshop.org
but the milano workshop`s page is broken!
maybe you look through http://www.tfd.chalmers.se/~hani/kurser/OS_CFD/

elvis March 23, 2011 13:35

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import vtk

reader = vtk.vtkUnstructuredGridReader()
reader.SetFileName("/home/elvis/VTK_unstr.vtk")

filter = vtk.vtkDataSetSurfaceFilter()
filter.SetInput(reader.GetOutput())

clean = vtk.vtkCleanPolyData()
clean.SetInputConnection(filter.GetOutputPort())

triangles = vtk.vtkTriangleFilter()
triangles.SetInputConnection(clean.GetOutputPort() )

write = vtk.vtkSTLWriter()
write.SetInputConnection(triangles.GetOutputPort() )
#write.SetFileTypeToASCII()
write.SetFileTypeToBinary()
write.SetFileName("/home/elvis/STL_bin.stl")
write.Write()

cristina87 March 23, 2011 14:04

what mesh generator to use for huge .stl file?
 
Hi,

Thank you for help. I resolved with vtkGeometryFilter and it's works :P Now I have a .stl file but I don't know how to generate the mesh. I tried with Discretizer but it seems that the file is to large(I have a complex geometry there) and sometimes it blocks - even when it works I didn't find exactly the comand to generate the mesh.

I tried to install Harpoon (I read it is for complex geometries) but I don't find a version for linux x86... It is only for linux 64 bit and for windows (and in windows I don't have installed any solver and I receive an error when I try to open it).

Do you know where can I find harpoon for linux x86 or a solver for it to install on windows? Or what other mesh generator for complex geometry do you know? I tried also with engrid but it's horrible to install it on ubuntu ...

Cristina

cristina87 March 24, 2011 09:22

parser for vtk file to obtain blockMeshDict or vtkDealuny3D it's enough to obtain mes
 
Hi,

It doesn't seem to useful to have the .stl format... To obtain the mesh I still need to construct the blockMeshDict for the blockMesh utility and I really don't know how to do because I have a huge geometry with 4 buildings (and I don't know how to identify exactly the corners and the edges of the buildings only from the vtk file - there is a large list of points). If someone has already write a parser for vtk files(ubstructured grid) in order to obtain the dictionary for block mesh can please give me some clues?

Now I'm trying with Delauny3D algorithm - as I understood it generates somehow a mesh... It's good for my future simulation? (I will aply after that a solver on my mesh)

Cristina

elvis March 25, 2011 03:39

Dear Cristina,
there are some publications and discusions related to terrain meshing

http://hig.diva-portal.org/smash/get...936/FULLTEXT01
=>Modelling of wind flow over complex terrain
using OpenFoam , Xabier Pedruelo Tapia June 2009 Master’s Thesis in Energy Systems
===>Take a look at page 81 to understand what SHM makes for meshing
you have two volumes (Volume Blockmesh=Rectangle) - (Volume STL=Terrain surface)
this is your CFD-simulation-Mesh

http://www.aij.or.jp/jpn/publish/cfdguide/index_e.htm Guidebook for Practical Applications of CFD to Pedestrian Wind Environment around Buildings
http://oshima.eng.niigata-u.ac.jp/Op...ingDivided.pdf

A blockMeshDict for a rectangle (8 points) is not a big challange!

there is even a tutorial with terrain meshing

http://www.cfd-online.com/Forums/ope...-openfoam.html

elvis

nwpukaka July 26, 2014 20:43

Quote:

Originally Posted by elvis (Post 300655)
Hi,

i wrote a pythonvtk script to convert unstructuredgrid vtk-files into STL-files.
If you send me your VTK-file in an email elvis-the-pelvis (at) hotmail dot de i will try to convert your vtk-file into an STL-file. I will also post my script here when i come back from work.

From the STL-file you can take several ways to get a mesh for CFD-simulations with Openfoam.
=>SnappyHexMesh (SHM) http://www.openfoam.com/docs/user/sn...#x26-1490005.4
=>Engrid
http://engits.eu/en/documentation
=>discretizer (Discretizer-Setup)
http://www.discretizer.org/node/21 (a screencast)

and lots of other ways (salome , blender, calculix)
there used to be some descriptions on the http://www.openfoamworkshop.org
but the milano workshop`s page is broken!
maybe you look through http://www.tfd.chalmers.se/~hani/kurser/OS_CFD/

Hi Elvis,

I currently have the same problem with the conversion my vtk mesh to OpenFoam, but my vtk format is xml, does your script accept this kind of format?

Cheers,
Kan

elvis July 28, 2014 09:06

Hi,

if paraview can load/visualize your file, you should be able to write STL-file from Paraview http://www.paraview.org/Wiki/The_ParaView_Tutorial
http://www.paraview.org/Wiki/ParaView

http://www.paraview.org/Wiki/Convert...rom_PLY_to_VTP just a starter

http://www.vtk.org/doc/release/6.0/html/classes.html => http://www.vtk.org/doc/release/6.0/h...ataReader.html or what kind of Data
http://www.vtk.org/doc/release/6.0/h...STLWriter.html


All times are GMT -4. The time now is 09:25.