Adding expressions with non-matching form arguments ('v_1',) vs ()

Hi, I am trying to solve the following pde with neumann condition. And I defined v as “n = FacetNormal(mesh)” to let the right hand side equal to “dot(Constant((1,0)),n)vds” for i = 1. But I got the error “Adding expressions with non-matching form arguments (‘v_1’,) vs ()”. Is anyone know the reason about this? Thanks in advance!

image

mesh = UnitSquareMesh(4, 6)
Ve = FiniteElement('Lagrange', mesh.ufl_cell(), 1)  
Re = FiniteElement('Real', mesh.ufl_cell(), 0)
X = FunctionSpace(mesh, MixedElement([Ve, Re]))
dx = Measure('dx')(subdomain_data=subdomains)
n = FacetNormal(mesh)
u, m = TrialFunctions(X)
v, r = TestFunctions(X)
a1 = inner(nabla_grad(u) + Constant((1,0)), k*nabla_grad(v))*dx + u*r*dx + m*v*dx
l1 = dot(Constant((1,0)),n)*v*ds

x = Function(X)
solve(a1 == l1, x) 

image

The issue here is that a1 is not bilinear:

The term

should be on the right hand side of your eq.
Consider the following minimal working example:

from dolfin import *
mesh = UnitSquareMesh(4, 6)
Ve = FiniteElement('Lagrange', mesh.ufl_cell(), 1)
Re = FiniteElement('Real', mesh.ufl_cell(), 0)
X = FunctionSpace(mesh, MixedElement([Ve, Re]))
dx = Measure('dx')
n = FacetNormal(mesh)
k = 0.1
u, m = TrialFunctions(X)
v, r = TestFunctions(X)
a1 = inner(nabla_grad(u) + Constant((1, 0)),
           k*nabla_grad(v))*dx + u*r*dx + m*v*dx

l1 = dot(Constant((1, 0)), n)*v*ds
F = a1-l1
a1 = lhs(F)
L1 = rhs(F)
x = Function(X)
solve(a1 == l1, x)
1 Like