4#ifndef DUNE_GRID_UTILITY_GRIDINFO_HH
5#define DUNE_GRID_UTILITY_GRIDINFO_HH
21#include <dune/geometry/referenceelements.hh>
23#include <dune/geometry/multilineargeometry.hh>
76 public std::binary_function<GeometryType, GeometryType, bool>
81 return a.
dim() < b.
dim() ||
97 public std::map<GeometryType, EntityInfo<ctype>, GridViewInfoGTCompare>
124 void print(std::ostream &stream, std::string prefix)
const {
126 stream << prefix <<
gridName <<
":\n";
138 typedef typename GridViewInfo::const_iterator Iterator;
139 std::size_t dim = ~0;
140 const Iterator &end = this->end();
141 for(Iterator it = this->begin(); it != end; ++it) {
142 if(it->first.dim() != dim) {
143 dim = it->first.dim();
144 stream << prefix <<
"Dim = " << dim <<
":\n";
146 stream << prefix <<
" " << it->first <<
": Count = "
147 << it->second.count <<
", Volume range = "
148 <<
"(" << it->second.volumeMin <<
".."
149 << it->second.volumeMax <<
"), Total volume = "
150 << it->second.volumeSum <<
"\n";
161 template<
class ctype>
165 info.
print(stream,
"");
172 struct FillGridInfoOperation {
173 template<
class Entity,
class Mapper,
class Visited,
class RefElem>
174 static void apply(
const Entity &e,
const Mapper &mapper, Visited &visited,
176 const RefElem &refelem,
179 typedef typename Entity::Geometry::ctype ctype;
180 static const std::size_t dimw = Entity::Geometry::coorddimension;
182 std::vector<FieldVector<ctype, dimw> > coords;
183 for(
int i = 0; i < refelem.size(codim); ++i) {
184 int index = mapper.map(e, i, codim);
187 visited[index] =
true;
191 coords.resize( refelem.size(i, codim, dim) );
192 for(std::size_t corner = 0; corner < coords.size(); ++corner)
193 coords[ corner ] = geo.corner( refelem.subEntity( i, codim, corner, dim ) );
196 ctype volume = mygeo.
volume();
205 template<
int dimgr
id>
206 struct MCMGNonElementLayout {
207 bool contains(GeometryType
gt)
const {
return gt.dim() < dimgrid; }
220 typedef typename GV::ctype ctype;
221 static const std::size_t dim = GV::dimension;
224 typedef typename GV::IndexSet
IndexSet;
231 std::vector<bool> visited(mapper.size(),
false);
233 gridViewInfo.
gridName = className<typename GV::Grid>();
236 gridViewInfo.clear();
238 const EIterator &eend = gv.template end<0>();
239 for(EIterator eit = gv.template begin<0>(); eit != eend; ++eit) {
240 ctype volume = eit->geometry().volume();
246 if(!eit->type().isNone()) {
247 const EGeometry &geo = eit->geometry();
249 apply(*eit, mapper, visited, geo, RefElems::general(eit->type()),
256 if(gridViewInfo.count(
gt) > 0) {
257 for(std::size_t codim = 0; codim < dim; ++codim) {
258 gt.makeNone(dim-codim);
261 std::numeric_limits<ctype>::quiet_NaN();
268 const InfoIterator &end = gridViewInfo.end();
270 for(InfoIterator it = gridViewInfo.begin(); it != end; ++it) {
271 it->second.count = is.size(it->first);
272 if(it->second.count == 0)
274 it->first <<
" while iterating through the grid, but "
275 "indexSet.size() == 0 for that geometry type");
Wrapper class for entities.
Definition: entity.hh:62
GridImp::template Codim< cd >::Geometry Geometry
The corresponding geometry type.
Definition: entity.hh:97
@ dimension
Know the grid dimension.
Definition: entity.hh:108
Base class for Dune-Exceptions.
Definition: exceptions.hh:91
A static loop using TMP.
Definition: forloop.hh:110
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
unsigned int dim() const
Return dimension of the type.
Definition: type.hh:321
bool isNone() const
Return true if entity is a singular of any dimension.
Definition: type.hh:316
unsigned int id() const
Return the topology id the type.
Definition: type.hh:326
Index Set Interface base class.
Definition: indexidset.hh:76
Mapper interface.
Definition: mapper.hh:108
generic geometry implementation based on corner coordinates
Definition: multilineargeometry.hh:148
ctype volume() const
obtain the volume of the mapping's image
Definition: multilineargeometry.hh:310
Implementation class for a multiple codim and multiple geometry type mapper.
Definition: mcmgmapper.hh:104
A free function to provide the demangled class name of a given object or type as a string.
A few common exception classes.
A static for loop for template meta-programming.
Implements a vector constructed from a given type representing a field and a compile-time given size.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:243
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:132
Mapper for multiple codim and multiple geometry types.
Dune namespace.
Definition: alignment.hh:10
void fillGridViewInfoSerial(const GV &gv, GridViewInfo< typename GV::ctype > &gridViewInfo)
fill a GridViewInfo structure from a serial grid
Definition: gridinfo.hh:217
Static tag representing a codimension.
Definition: dimension.hh:22
Structure to hold statistical information about one type of entity.
Definition: gridinfo.hh:31
ctype volumeMin
minimum volume of all entities in the set.
Definition: gridinfo.hh:40
ctype volumeMax
maximum volume of all entities in the set.
Definition: gridinfo.hh:47
ctype volumeSum
sum of volumes of all entities in the set.
Definition: gridinfo.hh:54
std::size_t count
number of entities in the set
Definition: gridinfo.hh:33
EntityInfo()
initialize the structure
Definition: gridinfo.hh:62
Comparison object to sort GeometryType by majorly dimension.
Definition: gridinfo.hh:77
bool operator()(const GeometryType &a, const GeometryType &b) const
compare two GeometryTypes
Definition: gridinfo.hh:79
structure to hold information about a certain GridView.
Definition: gridinfo.hh:98
std::ostream & operator<<(std::ostream &stream, const GridViewInfo< ctype > &info)
write a GridViewInfo object
Definition: gridinfo.hh:162
std::string gridViewName
name of the class of the GridView this information was extracted from
Definition: gridinfo.hh:102
std::string partitionName
name of the partition this information was extracted from
Definition: gridinfo.hh:108
std::string gridName
name of the grid class this information was extracted from
Definition: gridinfo.hh:100
void print(std::ostream &stream, std::string prefix) const
print the information contained in this object
Definition: gridinfo.hh:124
Class providing access to the singletons of the reference elements.
Definition: referenceelements.hh:479
A unique label for each type of element that can occur in a grid.