Longer answer:
The traditional C-interface nglib is kept alive, but not updated for longer time…
You may want to work directly with the Netgen C++ classes, without the C-wrapper.
The easiest way to migrate is to search for the Ng_ function in the interface, and work directly with the C++ mesh class:
There might be an argument for the traditional C-API, if one system-installed Netgen is used by various applications. But, since you are already including internal headers, it seems you are already bypassing the C-interface.
thank you for your feedback. I managed to update Engrid 1.4 to the latest netgen version. The actual challenge was to get the new exception handling updated. Unfortunately the effort was of no use because the Engrid codebase is so out of date with respect to its dependencies (vtk and qt changed to drastically in recent years), that I can’t get it to work and my latest conclusion is, that I would have to rewrite engrid from scratch. Updating the dependencies was insufficient due to changes of the memory management etc. in newer versions of the core libraries. It’s a shame because engrid is a masterpiece from its capabilities perspective.
Now, I have been thinking to turn the idea on its head and implement engrid’s boundary layer meshing capabilities in netgen.
The background: I need a cfd mesh generation software that excells in boundary layer mesh generation for OpenFOAM simulations but I think SU2 users would be happy to use it, too. There are many open source mesh generation tools and libraries but when it comes to prismatic boundary layer mesh generation and a y+<1 requirement they are pretty weak.
Questions:
I understand that there’s already some layer creation functionality in netgen using a “splitting tets” approach can you elaborate on that? What’s the use case and approach?
The Engrid 1.4 approach is basically: create a smooth surface mesh, extrude a boundary layer shell from it into the volume mesh direction, create the volume mesh, split the shell into layers and adjust the inlet and outlet surface meshes as the edge regions are replaced by faces of the boundary layer mesh and course there’s a lot of heights and normals calculation and smoothing going on in the process.
What would be the entry point in the netgen code to implement something like this?
since very recent, there is also a boundary layer feature in Netgen. After surface meshing, a prism layer is grown from the surface mesh, and the tet-mesher starts after the layers.
It was implemented mainly by Matthias, he will explain more on that.
It’s definitely good to have more users / testers for this new feature.
I had a hands-on look at the mesh and BL creation functionality but the NGSolve GUI menu option to create a prismatic boundary layer doesn’t work i.e. doesn’t open a dialog. A computation starts immediately and NGSolve crashes after some time.
My initial test cases are the reproduction of these two cases:
My objectives are cases similar to wingbodies using turbulence models that require y+<1, suitable for laminar-turbulent transition flow simulations.
I had a look at the BL related source code and the test script - it’s all very promissing.
I am looking forward to the feedback from Matthias and regarding the above mentioned issue.
There is currently no GUI interface for the Boundary layer generation. Here is a short example using the hinge.stl geometry in the netgen/tutorials directory:
from netgen.stl import STLGeometry
from netgen.meshing import BoundaryLayerParameters
geo = STLGeometry("hinge.stl")
# don't grow blayers on last two faces (to treat inlet and outlet boundary)
blp = [BoundaryLayerParameters(thickness=[0.1, 0.2], boundary=list(range(1,15)), outside=False)]
m = geo.GenerateMesh(boundary_layers=blp)
In C++, the Interface is very similar, just set the boundary_layers member in the MeshingParameters object used in the GenerateMesh call.
Note that this code was mainly developed for electomagnetic simulations and might not create layers that are perfectly suited for CFD simulations. One limitation might be that the thickness is currently constant, but this could be easily changed.
I ran the hinge example (and tried may others) but I can’t visualize a boundary layer?!
This is the terminal output I get when running the hinge example:
netgen BL-test-2.py
optfile ./ng.opt does not exist - using default values
togl-version : 2
OCC module loaded
loading ngsolve library
NGSolve-6.2.2504
Using Lapack
Including sparse direct solver Pardiso
Running parallel using 16 thread(s)
Delaunay meshing
Volume Optimization
Delaunay meshing
Volume Optimization
Meshing done, time = 0.210221 sec
Delaunay meshing
Volume Optimization
Meshing done, time = 0.21023 sec
Thank you for using NGSolve
All I see, when I use the clipping option in the GUI, is the meshed shell of the hinge.
BR,
Klaus
…
I spend some more time attempting to get the boundary layer functionality to work but didn’t succeed.
There are two observations:
1: The boundary layer creation fails or to be precise, it seems not to be triggered. I tried creating a boundary layer on the hinge.stl model as you suggested and a cube, sphere or a cylindrical hole through a cube created using the occ functionality. I played also with the anisotropic meshing functionality, which works fine.
2: On one occasion when I tried to create 2 layers on a cylindrical hole through a cube (a very small cube), millions (5+) of surface cells were created according to the number shown at the bottom of the GUI. netgen ran out of memory (exceeding the 16Gb + extended memory available) and crashed, there was also an indication of an omp issue.
How should be proceed to fix the problem. Of course maybe I am just missing an important point.
I came back to the hinge example and tried the code below. I tried the viewing options but I am still stuck with shells and apparently no boundary layers being created. I went through the source code and tried boundary layers e.g. on a simple cube but have not been able to create one. I am probably missing a step/point in the process?!
from netgen.stl import STLGeometry
from netgen.meshing import BoundaryLayerParameters
Load the hinge geometry
geo = STLGeometry(“hinge.stl”)
Define boundary layer parameters for the outside of the hinge
blp = [
BoundaryLayerParameters(
thickness=[0.1, 0.2, 0.3], # Three layers with increasing thickness
boundary=“hinge_surface”, # Regex pattern matching hinge surfaces
outside=True, # Grow outward from the hinge surface
new_material=“boundary_layer”,# Material name for new elements
grow_edges=True, # Grow layers along sharp edges
limit_growth_vectors=True, # Prevent self-intersections
disable_curving=False # Allow curved elements for better quality
)
]
Generate mesh with boundary layers
m = geo.GenerateMesh(
boundary_layers=blp,
maxh=0.5, # Base mesh size
grading=0.3, # Grading factor
optsteps3d=5 # Optimization steps
)