Writing the meshes as BREP file or MSH file using python api

More
4 years 2 weeks ago #3307 by renard
Hi,
I'm trying to create a simple geometry of a fusion of two spheres using the python api of netgen.
Going through the tutorials I have written the following code,


Code:
from netgen.csg import * sphere1 = Sphere( Pnt(0,0,0), 12.0 ) sphere2 = Sphere( Pnt(20,0,0), 12.0 ) geo = CSGeometry() geo.Add( sphere1 + sphere2 ) mesh = geo.GenerateMesh(maxh = 1.0) mesh.Save("twospheres.vol")

This code is working, however I would like to save this in a 'brep' file or 'msh3' file ( gmsh file format).

Is there any way to do this ?

also, this "vol" file format can not be opened by Netgen. Is there any way to open and visualize the saved 'vol' file later ?


Thanks for your help.
More
4 years 1 week ago #3308 by hvwahl
Hello renard,

checkout this forum thread about exporting the mesh to other file formats. Essentially you need to do
Code:
mesh.Export(filename, format)

I had no issue opening the mesh in the netgen gui via File > Load Mesh. One alternative to visualise the mesh via ngsolve would be to export a vtk with the constant 1 as the CoefficientFunction and then to visualise this in Paraview.

Best wishes
Henry
The following user(s) said Thank You: renard
More
4 years 1 week ago #3309 by cwinters
Hi renard,

to load the Netgen mesh from python, you have to do the following
Code:
from netgen import meshing m = meshing.Mesh(3) # create a 3-dimensional mesh m.Load("twospheres.vol")

To export the mesh, use the function suggested by Henry.

Best,
Christoph
More
4 years 1 week ago #3311 by renard
Hi, Thank you. I could export the mesh in Gmsh2 file format. However, I could not find the option to save the geometry as a boundary-representation (brep) file. Can you help me with that too?
More
4 years 1 week ago #3312 by rgs
I am not sure if BREP is supported. If you go to File -> Export Filetype, you can see the list of supported filetypes.
Time to create page: 0.103 seconds