Access normal vector

I would like to try and write some code for approximating the curvature of the boundary of the mesh. The current solution proposed in the function “curvature” does not work too well and I would like to try other variants.

The normals computed in FreeFEM are normals to the edges of the boundary or normals approximated at the vertices on the boundary?

Normals are computed on integration points, you can save it in a vector using this trick:

mesh Th = square(10, 10);
fespace Uh(Th, P1);

int i = 0, j = 0;
real[int] nx(Uh.ndof), ny(Uh.ndof);
real a = int1d(Th)((nx[i++] = N.x) + (ny[j++] = N.y));
cout << nx << endl;
cout << ny << endl;

I suppose that your question is about surface mesh

The “curvature”function is defined for a 2D mesh. An equivalent for surface 3D could be developed as soon as possible

For a meshS, there are 2 types of normals computed in FreeFEM
-> N is the exterior normals (flux)
-> Nt is normal the surface element
normals at vertices doesn’t exist for the moment, elements are flat


Thank you for this information. @Simon: nice trick for saving the normal information!

In fact, my question is about a 2D mesh. The curvature function works well when the mesh comes from “buildmesh” with a nice parametrization, but I have the impression that it is not too stable. For example, when computing the curvature of a slightly perturbed disk using “curvature” the result oscillates too much.

Dear Beniamin Bogosel,
Thank you for your question! I am also caught in the problem that the function ''curcature‘’ does not work. There is a compile error about the code ~load “curvature”~, I can not load it, have you ever solved this trouble? Many thanks!

Sorry for replying this late. You should use load "Curvature" with upper case C. Then using Kappa = curvature(Th,label); should work, where Th is a mesh variable and label is the boundary Label. Also Kappa must be a P1 finite element function on the mesh Th.

Hi! Can we use the curvature command to a level set function?

Use the plugin “distance”

eee example: forme the source :

1 Like

Hi Sir!. I am confused about how I am going to incorporate the command distance. If I have kappa as the curvature of my level set function, then
kappa = curvature(Th, levelset=phi). But this is not workable since the command curvature works on the boundary of the mesh. Please correct me if I am wrong. Thank you!

Yes , curvature function compute the curvature of a mesh boundary.
but if \psi is a distance function of the levelest \phi=0,
then \nabla(\psi) is an approximation the normal to the level set and
\nabla\nabla(\psi).\tau.\tau is a approximation de the curvature (where \tau is the tangent to the level set, but not well defined, because \psi is affine on each triangle.

1 Like

I capture the level set with isoline function and parameter close=0, after is transform in boundary with border function, finally build a mesh with buildmesh.