I would like to know if it is possible to mesh only a face from a 3d step file.
All faces have unique name, and we can read them with mesh.GetBoundaries().
If it isn’t possible, i would like to know how to print boundary’s vertices.
I can suggest the following plans, if one fits I can get into more details:
- extract the OCC-face (as a shape) from the OCC geometry, and mesh only that one
- mesh the whole geometry, iterate over all boundary elements, check the bc-label of that element, and get all vertices of that boundary element (uses Python loops)
- define fes=H1(mesh, order=1) finite element space, and ask for the RegionDofs of the boundary-region of interest. You will get a BitArray (all loops are executed in fast C++ code)
I think the best is the first one.
Will it work if I only have netgen.occ ?
Thanks a lot for your answer.
We create a cube, name the faces and store it as step-file
from netgen.occ import * shape = Box((0,0,0), (1,1,1)) shape.faces.name = "default" shape.faces.Max(X).name = "righttop" shape.faces.Max(Z).name = "righttop" shape.WriteStep("cube.stp")
We reload the step-file as Netgen-OCCGeometry, and extract the OCC-shape. We can extract the faces using the netgen.occ - Python wrapper to OCC. Finally, we make a new Netgen-OCCGeometry:
geo = OCCGeometry("cube.stp") shape2 = geo.shape for f in shape2.faces: print (f.name) rt = Glue (shape2.faces["righttop"]) partgeo = OCCGeometry(rt)
and mesh it:
from ngsolve import * from ngsolve.webgui import Draw # using jupyter drawing mesh = Mesh(partgeo.GenerateMesh(maxh=0.2)) Draw (mesh);
I’ve just tried it, and it doesn’t work for me.
Print (f.name) returns all the faces’s name but the mesh makes no cells or elements.
(Geometrie is another STEP file, but it do the same as cube.stp)
This is my code with your recommandations :
from netgen.occ import *
from ngsolve import *
import pyvista as pv
geo = OCCGeometry(“Geometrie.stp”)
shape2 = geo.shape
for f in shape2.faces:
rt = Glue (shape2.faces[“Face3”])
partgeo = OCCGeometry(rt)
mesh = Mesh(partgeo.GenerateMesh(maxh=100))
vtk = VTKOutput(ma=mesh,
grid = pv.read(‘Face3.vtu’)
plotter = pv.Plotter()
The jupyter library never works for me, so I use pyvista and the VTK Output command instead.
Thanks for your help
it was the fault of the VTKOutput.
I change for a STL Export and all working fine.
Thanks Again !