6 #ifndef DUNE_GRID_UTILITY_GRIDINFO_HH 7 #define DUNE_GRID_UTILITY_GRIDINFO_HH 18 #include <dune/common/classname.hh> 19 #include <dune/common/exceptions.hh> 20 #include <dune/common/fvector.hh> 21 #include <dune/common/hybridutilities.hh> 23 #include <dune/geometry/multilineargeometry.hh> 24 #include <dune/geometry/referenceelements.hh> 25 #include <dune/geometry/type.hh> 78 public std::binary_function<GeometryType, GeometryType, bool>
83 return a.dim() < b.dim() ||
84 (a.dim() == b.dim() && (a.isNone() < b.isNone() ||
85 (a.isNone() == b.isNone() && (a.id() >> 1) < (b.id() >> 1))));
99 public std::map<GeometryType, EntityInfo<ctype>, GridViewInfoGTCompare>
126 void print(std::ostream &stream, std::string prefix)
const {
128 stream << prefix <<
gridName <<
":\n";
140 typedef typename GridViewInfo::const_iterator Iterator;
141 std::size_t dim = ~0;
142 const Iterator &end = this->end();
143 for(Iterator it = this->begin(); it != end; ++it) {
144 if(it->first.dim() != dim) {
145 dim = it->first.dim();
146 stream << prefix <<
"Dim = " << dim <<
":\n";
148 stream << prefix <<
" " << it->first <<
": Count = " 149 << it->second.count <<
", Volume range = " 150 <<
"(" << it->second.volumeMin <<
".." 151 << it->second.volumeMax <<
"), Total volume = " 152 << it->second.volumeSum <<
"\n";
163 template<
class ctype>
167 info.
print(stream,
"");
174 struct FillGridInfoOperation {
175 template<
class Entity,
class Mapper,
class Visited,
class RefElem>
176 static void apply(
const Entity &e,
const Mapper &mapper, Visited &visited,
181 typedef typename Entity::Geometry::ctype ctype;
182 static const std::size_t dimw = Entity::Geometry::coorddimension;
184 std::vector<FieldVector<ctype, dimw> > coords;
185 for(
int i = 0; i < refelem.size(codim); ++i) {
186 int index = mapper.map(e, i, codim);
189 visited[index] =
true;
193 coords.resize( refelem.size(i, codim, dim) );
194 for(std::size_t corner = 0; corner < coords.size(); ++corner)
195 coords[ corner ] = geo.corner( refelem.subEntity( i, codim, corner, dim ) );
196 MultiLinearGeometry<ctype, dim-codim, dimw> mygeo(gt, coords);
198 ctype volume = mygeo.volume();
217 typedef typename GV::ctype ctype;
218 static const std::size_t dim = GV::dimension;
219 typedef typename GV::template Codim<0>::Iterator EIterator;
225 typedef ReferenceElements<ctype, dim> RefElems;
229 [](
GeometryType gt,
int) {
return gt.dim() < GV::dimension; }
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();
248 Hybrid::forEach(std::make_index_sequence< dim >{},
249 [ & ](
auto i){ FillGridInfoOperation< i+1 >::apply(*eit, mapper, visited, geo, RefElems::general(eit->type()), gridViewInfo); } );
254 if(gridViewInfo.count(gt) > 0) {
255 for(std::size_t codim = 0; codim < dim; ++codim)
257 gt = GeometryTypes::none(dim-codim);
260 std::numeric_limits<ctype>::quiet_NaN();
262 gt = GeometryTypes::none(0);
267 const InfoIterator &end = gridViewInfo.end();
269 for(InfoIterator it = gridViewInfo.begin(); it != end; ++it) {
270 it->second.count = is.
size(it->first);
271 if(it->second.count == 0)
272 DUNE_THROW(Exception,
"Found Entities of geomentry type " <<
273 it->first <<
" while iterating through the grid, but " 274 "indexSet.size() == 0 for that geometry type");
282 #endif // DUNE_GRID_UTILITY_GRIDINFO_HH int max(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:337
std::string gridName
name of the grid class this information was extracted from
Definition: utility/gridinfo.hh:102
auto size(GeometryType type) const
Return total number of entities of given geometry type in entity set .
Definition: common/indexidset.hh:223
Mapper for multiple codim and multiple geometry types.
Index Set Interface base class.
Definition: common/grid.hh:348
static constexpr int dimension
Know the grid dimension.
Definition: common/entity.hh:109
ctype volumeMax
maximum volume of all entities in the set.
Definition: utility/gridinfo.hh:49
std::string gridViewName
name of the class of the GridView this information was extracted from
Definition: utility/gridinfo.hh:104
GridImp::template Codim< cd >::Geometry Geometry
The corresponding geometry type.
Definition: common/entity.hh:100
concept Geometry
Model of a geometry object.
Definition: concepts/geometry.hh:29
Comparison object to sort GeometryType by majorly dimension.
Definition: utility/gridinfo.hh:77
void fillGridViewInfoSerial(const GV &gv, GridViewInfo< typename GV::ctype > &gridViewInfo)
fill a GridViewInfo structure from a serial grid
Definition: utility/gridinfo.hh:214
bool operator()(const GeometryType &a, const GeometryType &b) const
compare two GeometryTypes
Definition: utility/gridinfo.hh:81
ctype volumeSum
sum of volumes of all entities in the set.
Definition: utility/gridinfo.hh:56
Include standard header files.
Definition: agrid.hh:59
Structure to hold statistical information about one type of entity.
Definition: utility/gridinfo.hh:33
auto size() const
Return total number of entities in the entity set managed by the mapper.
Definition: mapper.hh:152
std::size_t count
number of entities in the set
Definition: utility/gridinfo.hh:35
Implementation class for a multiple codim and multiple geometry type mapper.
Definition: mcmgmapper.hh:127
structure to hold information about a certain GridView.
Definition: utility/gridinfo.hh:98
std::string partitionName
name of the partition this information was extracted from
Definition: utility/gridinfo.hh:110
Wrapper class for entities.
Definition: common/entity.hh:65
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
EntityInfo()
initialize the structure
Definition: utility/gridinfo.hh:64
std::ostream & operator<<(std::ostream &stream, const GridViewInfo< ctype > &info)
write a GridViewInfo object
Definition: utility/gridinfo.hh:164
int min(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:348
ctype volumeMin
minimum volume of all entities in the set.
Definition: utility/gridinfo.hh:42
concept IndexSet
Model of an index set.
Definition: concepts/indexidset.hh:55
void print(std::ostream &stream, std::string prefix) const
print the information contained in this object
Definition: utility/gridinfo.hh:126
Mapper interface.
Definition: mapper.hh:109