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,
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)
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.
checkout this forum thread about exporting the mesh to other file formats. Essentially you need to do
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.
to load the Netgen mesh from python, you have to do the following
from netgen import meshing
m = meshing.Mesh(3) # create a 3-dimensional mesh
To export the mesh, use the function suggested by Henry.
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?
I am not sure if BREP is supported. If you go to File → Export Filetype, you can see the list of supported filetypes.