Working with external (step) meshes

Dear NGSolve developers,

I am interested in knowing if it’s possible to perform boolean operations on external meshes in step formats. I have a solid geometry (say volume1 and given in a step file) which needs to be embedded inside another volume, ideally a sphere (say volume2 and created with CSGeometry() ) and i then need to mesh the region (volume2 - volume1) and define dirichlet boundary conditions on the surface of volume1. I tried performing the boolean operation in gmsh but as i understand from mailing list there, a boolean between step and geometric entities in gmsh is not possible (also i get incorrect results so not sure if the boolean operation is being performed correctly).

I started looking at the given here and this actually merges my step file with a sphere without trouble (attached the adapted script). However it’s not clear to me how to obtain the volume mesh for the region in between and define a boundary condition on interior surface. The line mesh.GenerateVolumeMesh() in the ends up in error in my case, i receive an error: Stop meshing since too many attempts. I am not sure why this happens as i could get a volume mesh with gmsh and i also added a line geo1.Heal() that fixes the errors in my step file if any.

Provided i am able to generate a volume mesh, would the following syntax make sense in order to apply the dirichlet condition on the surface of volume1:

mesh.SetMaterial(1,'inner') # set the volume1 material as inner uVal = x+2.0 mesh.SetMaterial(2,'outer') # set the volume2 material as outer and then fes = H1(mesh, order=2, dirichlet="inner") ubar = GridFunction (fes) ubar.Set (uVal, definedon=mesh.Boundaries("inner"))

Thanks in advance for your help!




I could get the boolean operation working with the given in my message above. I am now trying to get this code working on the hpc cluster. We have a mpi build for ngsolve on the cluster and the python version 3.8. While the script above works on my desktop with python version 3.6, ngsolve complains for the line below when tried on the hpc cluster:

from netgen.NgOCC import *

and produces following error:

This module is deprecated and just a wrapper for netgen.occ, import netgen.occ instead
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-a49208ac6baf> in <module>
----> 1 from netgen.NgOCC import *

/opt/apps/alces/ngsolve_mpi/lib/python3.8/site-packages/netgen/ in <module>
      5 logger.warning("This module is deprecated and just a wrapper for netgen.occ, import netgen.occ instead")
----> 7 from .occ import *

/opt/apps/alces/ngsolve_mpi/lib/python3.8/site-packages/netgen/ in <module>
----> 1 from .libngpy._NgOCC import *
      2 from .meshing import meshsize

ModuleNotFoundError: No module named 'netgen.libngpy._NgOCC'; 'netgen.libngpy' is not a package

Any clues why netgen complains? (btw, import netgen.occ also produces same error)

This is most likely because the version on the cluster is built without OCC support. Make sure that -DUSE_OCC=ON is set and occ is installed on the cluster.