4#ifndef DUNE_GRIDINFO_HH
5#define DUNE_GRIDINFO_HH
11#include <dune/geometry/referenceelements.hh>
31 void gridinfo (
const G& grid, std::string prefix=
"")
34 const int dim = G::dimension;
35 const int dimworld = G::dimensionworld;
38 std::cout << prefix <<
"=> " <<
className(grid)
40 <<
", dimworld=" << dimworld
44 for (
int level=0; level<=grid.maxLevel(); level++)
46 std::cout << prefix <<
"level " << level;
47 for (
int cd=0; cd<=dim; cd++)
49 std::cout <<
" codim[" << cd <<
"]=" << grid.size(level,cd);
51 std::cout << std::endl;
55 std::cout << prefix <<
"leaf ";
56 for (
int cd=0; cd<=dim; cd++)
58 std::cout <<
" codim[" << cd <<
"]=" << grid.size(cd);
60 std::cout << std::endl;
62 std::cout << prefix <<
"leaf"
66 for (
int c=0; c<=dim; c++)
68 for (std::size_t i=0; i<grid.leafIndexSet().types(c).size(); i++)
70 if (!first) std::cout <<
",";
71 std::cout << grid.leafIndexSet().types(c)[i]
73 <<
"=" << grid.leafIndexSet().size(grid.leafIndexSet().types(c)[i]);
77 std::cout <<
")" << std::endl;
90 const int dim = G::dimension;
93 typedef typename G::ctype ct;
101 std::cout << prefix <<
"level=" << level
105 for (
unsigned i=0; i<grid.levelIndexSet(level).types(0).size(); i++)
107 if (!first) std::cout <<
",";
108 std::cout << grid.levelIndexSet(level).types(0)[i]
109 <<
"=" << grid.levelIndexSet(level).size(grid.levelIndexSet(level).types(0)[i]);
112 std::cout <<
")" << std::endl;
115 LevelIterator eendit = grid.levelGridView(level).template end<0>();
116 for (LevelIterator it = grid.levelGridView(level).template begin<0>();
119 std::cout << prefix <<
"level=" << it->level()
120 <<
" " << it->type() <<
"[" << dim <<
"]"
121 <<
" index=" << grid.levelIndexSet(level).index(*it)
122 <<
" gid=" << grid.globalIdSet().template id<0>(*it)
123 <<
" leaf=" << it->isLeaf()
128 <<
" first=(" << it->geometry().corner(0) <<
")"
131 std::cout << prefix <<
"codim " << dim <<
" subindex";
132 for (
int i=0; i<it->template count<dim>(); i++)
134 std::cout <<
" " << i <<
":" << grid.levelIndexSet(level).subIndex(*it,i,dim);
136 std::cout << std::endl;
138 std::cout << prefix <<
"codim " << dim-1 <<
" subindex";
139 for (
int i=0; i<it->template count<dim-1>(); i++)
141 std::cout <<
" " << i <<
":" << grid.levelIndexSet(level).subIndex(*it,i,dim-1);
143 std::cout << std::endl;
157 const int dim = G::dimension;
160 typedef typename G::ctype ct;
169 std::cout << prefix <<
"leaf"
173 for (
int c=0; c<=dim; c++)
175 for (
unsigned i=0; i<grid.leafIndexSet().types(c).size(); i++)
177 if (!first) std::cout <<
",";
178 std::cout << grid.leafIndexSet().types(c)[i]
180 <<
"=" << grid.leafIndexSet().size(grid.leafIndexSet().types(c)[i]);
184 std::cout <<
")" << std::endl;
187 VLeafIterator veendit = grid.template leafend<dim>();
188 for (VLeafIterator it = grid.template leafbegin<dim>(); it!=veendit; ++it)
190 std::cout << prefix <<
"level=" << it->level()
191 <<
" " << it->type() <<
"[" << dim <<
"]"
192 <<
" index=" << grid.leafIndexSet().index(*it)
193 <<
" gid=" << grid.globalIdSet().template id<dim>(*it)
195 <<
" pos=(" << it->geometry().corner(0) <<
")"
200 LeafIterator eendit = grid.template leafend<0>();
201 for (LeafIterator it = grid.template leafbegin<0>(); it!=eendit; ++it)
203 std::cout << prefix <<
"level=" << it->level()
204 <<
" " << it->type() <<
"[" << dim <<
"]"
205 <<
" index=" << grid.leafIndexSet().index(*it)
206 <<
" gid=" << grid.globalIdSet().template id<0>(*it)
207 <<
" leaf=" << it->isLeaf()
212 <<
" first=(" << it->geometry().corner(0) <<
")"
215 std::cout << prefix <<
"codim " << dim <<
" subindex";
216 for (
int i=0; i<it->template count<dim>(); i++)
218 std::cout <<
" " << i <<
":" << grid.leafIndexSet().subIndex(*it,i,dim);
220 std::cout << std::endl;
222 std::cout << prefix <<
"codim " << dim-1 <<
" subindex";
223 for (
int i=0; i<it->template count<dim-1>(); i++)
225 std::cout <<
" " << i <<
":" << grid.leafIndexSet().subIndex(*it,i,dim-1);
227 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.
void gridinfo(const G &grid, std::string prefix="")
A function to print some information about the grid as a whole.
Definition: gridinfo.hh:31
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:87
void gridleaflist(const G &grid, std::string prefix)
A function to print info about a leaf grid and its entities.
Definition: gridinfo.hh:154
Dune namespace.
Definition: alignment.hh:11
std::string className()
Provide the demangled class name of a type T as a string.
Definition: classname.hh:23
Static tag representing a codimension.
Definition: dimension.hh:22
Class providing access to the singletons of the reference elements.
Definition: referenceelements.hh:752