The “adj“ function in mesh connectivity is very useful, which can find the adjacent triangle of the triangle k by edge e using only one statement “Th[k].adj(e)”.
I’m doing a FEM analysis work using Python rather than FreeFem++, and I wonder how to implement the “adj“ function when the mesh information is known, i.e., the mapping between mesh k and the corresponding vertex id is known?
Or is it possible to find the source code which implementing the “adj” function
I think you can do as
– First build for each vertex the list of triangles around it, by making a loop on triangles and attributing the triangle index to each of its 3 vertices.
– Then you make a loop on triangles (index k) and a subloop on its edges (index e), giving two vertices as ends, and for each of these two vertices you look in the list of their neighbouring triangles (built in the first step) to find if there is a common triangle in these two lists (additionally to the current triangle). Then you can register this triangle as the adjacent of (k,e).