6#ifndef DUNE_GRID_COMMON_GRIDINFO_HH
7#define DUNE_GRID_COMMON_GRIDINFO_HH
13#include <dune/geometry/referenceelements.hh>
33 void gridinfo (
const G& grid, std::string prefix=
"")
36 const int dim = G::dimension;
37 const int dimworld = G::dimensionworld;
40 std::cout << prefix <<
"=> " <<
className(grid)
42 <<
", dimworld=" << dimworld
46 for (
int level=0; level<=grid.maxLevel(); level++)
48 std::cout << prefix <<
"level " << level;
49 for (
int cd=0; cd<=dim; cd++)
51 std::cout <<
" codim[" << cd <<
"]=" << grid.size(level,cd);
53 std::cout << std::endl;
57 std::cout << prefix <<
"leaf ";
58 for (
int cd=0; cd<=dim; cd++)
60 std::cout <<
" codim[" << cd <<
"]=" << grid.size(cd);
62 std::cout << std::endl;
64 std::cout << prefix <<
"leaf"
68 for (
int c=0; c<=dim; c++)
70 for (std::size_t i=0; i<grid.leafIndexSet().types(c).size(); i++)
72 if (!first) std::cout <<
",";
73 std::cout << grid.leafIndexSet().types(c)[i]
75 <<
"=" << grid.leafIndexSet().size(grid.leafIndexSet().types(c)[i]);
79 std::cout <<
")" << std::endl;
89 const int dim = G::dimension;
92 typedef typename G::ctype ct;
95 std::cout << prefix <<
"level=" << level
99 for (
unsigned i=0; i<grid.levelIndexSet(level).types(0).size(); i++)
101 if (!first) std::cout <<
",";
102 std::cout << grid.levelIndexSet(level).types(0)[i]
103 <<
"=" << grid.levelIndexSet(level).size(grid.levelIndexSet(level).types(0)[i]);
106 std::cout <<
")" << std::endl;
109 for (
const auto& element : elements(
levelGridView(grid, level)))
111 const auto& geometry = element.geometry();
112 std::cout << prefix <<
"level=" << element.level()
113 <<
" " << element.type() <<
"[" << dim <<
"]"
114 <<
" index=" << grid.levelIndexSet(level).index(element)
115 <<
" gid=" << grid.globalIdSet().template id<0>(element)
116 <<
" leaf=" << element.isLeaf()
121 <<
" first=(" << geometry.corner(0) <<
")"
124 std::cout << prefix <<
"codim " << dim <<
" subindex";
125 for (
unsigned int i=0; i < element.subEntities(dim); i++)
127 std::cout <<
" " << i <<
":" << grid.levelIndexSet(level).subIndex(element,i,dim);
129 std::cout << std::endl;
131 std::cout << prefix <<
"codim " << dim-1 <<
" subindex";
132 for (
unsigned int i=0; i < element.subEntities(dim-1); i++)
134 std::cout <<
" " << i <<
":" << grid.levelIndexSet(level).subIndex(element,i,dim-1);
136 std::cout << std::endl;
148 const int dim = G::dimension;
151 typedef typename G::ctype ct;
154 std::cout << prefix <<
"leaf"
158 for (
int c=0; c<=dim; c++)
160 for (
unsigned i=0; i<grid.leafIndexSet().types(c).size(); i++)
162 if (!first) std::cout <<
",";
163 std::cout << grid.leafIndexSet().types(c)[i]
165 <<
"=" << grid.leafIndexSet().size(grid.leafIndexSet().types(c)[i]);
169 std::cout <<
")" << std::endl;
174 std::cout << prefix <<
"level=" <<
vertex.level()
175 <<
" " <<
vertex.type() <<
"[" << dim <<
"]"
176 <<
" index=" << grid.leafIndexSet().index(
vertex)
177 <<
" gid=" << grid.globalIdSet().template id<dim>(
vertex)
179 <<
" pos=(" <<
vertex.geometry().corner(0) <<
")"
184 for (
const auto& element : elements(
leafGridView(grid)))
186 const auto& geometry = element.geometry();
187 std::cout << prefix <<
"level=" << element.level()
188 <<
" " << element.type() <<
"[" << dim <<
"]"
189 <<
" index=" << grid.leafIndexSet().index(element)
190 <<
" gid=" << grid.globalIdSet().template id<0>(element)
191 <<
" leaf=" << element.isLeaf()
196 <<
" first=(" << geometry.corner(0) <<
")"
199 std::cout << prefix <<
"codim " << dim <<
" subindex";
200 for (
unsigned int i=0; i < element.subEntities(dim); i++)
202 std::cout <<
" " << i <<
":" << grid.leafIndexSet().subIndex(element,i,dim);
204 std::cout << std::endl;
206 std::cout << prefix <<
"codim " << dim-1 <<
" subindex";
207 for (
unsigned int i=0; i < element.subEntities(dim-1); i++)
209 std::cout <<
" " << i <<
":" << grid.leafIndexSet().subIndex(element,i,dim-1);
211 std::cout << std::endl;
A free function to provide the demangled class name of a given object or type as a string.
A few common exception classes.
Grid< dim, dimworld, ct, GridFamily >::LeafGridView leafGridView(const Grid< dim, dimworld, ct, GridFamily > &grid)
leaf grid view for the given grid
Definition: grid.hh:819
Grid< dim, dimworld, ct, GridFamily >::LevelGridView levelGridView(const Grid< dim, dimworld, ct, GridFamily > &grid, int level)
level grid view for the given grid and level.
Definition: grid.hh:802
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:506
void gridinfo(const G &grid, std::string prefix="")
A function to print some information about the grid as a whole.
Definition: gridinfo.hh:33
void gridlevellist(const G &grid, int level, std::string prefix)
A function to print info about a grid level and its entities.
Definition: gridinfo.hh:86
void gridleaflist(const G &grid, std::string prefix)
A function to print info about a leaf grid and its entities.
Definition: gridinfo.hh:145
Dune namespace.
Definition: alignedallocator.hh:13
std::string className()
Provide the demangled class name of a type T as a string.
Definition: classname.hh:47
Class providing access to the singletons of the reference elements.
Definition: referenceelements.hh:170