Hi, I am having a problem in project grad(u) only on the boundaries on fenics 2016.1.0, and get error Unable to successfully call PETSc function ‘MatSetValues’., here is the MWE:
from dolfin import *
import mshr as mr
#parameters[“allow_extrapolation”] = True
LL=1.;HH=1.
Lx=0.4;Ly=0.5;Lz=0.2
R=50
Rectangle = mr.Rectangle(Point(0, 0), Point(LL, HH))
mesh=mr.generate_mesh(Rectangle, R)
V=VectorFunctionSpace(mesh, “CG”, 2)
V_CG1=FunctionSpace(mesh, “CG”, 2)
u_trial=TrialFunction(V)
u_ =TestFunction(V)
#u=Function(V)
expr=Expression(‘x[1]*x[1]+x[0]*x[0]*x[0]’, degree=4)
f=interpolate(expr, V_CG1)
a=inner(u_trial, u_)*ds
A=assemble(a)
A=assemble(a, keep_diagonal=True)
A.ident_zeros()
L=inner(grad(f), u_)*ds
b=assemble(L)
u=Function(V)
solve(A, u.vector(), b)
File(“test_proj_on BD/u.pvd”)<<u
Can anyone tell me how to fix this?