CFD Online Logo CFD Online URL
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

LinkBack Thread Tools Search this Thread Display Modes
Old   May 30, 2014, 13:25
Default Convert stl files and multi region
New Member
Adrien Brunet
Join Date: May 2014
Posts: 1
Rep Power: 0
abrunet is on a distinguished road
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()
write = vtk.vtkSTLWriter()


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

write = vtk.vtkSTLWriter()

write.SetFileName('_binary.stl'.join(path.split('. stl')))

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

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

solid ascii

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.

abrunet is offline   Reply With Quote

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

Regards dirk
dzi is offline   Reply With Quote


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 17:36.