First, I'm sry for such trivial question (once again) but I cannot google the solution and also didn't find it in the FENICS book (although I didn't read everything). I simplified my original problem to the problem of implementing the grad of vector function.
from dolfin import *
dim = 2
mesh = UnitSquareMesh(5,5)
V = VectorFunctionSpace(mesh, 'DG', 1)
W = TensorFunctionSpace(mesh, 'DG', 1, shape=(dim,dim))
U = Function(V)
M = Function(W)
for i in range(dim-1):
for j in range(dim-1):
assign( M[i,j], U[i].dx(j) )
According to FENICS book (pg. 313) the j-th derivative of i-th component of vector function U should be U[i].dx(j). The result I'm getting with this code is that the assign method ends with error 'list of Function expected'.
I also tried the following option
ind = i*dim + j
assign( M.sub(ind), U[i].dx(j) )
which gave me the same error.
Can you pls help me with the correct syntax? I would also appreciate if you can recomend me some tutorial to syntax in FENICS. How to work with vectors, functions, derivatives - how to acces components of those. Im kind of lost in those and cannot find the answers anywhere.