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

Project expression to subfunction

+3 votes

I want to project an expression to a 0th-degree DG subfunction (i.e. function of a "subspace" of a mixed space). Below is my attempt. However, it seems something goes wrong, perhaps the order of the DOFs is handled incorrectly. That is suggested by the plot of the resulting function. I have read about similar issues on the forums and tried FunctionAssigner, but without success.

from dolfin import *

mesh = UnitSquareMesh(10, 10)

RT    = FunctionSpace(mesh, "RT", 1)
P     = FunctionSpace(mesh, "DG", 0)
mixed = MixedFunctionSpace([RT, P, P])

psi0  = Function(mixed);

f = Expression("x[0]")

assign(psi0.sub(2), project(f, mixed.sub(2).collapse()))

plot(psi0.sub(2))

interactive()

I tried this with version 1.3.0 of Fenics.

asked Feb 11, 2014 by hellman FEniCS Novice (360 points)
edited Feb 11, 2014 by hellman

2 Answers

0 votes
 
Best answer

This should be fixed in the development version of DOLFIN.

answered Mar 2, 2014 by johanhake FEniCS Expert (22,480 points)
selected Feb 12, 2015 by hellman
0 votes

I guess this is related to Issue #93, because if I replace the RT-space with the P-space, it seems to work. This is however not desirable for me. Is there some workaround that I could use to accomplish the same thing?

answered Feb 11, 2014 by hellman FEniCS Novice (360 points)
...