Thanks for your reply. I have taken care of the boundary condition. Basically I have a weak form with 3 weighting function spaces. These 3 spaces have 3 different dirichlet boundary conditions . My basic questions ais how to do mixed space formulation for more than 2 function spaces in fenics. After incorporating your suggestions my code is :
`from dolfin import *
import numpy, sys
degree = int(sys.argv[1])
divisions =[int(arg) for arg in (sys.argv[2:])]
mesh=UnitSquareMesh(*divisions)
V = FunctionSpace(mesh,"Lagrange",degree)
Q = FunctionSpace(mesh,"Lagrange",degree)
L = FunctionSpace(mesh,"Lagrange",degree)
M = MixedFunctionSpace([V,Q,L])
Test= TestFunction(M)
(v,q,w) = split(Test)
Trial = TrialFunction(M)
(u,mu,lmd) = split(Trial)
F=inner(nabla_grad(lmd),nabla_grad(v))*mu*dx +inner(nabla_grad(lmd),nabla_grad(u))*q*dx
+inner(nabla_grad(w),nabla_grad(u))*mu*dx
def boundary_ul(x,on_boundary):
on_boundary and (near(x[0],0.0) or near(x[0],1.0) \
or near(x[1],0.0) or near(x[1],1.0))
def boundary_mu(x,on_boundary):
on_boundary and (near(x[1],0.0) or near(x[0],1.0))
PrescribedU=Expression("0.25*(pow(x[0],2)+pow(x[1],2))-x[0]*x[1]*0.5-x[0]+0.5*x[1]")
bcs_u = DirichletBC(M.sub(0),PrescribedU , boundary_ul)
PrescribedMU= Expression("(2/(exp(2)-1))*(exp(2*x[0])+2*x[1])")
bcs_mu=DirichletBC(M.sub(1),PrescribedMU,boundary_mu)
bcs_lmd=DirichletBC(M.sub(2),Constant(0.0),boundary_ul)
bcs=[bcs_u ,bcs_mu , bcs_lmd]
solution = Function(M)
solve(lhs(F)==rhs(F),solution, bcs)
`
With the above code I get the following error message.
Unable to extract all indices.
Traceback (most recent call last):
File "objmin_var.py", line 82, in
solve(lhs(F)==rhs(F),solution, bcs)
File "/usr/lib/python2.7/dist-packages/dolfin/fem/solving.py", line 268, in solve
_solve_varproblem(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/dolfin/fem/solving.py", line 292, in _solve_varproblem
form_compiler_parameters=form_compiler_parameters)
File "/usr/lib/python2.7/dist-packages/dolfin/fem/solving.py", line 80, in __init__
a = Form(a, form_compiler_parameters=form_compiler_parameters)
File "/usr/lib/python2.7/dist-packages/dolfin/fem/form.py", line 56, in __init__
common_cell)
File "/usr/lib/python2.7/dist-packages/dolfin/compilemodules/jit.py", line 66, in mpi_jit
return local_jit(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/dolfin/compilemodules/jit.py", line 154, in jit
return jit_compile(form, parameters=p, common_cell=common_cell)