[Gmsh] Write individual physical surfaces, preferably from Python API

Christophe Geuzaine cgeuzaine at uliege.be
Thu Oct 11 13:53:10 CEST 2018



> On 10 Oct 2018, at 19:09, Herzig Ivo (herziivo) <herziivo at students.zhaw.ch> wrote:
> 
> Hello,
> 
> Is there an option to write physical surfaces to individual files (preferably STL)? e.g. if I have physical surfaces "inlet" and "outlet" and I want to write them to "inlet.stl" and "outlet.stl" files.

As guillaume said, when physical groups are defined, by default Gmsh only saves those mesh elements that belong to physical groups. You can thus indeed use this feature to selectively save what you need.

I have added a "removePhysicalGroups" function in the api to make this easy: you can now do: 

model.mesh.generate(2)

model.addPhysicalGroup(2, [37], 100)  # inlet
gmsh.write("inlet.stl")

model.removePhysicalGroups()
model.addPhysicalGroup(2, [42], 200)  # inlet
gmsh.write("outlet.stl")


> 
> Another option would be to write them to a single STL file but in separate solids named after the Physical surfaces, but I don't think gmsh can do that either?
> 

Is this supported by the STL format? If it is, we could indeed modify our STL writer to create multiple "solids" (that's easy to code - see Geo/GModelIO_STL.cpp : don't hesitate to submit merge request in our gitlab with an implementation).

Note that since you are using the API, you could also simply iterate on the surfaces you are interested in, and just write the STL yourself for each part.

Christophe

> Is there an Option I missed that does this? Or a command line switch?​
> 
> Thanks for your help!
> Ivo
> _______________________________________________
> gmsh mailing list
> gmsh at onelab.info
> http://onelab.info/mailman/listinfo/gmsh

— 
Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science 
http://www.montefiore.ulg.ac.be/~geuzaine

Free software: http://gmsh.info | http://getdp.info | http://onelab.info




More information about the gmsh mailing list