 # 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;
``````

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

Axel

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`.