Hello,
I wanted to extract normal vector at boundary (like for x- face, its is (-1,0,0) or y+ face ((0,1,0) for simple cube). How can I get such data in dolfinx.
How can I extract facet normal of boundary vertices?
In legacy-dolfin, the following commands worked, but, I couldnāt replicate it in dolfinx.
dim=3
bdim = dim-1
bmesh = BoundaryMesh(mesh, "exterior")
mapping = bmesh.entity_map(bdim)
m=mapping[cell.index()]
curr_facet_normal = Facet(mesh, m).normal()
# After executing
curr_facet_normal.x()
# I was able to get normal vector x component corresponding to facet.
Can you suggest getting similar normal vector x component in dolfinx. I tried n=Facetnormal(mesh), but, couldnāt extract n data like n.vector[:].
Please note that you are not extracting the normal at boundary vertices in legacy dolfin, as this would not be well-defined.
You are extracting the normal of each facet (which is unique and constant in the case of affine meshes).
I guess the OP is very close to what he wants, he just needs to access, or visualize his ānā, unless I am missing something?
Anyway, I have ran the code from the Github snipet, as is.
I got a strange figure with Paraview (yellow colored arrows, but there is no yellow in the colormap, so no idea what value they have.). Strange directions. Apparently the code produces a tangent folder, but no normal one, by default.
In this gist you can find a code for approximating facet vectors on all facets or a subset of facets on a dolfinx mesh. The function has a flag tangent. When this flag is set to False the facet normal vectors will be approximated, whereas the facet tangent vectors are approximated when the flag is set to True.