5#ifndef DUNE_GRIDINFO_HH
6#define DUNE_GRIDINFO_HH
12#include <dune/geometry/referenceelements.hh>
32 void gridinfo (
const G& grid, std::string prefix=
"")
35 const int dim = G::dimension;
36 const int dimworld = G::dimensionworld;
39 std::cout << prefix <<
"=> " <<
className(grid)
41 <<
", dimworld=" << dimworld
45 for (
int level=0; level<=grid.maxLevel(); level++)
47 std::cout << prefix <<
"level " << level;
48 for (
int cd=0; cd<=dim; cd++)
50 std::cout <<
" codim[" << cd <<
"]=" << grid.size(level,cd);
52 std::cout << std::endl;
56 std::cout << prefix <<
"leaf ";
57 for (
int cd=0; cd<=dim; cd++)
59 std::cout <<
" codim[" << cd <<
"]=" << grid.size(cd);
61 std::cout << std::endl;
63 std::cout << prefix <<
"leaf"
67 for (
int c=0; c<=dim; c++)
69 for (std::size_t i=0; i<grid.leafIndexSet().geomTypes(c).size(); i++)
71 if (!first) std::cout <<
",";
72 std::cout << grid.leafIndexSet().geomTypes(c)[i]
74 <<
"=" << grid.leafIndexSet().size(grid.leafIndexSet().geomTypes(c)[i]);
78 std::cout <<
")" << std::endl;
91 const int dim = G::dimension;
94 typedef typename G::ctype ct;
99 typedef typename G::Traits::template Codim<0>::LevelIterator
LevelIterator;
102 std::cout << prefix <<
"level=" << level
106 for (
unsigned i=0; i<grid.levelIndexSet(level).geomTypes(0).size(); i++)
108 if (!first) std::cout <<
",";
109 std::cout << grid.levelIndexSet(level).geomTypes(0)[i]
110 <<
"=" << grid.levelIndexSet(level).size(grid.levelIndexSet(level).geomTypes(0)[i]);
113 std::cout <<
")" << std::endl;
117 for (
LevelIterator it = grid.template lbegin<0>(level); it!=eendit; ++it)
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;
165 typedef typename G::Traits::template Codim<0>::LeafIterator
LeafIterator;
166 typedef typename G::Traits::template Codim<dim>::LeafIterator VLeafIterator;
169 std::cout << prefix <<
"leaf"
173 for (
int c=0; c<=dim; c++)
175 for (
unsigned i=0; i<grid.leafIndexSet().geomTypes(c).size(); i++)
177 if (!first) std::cout <<
",";
178 std::cout << grid.leafIndexSet().geomTypes(c)[i]
180 <<
"=" << grid.leafIndexSet().size(grid.leafIndexSet().geomTypes(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) <<
")"
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;
Enables iteration over all leaf entities of a codimension zero of a grid. See also the documentation ...
Definition: leafiterator.hh:32
Enables iteration over all entities of a given codimension and level of a grid. See also the document...
Definition: leveliterator.hh:31
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:32
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:88
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:14
std::string className(T &t)
Provide the demangled class name of a given object as a string.
Definition: classname.hh:23
std::string PartitionName(PartitionType type)
Provide names for the partition types.
Definition: gridenums.hh:40
Class providing access to the singletons of the reference elements. Special methods are available for...
Definition: referenceelements.hh:563