CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Meshing & Mesh Conversion

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

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

Like Tree1Likes
  • 1 Post By elvis

Reply
 
LinkBack Thread Tools Display Modes
Old   March 22, 2011, 10:42
Default vtk to OpenFoam (or something else that can reach after OpenFoam)
  #1
New Member
 
Join Date: Mar 2011
Posts: 13
Rep Power: 6
cristina87 is on a distinguished road
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
cristina87 is offline   Reply With Quote

Old   March 23, 2011, 03:20
Default
  #2
Senior Member
 
Elvis
Join Date: Mar 2009
Location: Sindelfingen, Germany
Posts: 579
Blog Entries: 5
Rep Power: 13
elvis is on a distinguished road
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 is offline   Reply With Quote

Old   March 23, 2011, 13:35
Default
  #3
Senior Member
 
Elvis
Join Date: Mar 2009
Location: Sindelfingen, Germany
Posts: 579
Blog Entries: 5
Rep Power: 13
elvis is on a distinguished road
#!/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()
mgdenno likes this.
elvis is offline   Reply With Quote

Old   March 23, 2011, 14:04
Default what mesh generator to use for huge .stl file?
  #4
New Member
 
Join Date: Mar 2011
Posts: 13
Rep Power: 6
cristina87 is on a distinguished road
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 is offline   Reply With Quote

Old   March 24, 2011, 09:22
Default parser for vtk file to obtain blockMeshDict or vtkDealuny3D it's enough to obtain mes
  #5
New Member
 
Join Date: Mar 2011
Posts: 13
Rep Power: 6
cristina87 is on a distinguished road
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
cristina87 is offline   Reply With Quote

Old   March 25, 2011, 03:39
Default
  #6
Senior Member
 
Elvis
Join Date: Mar 2009
Location: Sindelfingen, Germany
Posts: 579
Blog Entries: 5
Rep Power: 13
elvis is on a distinguished road
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

terrain import openFoam

elvis

Last edited by elvis; March 25, 2011 at 04:00.
elvis is offline   Reply With Quote

Old   July 26, 2014, 20:43
Default
  #7
Member
 
Kan
Join Date: Feb 2014
Location: Australia
Posts: 48
Rep Power: 3
nwpukaka is on a distinguished road
Quote:
Originally Posted by elvis View Post
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
nwpukaka is offline   Reply With Quote

Old   July 28, 2014, 09:06
Default
  #8
Senior Member
 
Elvis
Join Date: Mar 2009
Location: Sindelfingen, Germany
Posts: 579
Blog Entries: 5
Rep Power: 13
elvis is on a distinguished road
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
elvis 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
vtk mesh or Abaqus mesh to OpenFOAM bigphil Open Source Meshers: Gmsh, Netgen, CGNS, ... 19 August 16, 2011 04:14
Cross-compiling OpenFOAM 1.7.0 on Linux for Windows 32 and 64bits with Mingw-w64 wyldckat OpenFOAM Announcements from Other Sources 3 September 8, 2010 06:25
Modified OpenFOAM Forum Structure and New Mailing-List pete Site News & Announcements 0 June 29, 2009 05:56
64bitrhel5 OF installation instructions mirko OpenFOAM Installation 2 August 12, 2008 18:07
Adventure of fisrst openfoam installation on Ubuntu 710 jussi OpenFOAM Installation 0 April 24, 2008 14:25


All times are GMT -4. The time now is 20:24.