# Need some help to build variation formula for adjacent elements

Dear Freefem team

 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

Best regards

For equation (2) it. Is not so clean because do have directly asset to this kind of intégrale

But it is possible to bluid the adj of face, after we can the term (2)

Remark I suppose f is a face and e_i e_j is element,

I will try to make a small exemple.

yes, you are right sir, f is the face shared by two elements ei and ej

Dear sir, I was wondering if you had some examples. Thank you for you 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.

And in this case no problem to compute

\sum_f ||\nabla G(e_i)-\nabla G(e_j)||_2^2 = intallface(Th)(Wcg* InternalBE/2* jump(G)^2 );

so the varf is

varf D2(G,GG) = intallface(Th)( Wcg*InternalBE* jump(G)*jump(GG ));


where Wcg is a finite element function defined of face (P0face3d fespace)

Thank you sir, the part you mentioned confused me as well. I will check you example and thank you for the guidance.