Split multiple border free elements in a 3D mesh

Hello all,

Given a 3D mesh discretized with tetrahedras (done with FreeFEM or gmsh), I would like to select the corner elements which have more than 1 free border (two or three) and then I would like to split these elements by adding one node at the barycenter so that each element of the mesh has at most 1 free border.

Does anyone know how to do it ?

Thank you in advance for your help,

Best regards,

Loïc,