Given a Function u in a FunctionSpace
, I would like to obtain the associated derivative as a Function
defined on the quadrature points. This may currently be done by using project
. However it is far too expensive with respect to my needs, especially when u is a vector with tensor-valued derivatives.
As an example, consider
mesh = UnitSquareMesh(10,10)
Vu = FunctionSpace(mesh, 'CG', 1)
Vq = VectorFunctionSpace(mesh, 'Quadrature', 0)
u = Function(Vu)
u = interpolate(Expression("pow(x[0],2)"),Vu)
eps = grad(u)
The currently working method to retrieve a function with eps at the quadrature point is
project(eps,Vq)
Something like interpolate(eps,Vq)
does not work because eps is not a GenericFunction
or Expression
. Is there any other efficient method to get the value of eps by simple and unprocessed evaluation of the derivative of the shape functions at the Gauss points? Of course, I want to avoid iteration loops though elements and Gauss points in python.
I known that there exists the recently added LocalSolver
to have a cheap version of 'project'. I am currently using this approach. But it is still somewhat unnecessary complex and undirect.
P.S.: I need this because I am looking at this because I am trying to develop a python version of a solver for plasticity (I known there exists https://bitbucket.org/fenics-apps/fenics-solid-mechanics in C++).