- Thank you received: 0
Writing the meshes as BREP file or MSH file using python api
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,
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.
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.
4 years 1 week ago #3308
by hvwahl
Replied by hvwahl on topic Writing the meshes as BREP file or MSH file using python api
Hello renard,
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.
Best wishes
Henry
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
4 years 1 week ago #3309
by cwinters
Replied by cwinters on topic Writing the meshes as BREP file or MSH file using python api
Hi renard,
to load the Netgen mesh from python, you have to do the following
To export the mesh, use the function suggested by Henry.
Best,
Christoph
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
4 years 1 week ago #3311
by renard
Replied by renard on topic Writing the meshes as BREP file or MSH file using python api
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?
Time to create page: 0.103 seconds