$L^2$ Projection

Hello dear all,

I have question about L^2 projection in fenics… specifically if I have solution vector u to pde, I can get gradients by using commands

V_vec = VectorFunctionSpace(mesh, "CG",1)
gradu = project(grad(u),V_vec)

however, I have a doubt… when we make ‘grad(u)’, what function space does ‘grad(u)’ live in? Why is necessary to project onto space given by ‘V_vec = VectorFunctionSpace(mesh, “CG”,1)’?

Thank you…
Bhagat

That’s what the second argument says: V_vec.

If u is a scalar, is necessary the V_vec is a space of vectors. Apart from that, it’s up to you to choose "CG", 1, or any other space which you may deem appropriate.

Thank you for your reply… I meant something slightly different. If I say for example

gu = grad(u)

and I look at object ‘gu’ before calling project function, what function space does ‘gu’ live in before projection?

Also CG means continuous galerkin yes?

or said differently… what exactly is the object ‘grad(u)’?

It’s a ufl object, which does not belong to any function space.

1 Like

ok… thank you very much sir.