1#ifndef DUNE_SPGRID_CHECKBNDSEGITERATOR_HH
2#define DUNE_SPGRID_CHECKBNDSEGITERATOR_HH
11#include <dune/common/array.hh>
15#include <dune/grid/common/exceptions.hh>
16#include <dune/grid/common/gridview.hh>
29 typedef typename Intersection::EntityPointer EntityPointer;
30 typedef typename EntityPointer::Entity Entity;
33 typedef typename GridView::Implementation::BoundarySegmentIterator BoundarySegmentIterator;
37 const IndexSet &indexSet = gridView.
indexSet();
41 typedef Dune::array< int, numFaces > Data;
42 std::vector< Data > boundaryFace( indexSet.size( 0 ) );
43 for(
typename std::vector< Data >::iterator vit = boundaryFace.begin(); vit != boundaryFace.end(); ++vit )
47 int bndIntersections = 0;
48 typedef typename GridView::template Codim< 0 >::Iterator Iterator;
49 const Iterator end = gridView.template end< 0 >();
50 for( Iterator it = gridView.template begin< 0 >(); it != end; ++it )
53 const Entity &entity = *it;
54 if( !entity.hasBoundaryIntersections() )
59 const IntersectionIterator iend = gridView.
iend( entity );
60 for( IntersectionIterator iit = gridView.
ibegin( entity ); iit != iend; ++iit )
62 const Intersection &intersection = *iit;
63 if( intersection.boundary() )
65 boundaryFace[ index ][ intersection.indexInInside() ] = 1;
70 std::cerr <<
"Found " << bndIntersections <<
" boundary intersections" << std::endl;
74 const BoundarySegmentIterator bend = gridView.
impl().boundarySegmentEnd();
75 for( BoundarySegmentIterator bit = gridView.
impl().boundarySegmentBegin(); bit != bend; ++bit )
78 const Intersection &boundarySegment = *bit;
82 if( !boundarySegment.boundary() )
83 DUNE_THROW( GridError,
"Boundary segment not on boundary" );
86 const int indexInInside = boundarySegment.indexInInside();
89 EntityPointer insidePtr = boundarySegment.inside();
90 const Entity &inside = *insidePtr;
93 const IntersectionIterator iend = gridView.
iend( inside );
94 for( IntersectionIterator iit = gridView.
ibegin( inside ); iit != iend; ++iit )
96 const Intersection &intersection = *iit;
99 if( intersection.impl().equals( boundarySegment.impl() ) != boundarySegment.impl().equals( intersection.impl() ) )
100 DUNE_THROW( GridError,
"Comparison of intersection and boundary segment failed" );
103 if( intersection.impl().equals( boundarySegment.impl() ) )
106 if( intersection.indexInInside() != indexInInside )
107 DUNE_THROW( GridError,
"Index in inside of boundary segment and intersection in inside entity do not conincide" );
110 if( (boundaryFace[ indexSet.index( inside ) ][ indexInInside ] -= 1) < 0 )
111 DUNE_THROW( GridError,
"Boundary segment found twice in inside entity" );
115 std::cerr <<
"Found " << bndSegments <<
" boundary segments" << std::endl;
118 for(
typename std::vector< Data >::iterator vit = boundaryFace.begin(); vit != boundaryFace.end(); ++vit )
120 for(
size_t face = 0; face < vit->size(); ++face )
121 if( (*vit)[ face ] != 0 )
122 DUNE_THROW( GridError,
"Not all boundary intersections were found" );
Grid view abstract base class.
Definition: gridview.hh:66
IndexTypeImp IndexType
The type used for the indices.
Definition: indexidset.hh:92
Dune::Intersection< GridImp, IntersectionImp > Intersection
Type of Intersection this IntersectionIterator points to.
Definition: intersectioniterator.hh:111
A few common exception classes.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
const IndexSet & indexSet() const
obtain the index set
Definition: gridview.hh:191
Implementation & impl()
access to the underlying implementation
Definition: gridview.hh:313
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: gridview.hh:92
IntersectionIterator ibegin(const typename Codim< 0 > ::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: gridview.hh:267
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
IntersectionIterator iend(const typename Codim< 0 > ::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: gridview.hh:274
Dune namespace.
Definition: alignedallocator.hh:13