|
[Sponsors] |
[snappyHexMesh] Convert stl files and multi region |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 30, 2014, 14:25 |
Convert stl files and multi region
|
#1 |
New Member
Adrien Brunet
Join Date: May 2014
Posts: 1
Rep Power: 0 |
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 |
|
July 1, 2014, 11:15 |
shm and multiregions
|
#2 |
Member
Join Date: Nov 2011
Location: Berlin
Posts: 31
Rep Power: 14 |
Hi
FYI i started another thread on SHM on multiregion foam. http://www.cfd-online.com/Forums/ope...ns-salome.html Regards dirk |
|
Tags |
convert, python, snappyhexmesh, stl, vtk |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[OpenFOAM] Post Processing Multi Region .OpenFOAM | malix38 | ParaView | 2 | April 1, 2019 21:44 |
Some questions about a multi region case run in parallel | zfaraday | OpenFOAM Running, Solving & CFD | 5 | February 23, 2017 11:25 |
[Other] Material properties in multi region foam and refining mesh for each region | mukut | OpenFOAM Meshing & Mesh Conversion | 2 | October 7, 2013 03:08 |
[snappyHexMesh] Multi Region Meshing | bruce | OpenFOAM Meshing & Mesh Conversion | 12 | July 31, 2013 11:09 |
[snappyHexMesh] Multi region meshing & recovering the original patch names | fluidpath | OpenFOAM Meshing & Mesh Conversion | 4 | May 19, 2013 20:13 |