Hello everyone,
I am converting meshes generated in
Coreform Cubit to GMSH format and then importing the Gmsh meshes into Netgen for FEM analysis.
When executing the script below,
from netgen.occ import *
from numpy import *
from ngsolve import *
from ngsolve.webgui import Draw
from netgen.read_gmsh import ReadGmsh
mesh = ReadGmsh(r'input.msh')
mesh = Mesh(mesh)
print(f'{len(mesh.GetMaterials())} Materials {mesh.GetMaterials()}')
print(f'{len(mesh.GetBoundaries())} Boundaries {mesh.GetBoundaries()}')
print(f'{len(mesh.GetBBoundaries())} BBoundaries {mesh.GetBBoundaries()}')
print(f'{len(mesh.GetBBBoundaries())} BBBoundaries {mesh.GetBBBoundaries()}')
fes = H1(mesh, order=2, dirichlet="left", dirichlet_bbnd="edge", dirichlet_bbbnd="gnd")
u, v = fes.TnT()
a = BilinearForm(grad(u) * grad(v) * dx).Assemble()
c = Preconditioner(a, type="local")
f = LinearForm(z * v * dx).Assemble()
gfu = GridFunction(fes)
from ngsolve import solvers
solvers.CG(sol=gfu.vec, rhs=f.vec, mat=a.mat, pre=c.mat, printrates=False, tol=1e-10, maxsteps=1000)
Draw(gfu, mesh, "solution", settings={"Colormap":{"autoscale":False, "min":0, "max":0.0003, "ncolors":32}, "camera": {"transformations": [{"type": "rotateY", "angle": 20}, {"type": "rotateX", "angle": 20}]}})
input.msh (4.9 KB)
the expected result should be:
1 Materials (‘air’,)
2 Boundaries (‘left’, ‘default’)
1 BBoundaries (‘edge’,)
1 BBBoundaries (‘gnd’,)
However, in the current Netgen, BBBoundaries are not loaded. Therefore, I have extended read_gmsh.py. If you find it suitable, would you consider adopting this version? I have also attached an example showing how this change affects the results when analyzing the Poisson equation.
read_gmsh_with_0d_import.py (10.5 KB)

