This proposal is related to the discussion Behavior of varf with rhs and on()
I think it would be useful to have a new option “rhsvarf” (=true or false)
for the on() tool that sets Dirichlet BC.
– If on() is used in the context of “solve” or “problem”, the option has no effect, and the behavior is the present one.
– The default value of rhsvarf would be “true”, in this case the behavior of on() is the present one. This means that when used within “varf”, the imposed value (i.e. g for “on(1,u=g)” ) is interpreted to the right-hand side.
Ex
varf test(u,v)
=int2d(Th)(dx(u)*dx(v)+dy(u)*dy(v))
-int2d(Th)(a*v)
+on(1,u=g)
;
Then tab=test(0,Vh); sets tab to +g*tgv (additionally to the -int2d(Th)(a*v) terms)
– Setting rhsvarf=false would imply that when used within “varf”, the imposed value g is interpreted in the left-hand side (thus changing its sign).
For the previous example it means that
tab=test(0,Vh); sets tab to -g*tgv (additionally to the -int2d(Th)(a*v) terms)
As a consequence, both codes
solve prob(u,v)
=int2d(Th)(dx(u)*dx(v)+dy(u)*dy(v))
-int2d(Th)(a*v)
+on(1,u=g)
;
solprob=u[];
and
varf test(u,v)
=int2d(Th)(dx(u)*dx(v)+dy(u)*dy(v))
-int2d(Th)(a*v)
+on(1,u=g,rhsvarf=false)
;
matrix A=test(Vh,Vh);
tab=test(0,Vh);//compute the left-hand side
tab=-tab;//transform it into right-hand side
sol=A^-1*tab;
would give the same solutions solprob and sol.