CAD-import mesh warnings

Hi,

I have some trouble to mesh my geometry. It is a ship hull that I’ve made in FreeCAD and then import as .iges in NGSolve. For some settings a mesh is generated but I’m not sure if it is good enough (?) because I get some warnings in the output:


Face 183 / 183 (plane space projection)
Delaunay meshing
start tetmeshing
start tetmeshing
start tetmeshing
start tetmeshing
Success !
Remove Illegal Elements
Delaunay meshing
WARNING: Delaunay, point not in any sphere
WARNING: Delaunay, point not in any sphere
WARNING: Delaunay, point not in any sphere
WARNING: Delaunay, point not in any sphere
WARNING: Delaunay, point not in any sphere
WARNING: Delaunay, point not in any sphere
WARNING: Delaunay, point not in any sphere
start tetmeshing
start tetmeshing
Success !
Remove Illegal Elements
Delaunay meshing
Remove Illegal Elements
Volume Optimization

I tried to import both .step and .brep versions of the CAD-file, but .iges is the only format that I got some mesh with. There are some different options when exporting from FreeCAD and I’m not sure which are best suited for export to NGSolve. Maybe someone here have more experience with this? FreeCAD model is attached.

In another attempt I added a sphere to the geometry, by creating a shape from the cad-import, removing the sphere from this shape and then making a compound of them. I did get a mesh from this in jupyter, but when I used the same settings (… I think) in a .py-script it resulted in an error:

Face 183 / 183 (plane space projection)
Delaunay meshing
double free or corruption (out)
Aborted

Here is the py-code.

from ngsolve import *
import netgen.gui

from ngsolve import ngsglobals
import netgen.occ as occ

ngsglobals.msg_level = 2

file = "simpleHull.iges"
cadImp = occ.OCCGeometry(file)

### Mesh cad-import ###
mesh = Mesh(cadImp.GenerateMesh(maxh=10))#.Curve(3) # assemble geometry and mesh with maximal mesh-size = maxh
Draw(mesh)
input("pause")

### Extract shape from cad-import and move the shape center to origo ###
cadImp_shape = cadImp.shape
bb = cadImp_shape.bounding_box
pmin = bb[0]
pmax = bb[1]
center = occ.Pnt(\
            (pmin.x + pmax.x) / 2, \
            (pmin.y + pmax.y) / 2, \
            (pmin.z + pmax.z) / 2 \
        )
disp = occ.Vec( \
            -center.x, \
            -center.y, \
            -center.z  \
        )
cadImp_shape = cadImp_shape.Move(disp)

### Add a sphere to the geometry ###
x_sp = -50
y_sp = -200
z_sp = 0
sp = occ.Sphere(occ.Pnt(x_sp,y_sp,z_sp), r = 5)   
sp.maxh = 1 
sp.mat("ball")
for face in sp.faces:
    face.col =  (1,0,0) # give sphere red faces
rest = cadImp_shape - sp ### subtract the sphere from cad-import geometry 

### Make compound and mesh ###
geo = occ.Compound([rest, sp])
geo = occ.OCCGeometry(geo)
mesh = Mesh(geo.GenerateMesh(maxh=20))#.Curve(3) # assemble geometry and mesh with maximal mesh-size = maxh
Draw(mesh)
input("pause")

Files are attached. Please comment the warnings in the meshing. I hope someone have some good suggestions on how to import this geometry in a better/correct way.

simpleHull-ngsolve.zip (553.5 KB)