Hey Joachim,
thanks for the quick reply.
Naturally, I suppose one wants to consider (orientation of) normal vectors with respect to the meshed domain. Of course, there opinions might differ, BUT:
Normal vectors not pointing outwards everywhere, (I suppose) is a consequence of boundary faces not being oriented consistently. And therefore, this simple example of big_brick minus small_brick above, breaks your tutorial on
Working with meshes
:
Since boundary faces are not oriented consistently, creating a volume mesh from the boundary mesh fails with the correct error message
Code:
ERROR: Edge 307 - 308 multiple times in surface mesh
... same error for some other edges ...
netgen.libngpy._meshing.NgException: Stop meshing since surface mesh not consistent
Since boundary face orientation is incosistent, alle edges belonging to the boundary of the top face of the small brick appear twice in the mesh -- instead of once, plus once in reverse direction!
Using the mesh above, and a snippet from the tutorial, reproduce error via:
Code:
from ngsolve import Mesh as ngsMesh
from netgen.csg import OrthoBrick, Pnt, CSGeometry
big = OrthoBrick(Pnt(0,0,0), Pnt(4,4,4))
small = OrthoBrick(Pnt(1, 1, 2), Pnt(3, 3, 4))
geo = CSGeometry()
geo.Add(big-small)
ngmesh = geo.GenerateMesh(maxh=0.5)
mesh = ngsMesh(ngmesh)
### new from here ###
from netgen.meshing import FaceDescriptor, Element2D, Mesh
new_ngmesh = Mesh()
fd_outside = new_ngmesh.Add(FaceDescriptor(bc=1,domin=1,surfnr=1))
pmap = {}
for e in mesh.ngmesh.Elements2D():
for v in e.vertices:
if (v not in pmap):
pmap[v] = new_ngmesh.Add(mesh.ngmesh[v])
for e in mesh.ngmesh.Elements2D():
new_ngmesh.Add(Element2D(fd_outside, [pmap[v] for v in e.vertices]))
new_ngmesh.GenerateVolumeMesh()
If it's not a bug, there's definitely an inconsistency.
(Nothing I couldn't work around with the badhack of changing the list-order of
Code:
[pmap[v] for v in e.vertices]
for some boundary faces. Anyhow, I still wanted to report this, since I could imagine other problems implied by the incosistent orientation.)
Best, Carl