Change of sign in linear part of variational problem (varf vs problem)

Hello,

I am novice to FreeFem and experimenting with the abundant features. Among other things, i read that the use of varfis supposed to be faster than problem.. So I tried it out in a simple example of linear elasticity, only to realise that it seems I need to inverse the sign of my neuman boundary in the problem definition. For example:

// Parameters
real E = 21e5;
real nu = 0.28;
real mu= E/(2*(1+nu));
real lambda = E*nu/((1+nu)*(1-2*nu));
real f = 1e10;

// Mesh
mesh Th = square(10, 10);
// Fespace
fespace Vh(Th, [P2,P2]);
Vh [u1, u2];
Vh [t1, t2];
real[int] sol(Vh.ndof);
// Macro
real sqrt2=sqrt(2.);
macro epsilon(u1,u2) [dx(u1),dy(u2),(dy(u1)+dx(u2))/sqrt2] //
macro div(u,v) ( dx(u)+dy(v) ) //



solve lame1([u1, u2], [t1, t2])
= int2d(Th)(
        lambda * div(u1, u2) * div(t1, t2)
      + 2.*mu * ( epsilon(u1,u2)' * epsilon(t1,t2) )
   )
   - int1d(Th,3)(
        f*t2
   )
   + on(4, u1=0, u2=0)
   + on(2, u1=f)
   ;

cout << int2d(Th)(u1)<<","<<int2d(Th)(u2) << "\n";
// manual solution
varf lame2([u1, u2], [t1, t2])
= int2d(Th)(
        lambda * div(u1, u2) * div(t1, t2)
      + 2.*mu * ( epsilon(u1,u2)' * epsilon(t1,t2) )
   )
   + int1d(Th,3)(
        f*t2
   )
   + on(2, u1=f)
   + on(4, u1=0, u2=0)
   ;
matrix A = lame2(Vh, Vh);
real[int] F = lame2(0,Vh);
sol=A^-1*F;
u1[]=sol;
cout << int2d(Th)(u1)<<","<<int2d(Th)(u2) << "\n";

Here i need to inverse the sign of the boundary (lines 27 and 41) to obtain the same results. (if both signs are the same, different values will be printed)

Is this the desired behavior or just a quick fix from my side? Where can i find more information regarding the mathematical definition of the varf and problem?
Thanks in advance for your answers!

solve vSolve(u, v) = a(u, v) + l(v) solves a(u, v) + l(v) = 0 while varf vPb(u, v) = a(u, v) + l(v) solves a(u, v) = l(v), so it is expected that you need to shift the sign in front of the linear form.

2 Likes