Very long surface meshing time for simple geometry

Hello,

I have an example which needs very long for surface meshing (about 5 minutes for 30.000 triangles on my machine). The geometry is very simple, I’m wondering why meshing takes so long and how this can be improved (usually this kind of geometry should not take more than a few seconds in netgen). Here is the example (v6.2.2403):

TopoDS_Shape s;
BinTools::Read(s, std::string("C:\\temp\\sbin2.brep").c_str());
auto occgeo = std::make_shared<netgen::OCCGeometry>(s);

netgen::MeshingParameters mp;
mp.perfstepsend = netgen::MESHCONST_MESHSURFACE;
mp.minh = 7.;
mp.maxh = 100.;
mp.grading = 0.5;

auto mesh = std::make_shared<netgen::Mesh>();
mesh->SetGeometry(occgeo);
occgeo->GenerateMesh(mesh, mp);

sbin2.brep (3.6 KB)

Kind regards,
Matthias

occ needs so long to build a triangulation of that surface, in netgen/libsrc/occ/occ_utils.cpp:77
The flags we set there are kind of their recommendation as in the link given in the comment there.

Maybe you can try playing with these parameters or ask the occ community/developers why this takes so long and what to do about this.

best
Christopher

Thanks Christopher!

The method BuildTriangulation is called inside OCCSetLocalMeshSize in order to create a triangulation on the occ-faces. The triangulation is used to define local mesh sizes by calling RestrictHTriangle on each triangle.

I assume that the triangulation should be as dense as possible at this stage. In the given example about 3.000.000 triangles are created here, however, the final mesh does only have 30.000 triangles (which is intended).

Does the triangulation need to be that dense at this stage?
Is the triangulation resolution somehow related to these mesh size parameters? (from NGSolve GUI):
image

no they are currently not steerable from gui. you can try changing them in cpp and see what effects they have. But without a clear reason what is happening there and how to prevent that in a stable way I think we are reluctant to change it. What should work is if you call the occ Triangulation function on the shape before meshing. As far as I know occ caches the triangulation and we would reuse it then. So you if you call the calctriangulation on the shapes before netgen does it should be possible for you to call it with different parameters.

One could make the parameters being dependent on the overall size of the shape in order to avoid unnecessary overtesselation and computational overhead at this stage. But since I don’t know the exact purpose of this triangulation inside the complete meshing process, I might be wrong that this would be an improvement.

This didn’t change anything on a quick test. Also, existing triangulations are removed from the shape inside BuildTriangulation by calling BRepTools::Clean.

Changing the aMeshParams.Relative to true in these settings helps in this case. But it changes a lot of meshes in our testcases quite significantly. So I’m not sure if this will get into main quickly. If you build netgen from source you can of course change this to fix the issue…

Yes, I see. Thank you anyway!