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

[snappyHexMesh] Convert stl files and multi region

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 30, 2014, 13:25
Default Convert stl files and multi region
  #1
New Member
 
Adrien Brunet
Join Date: May 2014
Posts: 1
Rep Power: 0
abrunet is on a distinguished road
Hi,
I'm new to openfoam and python-vtk, so I'm not even sure I'm asking this at the right place..

I found the folllowing code to convert stl binary files to ascii files and the opposite. (I'm a noob with python-vtk)

#!/usr/bin/env python


import vtk


def convert_stl2ascii(path):
reader = vtk.vtkSTLReader()
reader.SetFileName(path)
reader.Update()
write = vtk.vtkSTLWriter()
write.SetFileTypeToASCII()

write.SetInput(reader.GetOutput())
write.SetFileName(path)
write.Write()


def convert_stl2binary(path):
reader = vtk.vtkSTLReader()

reader.SetFileName(path)
reader.Update()
write = vtk.vtkSTLWriter()
write.SetFileTypeToBinary()

write.SetFileName('_binary.stl'.join(path.split('. stl')))
write.SetInput(reader.GetOutput())
write.Write()

Let's say I have a ascii stl file like this:

solid first_name
[...]
endsolid
solid second_name
[...]
endsolid
I can convert it to binary but when I try to convert it back to ascii, I get something like:

solid ascii
[...]
endsolid

What should I do to keep the Region name information and to avoid that several different region to be merged in only one region?

My aim is then to use openfoam and snappyhexmesh with that file (either the binary or ascii one). I need to convert the files because I start with a stl file uploaded by a user on a website, and I don't know what kind of stl file he will use. The easy way I found is to convert the file to binary and ascii regardless of its orignal type.

Hope my problem is clear and that you can help me.

Cheers
abrunet is offline   Reply With Quote

Old   July 1, 2014, 10:15
Default shm and multiregions
  #2
dzi
Member
 
Join Date: Nov 2011
Location: Berlin
Posts: 31
Rep Power: 10
dzi is on a distinguished road
Hi
FYI i started another thread on SHM on multiregion foam.

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

Regards dirk
dzi is offline   Reply With Quote

Reply

Tags
convert, python, snappyhexmesh, stl, vtk

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[OpenFOAM] Post Processing Multi Region .OpenFOAM malix38 ParaView 2 April 1, 2019 20:44
Some questions about a multi region case run in parallel zfaraday OpenFOAM Running, Solving & CFD 5 February 23, 2017 10:25
[Other] Material properties in multi region foam and refining mesh for each region mukut OpenFOAM Meshing & Mesh Conversion 2 October 7, 2013 02:08
[snappyHexMesh] Multi Region Meshing bruce OpenFOAM Meshing & Mesh Conversion 12 July 31, 2013 10:09
[snappyHexMesh] Multi region meshing & recovering the original patch names fluidpath OpenFOAM Meshing & Mesh Conversion 4 May 19, 2013 19:13


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