Dune Core Modules (2.9.0)

checktree.hh
1#ifndef DUNE_GRID_TEST_CHECKTREE_HH
2#define DUNE_GRID_TEST_CHECKTREE_HH
3
4#include <functional>
5#include <iterator>
6
7#include <dune/geometry/dimension.hh>
8
9#include <dune/grid/common/rangegenerators.hh>
10
11namespace Dune
12{
13
14 // External Forward Declarations
15 // -----------------------------
16
17 template< int, class, class >
18 class EntityTree;
19
20 template< class, class >
21 class IntersectionTree;
22
23
24
25 // makeEntityTree
26 // --------------
27
28 template< class Grid, class Entity, class Predicate >
29 inline static EntityTree< Entity::codimension, Grid, Predicate >
30 makeEntityTree ( const Grid &grid, const Entity &entity, const Predicate &predicate )
31 {
32 return EntityTree< Entity::codimension, Grid, Predicate >( grid, entity, predicate );
33 }
34
35
36
37 // checkEntityTree
38 // ---------------
39
40 template< class Grid, class Entity >
41 void checkEntityTree ( const Grid &grid, const Entity &entity )
42 {
43 std::function< bool( const Entity & ) > allLeaf = [] ( const Entity &e ) { return true; };
44 auto tree = makeEntityTree( grid, entity, allLeaf );
45
46 auto noOp = [] ( const Entity &e ) {};
47 if( testForwardIterator( tree.begin(), tree.end(), noOp ) != 0 )
48 DUNE_THROW( Dune::Exception, "Tree iterator does not fulfill the forward iterator concept." );
49
50 if( std::distance( tree.begin(), tree.end() ) != 1 )
51 DUNE_THROW( Dune::Exception, "Tree iterator with all leaf predicate should iterate over exactly 1 element." );
52 }
53
54 template< int codim, class GridView >
55 void checkEntityTree ( const GridView &gridView, Codim< codim > = Codim< codim >() )
56 {
57 for( const auto &entity : entities( gridView, Codim< codim >() ) )
58 checkEntityTree( gridView.grid(), entity );
59 }
60
61} // namespace Dune
62
63#endif // #ifndef DUNE_GRID_TEST_CHECKTREE_HH
Base class for Dune-Exceptions.
Definition: exceptions.hh:96
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)