Hello all,
I want to confirm a quick question, in FEniCS, the project function is project the original function to the finite element space using the degree of freedom of that finite element space right?
Thanks
Hello all,
I want to confirm a quick question, in FEniCS, the project function is project the original function to the finite element space using the degree of freedom of that finite element space right?
Thanks
Yes. In particular, it is L^2 projection onto the finite element space. See the following code example:
from dolfin import *
# L^2 projection onto the space V:
def my_project(u,V):
ut = TrialFunction(V)
v = TestFunction(V)
uh = Function(V)
solve(inner(ut,v)*dx==inner(u,v)*dx,uh)
return uh
# Compare with project function:
N = 10
mesh = UnitSquareMesh(N,N)
V = FunctionSpace(mesh,"CG",1)
x = SpatialCoordinate(mesh)
u = sin(x[0]*pi)*sin(2*x[1]*pi)
print(assemble(abs(my_project(u,V)
- project(u,V))*dx))
Thank you, kamensky! But for example if you are using BDM or RT element, I guess the projection is not L^{2} projection right? It should make use of the degree of freedom of BDM or RT right?
Thanks
L^2 projection still makes sense for RT/BDM elements, as the corresponding spaces are subsets of L^2. You can verify this by modifying the last part of my example above:
V = FunctionSpace(mesh,"RT",1)
x = SpatialCoordinate(mesh)
u = as_vector(2*(sin(x[0]*pi)*sin(2*x[1]*pi),))
e = my_project(u,V) - project(u,V)
print(assemble(dot(e,e)*dx))
Hello Kamensky, thank you very much for the explanation in detail! For RT/BDM elements, are you aware of any projection using the degree of freedom of RT/BDM instead of the L^{2} projection?
Thanks
I’m not sure I understand what you’re asking. The result of L^2 projection \Pi^h: L^2\to V^h onto some finite-dimensional space V^h\subset L^2 (be it a CG space, an RT space, or some other subspace of L^2) will return a function in V^h, which will be defined by some vector of degrees of freedom for V^h. In that sense it is “using the degrees of freedom” of V^h, regardless of what type of space V^h is.
Hello kamensky, thank you so much for all of your kind help and sorry for my late reply, what I am asking is actually that, you know for RT/BDM elements, they have their own degree of freedom, so if you have a H^{1} function, the degree of freedom from RT/BDM could be used to determine uniquely a function say in V_{h}. Yeah, I agree the L^{2} projection still makes sense in the RT/BDM spaces, but what I wonder is how to use the degree of freedom say of BDM/RT themselves to do the projection.