When I use adaptive mesh refinement in NGSolve and obtain a refined mesh, is it possible to access an interpolation/update operator such that the following transformation can be computed.
Let u[sub]H[/sub] be a solution on the coarse grid and u[sub]h[/sub] be the equivalent interpolated field on the hierarchically refined grid. u[sub]h[/sub] is obtained by interpolating the values of u[sub]H[/sub] on the finer grid:
This is useful to compute error norms of the coarse-grid solution on the refined grid and to compare these to norms of the solution on the refined grid . Is there a way to access this operator P?
maybe the attached file, where a MultiGrid preconditioner is build with coarse grid correction can help you.
Especially these lines:
prol = space.Prolongation()
Thank you for pointing me to the relevant operator. I’ll try this and get back to you if I have more questions.
I’m following up on my earlier question here. Is it possible to use the Prolongation/Restriction operator outside of the multigrid preconditioner environment?
For example, consider the Poisson example in the NGSolve documentation. Once I obtain the solution at some discretization level can I refine the mesh and use the prolongation operator to interpolate the coarse grid solution on the refined mesh? Can you please give an example of how this can be done?
you can use the Prolongation here as well, see the attached example.
But, you have to do some data copying.
As an alternative, you define
gfu = GridFunction(fes, nested=True)
then the prolongation is done within GridFunction.Update()
The prolongation must be provided by the FESpace, not all have it implemented.
E.g. some high order spaces use just the prolongation of the low order space…
Thank you for the detailed example with the comments. This is very helpful!
The prolongation works as expected for linear H1 spaces. If I use a higher-order H1 space, the error norm of the interpolated field on the refined grid is much larger - probably because the prolongation uses linear H1 space - as you mentioned.
However, prolongation does not seem to work on HDiv spaces. The field quantity on the refined grid is just zero in the whole domain. Is prolongation not implemented for HDiv?
yes, HDiv is missing. I have two recommendations:
If you are in 2D, you can use HCurl instead of HDiv, rotate your field by 90 deg, and replace div by curl. For lowest order HCurl we have the prolongation. This is a pure Python solution.
Copy the C++ code from HCurlSpace to HDivFESpace. Also prolongations for lowest order RT tetrahedral elements can be done similarly. Have a look into
ngsolve/multigrid/prolongation.hpp, line 183, class EdgeProlongation
comp/hcurlhdivfes.cpp, line 140 for building the edge hierarchy
We only assume from the mesh interface that it provides the hierarchy of vertices and elements, no edges or faces, this is more troublesome for p-version prolongations.
I have heard from people who have added at least second order H1 prolongations.
Thank you for your clarifications and your pointers on code modifications.
I’m working on problems in 3D domains and so will have to look into option 2 from your recommendations.
I’ll write back to you when I have more questions in this regard.