This is my first time posting on stackoverflow. If I make any mistakes please tell me.
For some background: I have recently started learning about meshing for CFD, and I'm trying to generate a pure hexmesh with OpenFOAM's builtin snappyHexMesh. However, snappyHexMesh is super awful at creating boundary layers, so I am trying to substitute them myself, by creating an offset .stl file and generating a single layer of cells between the two.
I want to try using CGAL's alpha wrapping function, as it seems to do exactly what I want (a scaled up version of my .stl). I have tried to simply scale the .stl, however I need the offset to be roughly the same in every direction, and scaling the stl file by a factor does not achieve that.
Im using python 3.10 and tried both pygalmesh as well as cgal swig bindings, both of which I installed with pip install.
So far I have tried:
import pygalmesh
import meshio
myMesh = meshio.read("myGeometry.stl")
myMesh1 = pygalmesh.alpha_wrap_3(myMesh, 0.01, 0.1)
This gives the error "module pygalmesh has no attribute alpha_wrap_3" How else can I call the function? It does not show up when I list all functions with
import pygalmesh
print(help(pygalmesh))
The other thing I tried:
from CGAL import CGAL_Alpha_wrap_3
from CGAL import CGAL_Polygon_mesh_processing as pmp
This works (at least gives no errors) and I can call the function CGAL_Alpha_wrap_3, which only gives the error that the variables are not defined. But I dont know how to import my geometry into this. When I try to import my geometry using Polygon_mesh_processing.IO.read_poly_mesh("mygeometry.stl") I get the error that the class IO does not exist. I can look at all classes and functions of CGAL_Polygon_mesh_processing but I dont see any option to import my geometry.
**TDLR; How can I use the Alpha_wrap_3 function with an imported .stl in Python? ** Thanks!
You may find the answer in the cgal-swig-bindings wiki and more particularly in this example from their Github repository.
The
alpha_wrap_3function from theCGAL.CGAL_Alpha_wrap_3module expects (in your case): aPolyhedron_3as the input mesh, scalars for alpha and offset, and aPolyhedron_3as the output enveloppe.Cheers !