Grid info utilities¶
dune-grid provides helper utilities to print structural information about a grid.
Learning goals
After this page, you should be able to:
- use
Dune::gridinfoto inspect a grid quickly, - interpret basic level and codimension statistics,
- connect
gridinfooutput to debugging and verification tasks.
Dune::gridinfo¶
A convenient entry point is:
#include <dune/grid/common/gridinfo.hh>
Dune::gridinfo(grid, "MyGrid");
This prints information such as:
- dimension and world dimension,
- numbers of entities by codimension,
- level and leaf statistics,
- selected geometry/index set details.
It is especially useful when:
- debugging mesh import,
- comparing refinement stages,
- verifying assumptions before assembly.
Typical workflow¶
Use it right after grid construction or file input:
auto grid = Dune::GmshReader<Grid>::read("mesh.msh");
Dune::gridinfo(*grid, "ImportedMesh");
Runnable example: examples/04_grid_info/grid_info.cc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
Build and run:
source _env/activate.sh
cd examples/04_grid_info
dunecontrol --current all
./build/debug/example04
Output:
level 0 elements: 12
leaf elements after refine: 48
YaspGrid Example=> Dune::YaspGrid<2, Dune::EquidistantCoordinates<double, 2> > const (dim=2, dimworld=2)
YaspGrid Examplelevel 0 codim[0]=12 codim[1]=31 codim[2]=20
YaspGrid Examplelevel 1 codim[0]=48 codim[1]=110 codim[2]=63
YaspGrid Exampleleaf codim[0]=48 codim[1]=110 codim[2]=63
YaspGrid Exampleleaf dim=2 types=((cube, 2)[0]=48,(simplex, 1)[1]=110,(simplex, 0)[2]=63)
Related utilities¶
printGridin grid I/O for topology/index visualization output.- Attaching data to grid entities for
indexSet/mapper based storage patterns. - direct
gv.size(codim)checks when you only need quick counts.
Summary and next steps¶
You now have a lightweight diagnostic tool to verify grid structure and refinement state. For the broader context, return to Core modules or continue with Grid basics.