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;
87 const int dim = G::dimension;
90 typedef typename G::ctype ct;
93 std::cout << prefix <<
"level=" << level
97 for (
unsigned i=0; i<grid.levelIndexSet(level).types(0).size(); i++)
99 if (!first) std::cout <<
",";
100 std::cout << grid.levelIndexSet(level).types(0)[i]
101 <<
"=" << grid.levelIndexSet(level).size(grid.levelIndexSet(level).types(0)[i]);
104 std::cout <<
")" << std::endl;
107 for (
const auto& element : elements(
levelGridView(grid, level)))
109 const auto& geometry = element.geometry();
110 std::cout << prefix <<
"level=" << element.level()
111 <<
" " << element.type() <<
"[" << dim <<
"]"
112 <<
" index=" << grid.levelIndexSet(level).index(element)
113 <<
" gid=" << grid.globalIdSet().template id<0>(element)
114 <<
" leaf=" << element.isLeaf()
119 <<
" first=(" << geometry.corner(0) <<
")"
122 std::cout << prefix <<
"codim " << dim <<
" subindex";
123 for (
unsigned int i=0; i < element.subEntities(dim); i++)
125 std::cout <<
" " << i <<
":" << grid.levelIndexSet(level).subIndex(element,i,dim);
127 std::cout << std::endl;
129 std::cout << prefix <<
"codim " << dim-1 <<
" subindex";
130 for (
unsigned int i=0; i < element.subEntities(dim-1); i++)
132 std::cout <<
" " << i <<
":" << grid.levelIndexSet(level).subIndex(element,i,dim-1);
134 std::cout << std::endl;
146 const int dim = G::dimension;
149 typedef typename G::ctype ct;
152 std::cout << prefix <<
"leaf"
156 for (
int c=0; c<=dim; c++)
158 for (
unsigned i=0; i<grid.leafIndexSet().types(c).size(); i++)
160 if (!first) std::cout <<
",";
161 std::cout << grid.leafIndexSet().types(c)[i]
163 <<
"=" << grid.leafIndexSet().size(grid.leafIndexSet().types(c)[i]);
167 std::cout <<
")" << std::endl;
172 std::cout << prefix <<
"level=" <<
vertex.level()
173 <<
" " <<
vertex.type() <<
"[" << dim <<
"]"
174 <<
" index=" << grid.leafIndexSet().index(
vertex)
175 <<
" gid=" << grid.globalIdSet().template id<dim>(
vertex)
177 <<
" pos=(" <<
vertex.geometry().corner(0) <<
")"
182 for (
const auto& element : elements(
leafGridView(grid)))
184 const auto& geometry = element.geometry();
185 std::cout << prefix <<
"level=" << element.level()
186 <<
" " << element.type() <<
"[" << dim <<
"]"
187 <<
" index=" << grid.leafIndexSet().index(element)
188 <<
" gid=" << grid.globalIdSet().template id<0>(element)
189 <<
" leaf=" << element.isLeaf()
194 <<
" first=(" << geometry.corner(0) <<
")"
197 std::cout << prefix <<
"codim " << dim <<
" subindex";
198 for (
unsigned int i=0; i < element.subEntities(dim); i++)
200 std::cout <<
" " << i <<
":" << grid.leafIndexSet().subIndex(element,i,dim);
202 std::cout << std::endl;
204 std::cout << prefix <<
"codim " << dim-1 <<
" subindex";
205 for (
unsigned int i=0; i < element.subEntities(dim-1); i++)
207 std::cout <<
" " << i <<
":" << grid.leafIndexSet().subIndex(element,i,dim-1);
209 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:809
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:792
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:797
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:84
void gridleaflist(const G &grid, std::string prefix)
A function to print info about a leaf grid and its entities.
Definition: gridinfo.hh:143
Dune namespace.
Definition: alignedallocator.hh:14
std::string className()
Provide the demangled class name of a type T as a string.
Definition: classname.hh:44
Class providing access to the singletons of the reference elements.
Definition: referenceelements.hh:168