# Adaptive mesh refinement with inter-element continuity

I am searching for a library that can perform adaptive mesh refinement (AMR) on large distributed unstructured meshes. For now, the cells are high-order quads/hexa. I was looking into p4est, which is well-maintained and scales well.

I am completely new to AMR, but as far I understood, the forest in p4est consists of one tree for each original cell in the mesh. The problem is that after refinement, the neighbouring subcells of the neighbouring trees will have independent/duplicate nodes, resulting in a non-conforming mesh, as I can check them in the VTK output (p4est_vtk_write_file). For post-processing purposes, I need a connected mesh (on a given partition). How can I achieve this? I added the tag to this question because I know that deal.ii uses p4est behind the scenes.

• What's the reason why you can't deal with hanging nodes after computing a solution? Sep 19 at 4:23
• I will note that p4est is a fantastic mesh data structure, but it is not a discretization library. You will be better off using something that builds on p4est. Sep 19 at 4:24

It's been a while since I've used deal.II so this is my recollection. If Wolfgang Bangerth or one of the other developers says otherwise you should listen to them.

What deal.II does is add continuity constraints to hanging nodes of the (non-conforming) mesh at the linear-algebraic level. So rather than solve a linear system involving the usual stiffness matrix for, say, the Poisson equation, some of the rows of that matrix are modified after assembly in order to ensure that the hanging nodes linearly interpolate the values on either side. There's a nice figure illustrating this in the deal.II documentation. It can be difficult to ensure that adding these constraints doesn't destroy the conditioning of the linear system, so I think there's a bit of re-scaling that happens as well. The naive thing would be to make one equation equal to $$u_i - (1 - \alpha)u_j - \alpha u_k = 0$$ where $$u_i$$ is the hanging node, $$u_j$$, $$u_k$$ are its neighbors, and $$\alpha$$ is the fractional distance of $$u_i$$ between $$u_j$$ and $$u_k$$. Instead, they scale this equation by whatever was in the diagonal of the matrix originally.

Anecdotally, I remember Wolfgang saying once that the hanging node constraint enforcement in deal.II was the hardest part to write and that it makes up a significant fraction of the overall lines of code of the library. This was a few years ago so maybe that's changed.

If you really do need a conforming mesh, then p4est might not do what you need out of the box. There probably are ways to turn a mesh with hanging nodes into a conforming one by local topological transformations, at least in 2D. If you just need fields to be continuous and don't actually have hard requirements on the mesh topology, then you might be able to work together something along the lines of what deal.II does. Judging by how much effort went into what deal.II does for hanging nodes, that might be a lot of work.

• Thank you, this reassures me that deal.ii handles the conformity at the algebraic level, i.e. enforcing the conformity on a non-conforming mesh. Unfortunately, I must use black-box post-processing tools, which assume a conforming mesh. Sep 18 at 8:24
• Do you know other software that converts a p4est output to a conforming mesh? Sep 18 at 8:38
• No sorry :/ you could try the deal.II mailing list? Does the result need to be all quads? If you're cool with some triangles then you can do it naively. Sep 18 at 15:46
• Quad/hex dominant is desirable, but not essential. Yes, I could split them by myself, but I am sure that would be suboptimal as I am not an expert. Sep 18 at 22:04
• It is not practically feasible to use adaptive mesh refinement on quad/hex meshes without hanging nodes. (Because it is not practically feasible to have transition elements that capture the hanging nodes into a conforming mesh, in the same way as one can do with red/green refinement for triangles.) Nor is there a good reason: There is nothing wrong with hanging nodes :-) Sep 19 at 4:21