saving the mesh in .vol format

More
6 years 9 months ago - 6 years 9 months ago #325 by ankit101
i am using the following script for converting the mesh from gmesh to netgen .vol but I would like to save the mesh also through my script.

from netgen.read_gmsh import ReadGmsh
from netgen.meshing import *
# import the Gmsh file to a Netgen mesh object
mesh = ReadGmsh("coarse_test")
# wrap it into an NGSolve mesh
from ngsolve import *
mesh = Mesh(mesh)
Draw(mesh)
print ("num vol elements:", mesh.GetNE(VOL))
print ("num bnd elements:", mesh.GetNE(BND)).


When I am using mesh.Save ("newmesh.vol"), its throwing back the following error:
Traceback (most recent call last):
File "testgmsh.py", line 18, in <module>
mesh.Save ("newmesh.vol")
AttributeError: 'ngsolve.comp.Mesh' object has no attribute 'Save'.

So could someone help me with saving the mesh after its converted using the script
Last edit: 6 years 9 months ago by ankit101.
More
6 years 9 months ago #326 by christopher
There is a difference between the NGSolve mesh (used for FE computations) and the Netgen mesh (from the mesher). When you do
Code:
mesh = Mesh(mesh)
you convert the mesh to a NGSolve mesh, but only the Netgen mesh has the Save function. You can either call Save before this conversion or you can get the Netgen mesh from the NGSolve one by calling
Code:
mesh.ngmesh.Save("newmesh.vol")
Time to create page: 0.090 seconds