This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

MatrixFunctionSpace?

+1 vote

Is there a way in FEniCS to create a MatrixFunctionSpace? For example, if I want to solve the Stokes equations I would like to solve also for the velocity gradient as an unknown variable (I don't want to compute the velocity gradient as a post-processing step by using grad(u)). So for my Stokes problem I have a VectorFunctionSpace for my velocity unknown, a FunctionSpace for my pressure unknown, but how can I set a matrix function space for my velocity gradient unknown?

asked Dec 1, 2014 by srhebergen FEniCS Novice (130 points)

1 Answer

+2 votes

Hi!

You should apply the TensorFunctionSpace;

TFS_CG1 = TensorFunctionSpace(mesh, "CG", 1)

For each degree of freedom TFS_CG1 will contain a tensor of 4 components in 2D and 9 components in 3D. If one has solved for the velocity field one can f.ex. do

grad_u = project(grad(u), TFS_CG1)
# Plot du/dx
plot(grad_u.sub(0))

Just an easy example. More info here:

http://fenicsproject.org/documentation/dolfin/dev/python/programmers-reference/functions/functionspace/TensorFunctionSpace.html

Hope this helps!

answered Dec 3, 2014 by joakibo FEniCS User (1,140 points)
edited Dec 3, 2014 by joakibo

That works, thanks!

...