I was wondering if you could give me some guidance to build the second terms of this variation formula. The first term is pretty straight forward. however , the second term need find all the adjacent element share the same face. I know how to build the adjacent matrix in freefem. However, I may need some help to set it in the variation formula and build the right matrix. Thank you for the attention

REmark, It formula have no real sens if the \nabla G(e_i) is not constante
because I do not understand ||\nabla G(e_i)-\nabla G(e_j)||_2^2 because the definition domain is e_i or e_j. So for me the formula (2) is wrong it is on ||\nabla G(e_i)-\nabla G(e_j)||_{f,2}^2 (integration of f). remark if G is P_1 then you have just a change in \omega_{cg} term.