Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

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

More
3 years 5 months 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
3 years 5 months 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
3 years 5 months 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
3 years 5 months 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
3 years 5 months 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.177 seconds