1#ifndef DUNE_SPGRID_CHECKSEITERATOR_HH
2#define DUNE_SPGRID_CHECKSEITERATOR_HH
8#include <dune/common/hybridutilities.hh>
11#include <dune/grid/common/gridview.hh>
19 struct CheckSuperEntityIterator;
26 CheckSuperEntityIterator< VT >::apply( gridView );
32 struct CheckSuperEntityIterator
40 static void apply (
const GridView &gridView );
46 static void apply (
const GridView &gridView )
50 static void apply (
const GridView &gridView )
52 Hybrid::forEach( std::make_integer_sequence< int, GridView::dimension >(), [ &gridView ] (
auto dim ) {
55 std::conditional< check, Check< codim >, NoCheck< codim > >::type::apply( gridView );
63 inline void CheckSuperEntityIterator< VT >::Check< codim >::apply (
const GridView &gridView )
66 std::cout <<
">>> Checking SuperEntityIterator for codimension "
67 << codim <<
"..." << std::endl;
69 const IndexSet &indexSet = gridView.indexSet();
70 std::vector< int > count( indexSet.size( codim ), 0 );
72 typedef typename GridView::template Codim< 0 >::Iterator ElementIterator;
74 const ElementIterator elEnd = gridView.template end< 0 >();
75 for( ElementIterator elIt = gridView.template begin< 0 >(); elIt != elEnd; ++elIt )
77 const typename ElementIterator::Entity &entity =*elIt;
78 for(
unsigned int i = 0; i < entity.subEntities( codim ); ++i )
79 ++count[ indexSet.subIndex( entity, i, codim ) ];
82 typedef typename GridView::template Codim< codim >::Iterator CodimIterator;
83 typedef typename GridView::Implementation::template Codim< codim >::SuperEntityIterator SEIterator;
85 const CodimIterator codimEnd = gridView.template end< codim >();
86 for( CodimIterator codimIt = gridView.template begin< codim >(); codimIt != codimEnd; ++codimIt )
88 const typename CodimIterator::Entity &entity = *codimIt;
91 const SEIterator seEnd = gridView.impl().superEntityEnd( entity );
92 for( SEIterator seIt = gridView.impl().superEntityBegin( entity ); seIt != seEnd; ++seIt )
94 const typename SEIterator::Entity &element = *seIt;
99 const int numSubs = element.subEntities( codim );
100 while( (k < numSubs) && (element.template subEntity< codim >( k ) != *codimIt) )
104 std::cout <<
"Entity " << indexSet.index( entity )
105 <<
"of codimension " << codim
106 <<
"is not a subentity of its super entity iterator."
109 else if( k != seIt.index() )
111 std::cout <<
"Entity " << indexSet.index( entity )
112 <<
"of codimension " << codim
113 <<
"is subEntity " << k <<
" instead of " << seIt.index() <<
"."
117 SEIterator copy = seIt;
120 std::cout <<
"Two subsequent super entity iterators should differ." << std::endl;
123 if( cnt != count[ indexSet.index( entity ) ] )
125 std::cout <<
"Number of super entities differs for entity "
126 << indexSet.index( entity )
127 <<
" of codimension " << codim
128 <<
" (" << cnt <<
" != " << count[ indexSet.index( entity ) ] <<
")."
Grid view abstract base class.
Definition: gridview.hh:66
Traits for type conversions and type information.
interface classes for superentity iterators
Traits::Grid Grid
type of the grid
Definition: gridview.hh:83
Traits::IndexSet IndexSet
type of the index set
Definition: gridview.hh:86
static constexpr int dimension
The dimension of the grid.
Definition: gridview.hh:148
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition: hybridutilities.hh:268
Dune namespace.
Definition: alignedallocator.hh:13
static const bool v
by default, a grid does not support superentity iterators
Definition: superentityiterator.hh:84