Hi folks,
I am trying to project the gradient of my solution to a function space, say V. project(grad(u), V) used to work well and the output was a vector. But after updating FEniCS to its latest version, I get the following error:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Shape mismatch.
Traceback (most recent call last):
File "test_cj_simple.py", line 30, in
g_cj = project(grad(cj), V)
File "/usr/lib/python2.7/dist-packages/dolfin/fem/projection.py", line 100, in project
L = ufl.inner(w, v)ufl.dx()
File "/usr/lib/python2.7/dist-packages/ufl/operators.py", line 127, in inner
return Inner(a, b)
File "/usr/lib/python2.7/dist-packages/ufl/tensoralgebra.py", line 184, in new
ufl_assert(ash == bsh, "Shape mismatch.")
File "/usr/lib/python2.7/dist-packages/ufl/assertions.py", line 37, in ufl_assert
if not condition: error(message)
File "/usr/lib/python2.7/dist-packages/ufl/log.py", line 154, in error
raise self._exception_type(self._format_raw(*message))
ufl.log.UFLException: Shape mismatch.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
This error is produced running the following code:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
from dolfin import *
import numpy
n = 100
mesh = IntervalMesh(n,0,1)
V = FunctionSpace(mesh, 'CG', 1)
mesh_coor = mesh.coordinates()
cj = TrialFunction(V)
v_cj = TestFunction(V)
x0_cj = mesh_coor[50][0]
f_cj = PointSource(V, Point(x0_cj))
a_cj = cjv_cjdx + inner(grad(cj), grad(v_cj))*dx
A_cj = assemble(a_cj)
B_cj = dolfin.Vector(A_cj.size(0))
B_cj.array()[:] = 0
f_cj.apply(B_cj)
cj = Function(V)
solve(A_cj, cj.vector(), B_cj)
g_cj = project(grad(cj), V)
plot(cj)
interactive()
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Any help is deeply appreciated.
Thanks,
Mo