6#ifndef DUNE_GRID_COMMON_GRIDINFO_HH
7#define DUNE_GRID_COMMON_GRIDINFO_HH
11#include <dune/common/exceptions.hh>
12#include <dune/common/classname.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()
119 << geometry.global(Dune::ReferenceElements<ct,dim>::general(element.type()).position(0,0))
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()
194 << geometry.global(Dune::ReferenceElements<ct,dim>::general(element.type()).position(0,0))
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;
void gridinfo(const G &grid, std::string prefix="")
A function to print some information about the grid as a whole.
Definition: common/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: common/gridinfo.hh:86
void gridleaflist(const G &grid, std::string prefix)
A function to print info about a leaf grid and its entities.
Definition: common/gridinfo.hh:145
std::string PartitionName(PartitionType type)
Provide names for the partition types.
Definition: gridenums.hh:46
Grid< dim, dimworld, ct, GridFamily >::LeafGridView leafGridView(const Grid< dim, dimworld, ct, GridFamily > &grid)
leaf grid view for the given grid
Definition: common/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: common/grid.hh:802
Include standard header files.
Definition: agrid.hh:60
@ vertex
Definition: common.hh:133