- Thank you received: 1
Find L2 projection of a given function in ngsolve
4 years 5 months ago - 4 years 5 months ago #2893
by dong
Find L2 projection of a given function in ngsolve was created by dong
I'm finding L2 projection of a given function f on a finite element space Q.
Is there any function in Ngsolve do this job as in Fenics?
I also tried to write a find to find the L2-projection using its definition, but I met an error when finding the inverse matrix.
Could you please tell me how to fix this? Please see the attached file.
Thank you so much.
Is there any function in Ngsolve do this job as in Fenics?
I also tried to write a find to find the L2-projection using its definition, but I met an error when finding the inverse matrix.
Could you please tell me how to fix this? Please see the attached file.
Thank you so much.
Attachments:
Last edit: 4 years 5 months ago by dong.
4 years 5 months ago #2894
by joachim
Replied by joachim on topic Find L2 projection of a given function in ngsolve
You have to do it following its definition. You are building some sub-block in a huge matrix, and the solver is telling you correctly that the big matrix is not invertible
Build and invert the matrix on a single space, then you can embed the single-space vectors in your product-space,
Joachim
Build and invert the matrix on a single space, then you can embed the single-space vectors in your product-space,
Joachim
4 years 5 months ago #2895
by dong
Replied by dong on topic Find L2 projection of a given function in ngsolve
Thank you so much. Could you please show me how to embed a single-space vectors in a product space?
I searched a tutorial from ngsolve documentation, but I couldn't find an example.
I searched a tutorial from ngsolve documentation, but I couldn't find an example.
4 years 5 months ago #2896
by joachim
Replied by joachim on topic Find L2 projection of a given function in ngsolve
You can use an embedding matrix:
This embeds a vector of length b-a into a vector of length n, starting at index a.
some use-cases you can find here:
github.com/NGSolve/modeltemplates/blob/m...ates/NavierStokes.py
Joachim
Code:
r = IntRange (a,b)
emb = Embedding(n, r)
some use-cases you can find here:
github.com/NGSolve/modeltemplates/blob/m...ates/NavierStokes.py
Joachim
The following user(s) said Thank You: dong
4 years 4 months ago #2903
by dong
Replied by dong on topic Find L2 projection of a given function in ngsolve
Thank you so much for your clarification. I think ngsolve will be more user-friendly if it has an L2-projection built-in function.
Time to create page: 0.109 seconds