I have to agree with Larry. The project function does not work to
project from a finite element on a fine mesh to a finite element on
a coarser mesh. Here is a simple example. Take the hat function
on the 1D mesh (0, 1/4, 1/2, 3/4, 1) which is 1 at 1/4 are 0 at
the other nodes, and project it onto the continuous piecewise
linear functions on the coarser mesh (0, 1/2, 1). Simple use of
the project function claims that the projection is identically
zero, but that is obviously not correct. Is there an easy way
to correctly compute this in FEniCS?
from dolfin import *
mesh = UnitInterval(4)
V = FunctionSpace(mesh, 'CG', 1)
u = Function(V)
u.vector()[1] = 0.0 # nodal values of u are 0, 1, 0, 0, 0
mesh0 = UnitInterval(2)
V0 = FunctionSpace(mesh0, 'CG', 1)
u0 = project(u, V0)
print u0.vector().array()
The output is [0., 0., 0.], while the correct answer is [.625, .25, -.125].
I have to agree with Larry. The project function does not work to
project from a finite element on a fine mesh to a finite element on
a coarser mesh. Here is a simple example. Take the hat function
on the 1D mesh (0, 1/4, 1/2, 3/4, 1) which is 1 at 1/4 are 0 at
the other nodes, and project it onto the continuous piecewise
linear functions on the coarser mesh (0, 1/2, 1). Simple use of
the project function claims that the projection is identically
zero, but that is obviously not correct. Is there an easy way
to correctly compute this in FEniCS?
from dolfin import * mesh0, 'CG', 1)
mesh = UnitInterval(4)
V = FunctionSpace(mesh, 'CG', 1)
u = Function(V)
u.vector()[1] = 0.0 # nodal values of u are 0, 1, 0, 0, 0
mesh0 = UnitInterval(2)
V0 = FunctionSpace(
u0 = project(u, V0)
print u0.vector().array()
The output is [0., 0., 0.], while the correct answer is [.625, .25, -.125].