[NETGEN] Tag elements belonging to surfaces in CAD geometry

Hello! I am looking to mesh a very complex geometry that I have in a cad (step) file. After meshing I would like to export the mesh with boundary tags based on the surfaces in the original cad geometry. For example, if the shape were a cube, I would like to be able to specify that all mesh facets coming from the meshing of the “top” face of the cube have a certain tag, facets coming the “front” and “left” faces of the cube have a different tag, etcetera. The purpose of the tags is, of course, to apply boundary conditions later in my code.

I know one can tag geometry when building it with CSG but, as I said, my geometry comes from a CAD model and has thousands of faces in unknown order.
I can come up with geometric predicates to identify the surfaces I am interested into.

Is it possible to implement this with netgen? Can anyone share an example script or point me in the right direction?

I don’t care if it’s gonna be Python or C++, if I have to #include OpenCASCADE and use it directly. Everything works.

Thanks in advance for any help!
Massimiliano

yes you can do all this. There is just yet little documentation for this.

A starting point are these notebooks from the last usermeeting:
2d_occ.ipynb (17.6 KB)
3d_occ.ipynb (15.0 KB)

specifically section “Selection of shapes”

There is a bunch more stuff, if you look into the source code in netgen/libsrc/occ/python_occ_shape.cpp

If you have more specific questions feel free to ask!

Hello! Thanks for the reply :slight_smile:
I’ve been stuck with a CAD problem for a couple of weeks but now I’m finally getting ready to do the meshing :smiley:

However, I noticed that Netgen doesn’t do parallel meshing for 2D surfaces coming from CAD geometries and this is an issue for me because I’m meshing a geometry with hundreds of thousands of surfaces and, although I think the Netgen algorithm produces superior-quality meshes, it’s taking forever in my case and I afford it.
Are there any plans to address this issue?
In the meantime, I’ll see if I can do the surface mesh with another program and then import it into Netgen for the volume mesh.