Grid hierarchy and refinement¶
One of the key DUNE ideas is that grids are hierarchical. Refinement creates levels and parent/child relations between entities.
Learning goals
After this page, you should be able to:
- explain why hierarchical grids matter,
- use leaf and level grid views after refinement,
- apply global refinement,
- access parent relations for vertically connected entities.
Why it matters¶
Hierarchy is important for:
- adaptive mesh refinement (AMR),
- multilevel methods,
- prolongation/restriction between coarse and fine representations.
Leaf and level views¶
After refinement, you can inspect different views:
auto leaf = grid.leafGridView();
auto level0 = grid.levelGridView(0);
auto level1 = grid.levelGridView(1);
Typical counts:
std::cout << "leaf elements: " << leaf.size(0) << "\n";
std::cout << "level 0 elements: " << level0.size(0) << "\n";
Refining a grid¶
Global refinement is the simplest starting point:
grid.globalRefine(1); // refine once
After that, leafGridView() refers to the refined leaves.
Vertical traversal¶
This section shows how to move between child and parent entities in the hierarchy.
For grids that provide hierarchical relations, entities can be connected vertically:
for (const auto& e : elements(grid.leafGridView()))
{
if (e.hasFather())
{
auto father = e.father();
(void)father;
}
}
This is the basic mechanism behind transfer operations between refinement levels.
Next steps¶
- Use Grid Traversal for horizontal traversal patterns.
- Use Grid Integration for a practical quadrature-based task on top of traversal.
Summary and next steps¶
You now have the hierarchy model needed for multilevel workflows and transfer operations. Continue with Grid Integration to apply traversal and geometry in a practical task.