Suppose u and v are my trial and test functions from the P1 (1st order Lagrange) space. If \phi denotes the basis functions then
u = \sum_j \phi_jU_j\quad\mathrm{and}\quad v=\hat{\phi_i}
The mass matrix M and the stiffness matrix K are
M_{ij} = \int\hat{\phi}_i\phi_j\mathrm{d}x\quad\mathrm{and}\quad K_{ij} = \int\nabla\hat{\phi}_i\cdot\nabla\phi_j\mathrm{d}x
I can assemble the mass matrix and the stiffness matrix in dolfin
as
a_K = inner(grad(u), grad(v))*dx
a_M = u*v*dx
M = assemble(a_M)
K = assemble(a_K)
Now I have another term
∫f(x)uv\mathrm{d}x\quad\mathrm{where}\quad f = \sum_k\phi_kF_k
To calculate this term as tensor product I require assembling the following rank 3 tensor
Q_{ijk} = \int\hat{\phi}_i\phi_j\phi_k\mathrm{d}x
How can I assemble this third-order tensor in dolfin
? To see the context for this question please see this question.