Hello,
I am trying to use Lagrange multiplier to impose \mathbf{u.n}=0 on \partial \Omega while solving the poisson equation \Delta\mathbf{u}=\mathbf{f}. First I wanted to know wether the Lagrange multipliers provide a soft condition. Because having normal \mathbf{u} non zero on the boundaries ain’t acceptable.
Since my mesh is sometimes round I can’t use Dirichlet boundary conditions.
After multiple tries and research my code is the following:
#With a given mesh
#Declare the spaces
Vx = FiniteElement("Lagrange", mesh.ufl_cell(), 2)
Vy = FiniteElement("Lagrange", mesh.ufl_cell(), 2)
Lm= FiniteElement("Lagrange", mesh.ufl_cell(), 1)
# Make a mixed space
TH = MixedElement([Vx,Vy,Lm])
Esp= FunctionSpace(mesh, TH)
n = FacetNormal(mesh)
(ux,uy, l) = TrialFunctions(Esp)
(vx,vy, m) = TestFunctions(Esp)
a = (dot(grad(ux), grad(vx))+dot(grad(uy), grad(vy)))*dx\
-(dot(grad(ux),n)*vx+dot(grad(uy),n)*vy)*ds\
+(ux*n[0]+uy*n[1])*m*l*ds #The part I'm not sure about...
L = (f[0]*vx+f[1]*vy)*dx
solu = Function(Esp)
#Work fine tile here
solve(a==L, solu)
Then I get the error:
ValueError: too many values to unpack (expected 2)
The solution I found is to use a penalisation coefficient P=10^{15} before the term \int\mathbf{u.n}\,\mathrm{d}s which I multiply with the symetric expression for the test function to get the bilinear form:
P\int\mathbf{u.n}\,\mathrm{d}s\int\mathbf{v.n}\,\mathrm{d}s
VectorFunctionSpace(mesh, 'P', 2)
n = FacetNormal(mesh)
u = TrialFunction(V)
v = TestFunction(V)
a = (dot(grad(u[0]), grad(v[0]))+dot(grad(u[1]), grad(v[1])))*dx\
-(dot(grad(u[0]),n)*v[0]+dot(grad(u[1]),n)*v[1])*ds\
+P*dot(u,n)*dot(v,n)*ds
L = dot(f,v)*dx
u = Function(V)
solve(a==L, u)
This solution seems to work, yet it might be due to the simplicity of poisson equation.
I need to have proper methods before moving onto more complex equations (the Toner-Tu equation for active matter if you know…)
Any kind of comment or help would be appreciated.
Thanks a lot in advance!
PS: Sorry for the grammar mistakes I am just a french…