Dune Core Modules (2.9.0)

checkidcommunication.hh
1#ifndef DUNE_SPGRID_CHECKIDCOMMUNICATION_HH
2#define DUNE_SPGRID_CHECKIDCOMMUNICATION_HH
3
4#include <dune/common/hybridutilities.hh>
5
6#include <dune/geometry/dimension.hh>
7
9#include <dune/grid/common/gridview.hh>
10
11namespace Dune
12{
13
14 template< class VT >
15 struct CheckIdCommunicationDataHandle;
16
17
18 template< InterfaceType iftype, class VT >
19 inline void checkIdCommunication ( const GridView< VT > &gridView )
20 {
21 std::cout << "Checking communication ids for " << iftype << "..." << std::endl;
22 CheckIdCommunicationDataHandle< VT > handle( gridView );
23 gridView.communicate( handle, iftype, Dune::ForwardCommunication );
24 }
25
26
27 template< class VT >
28 inline void checkIdCommunication ( const GridView< VT > &gridView )
29 {
30 checkIdCommunication< InteriorBorder_InteriorBorder_Interface >( gridView );
31 checkIdCommunication< InteriorBorder_All_Interface >( gridView );
32 checkIdCommunication< Overlap_OverlapFront_Interface >( gridView );
33 checkIdCommunication< Overlap_All_Interface >( gridView );
34 checkIdCommunication< All_All_Interface >( gridView );
35 }
36
37
38 template< class VT >
39 struct CheckIdCommunicationDataHandle
40 : public CommDataHandleIF< CheckIdCommunicationDataHandle< VT >, typename GridView< VT >::Grid::GlobalIdSet::IdType >
41 {
42 typedef Dune::GridView< VT > GridView;
43
44 static const int dimension = GridView::dimension;
45
46 typedef typename GridView::Grid Grid;
47 typedef typename Grid::GlobalIdSet GlobalIdSet;
48 typedef typename GlobalIdSet::IdType IdType;
49
50 explicit CheckIdCommunicationDataHandle ( const GridView &gridView )
51 : rank_( gridView.grid().comm().rank() ),
52 idSet_( gridView.grid().globalIdSet() )
53 {
54 Hybrid::forEach( std::make_integer_sequence< int, dimension+1 >(), [ this ] ( auto codim ) {
56 } );
57 }
58
59 bool contains ( int const dim, const int codim ) const
60 {
61 return ((codim >= 0) && (codim <= dimension) ? contains_[ codim ] : false);
62 }
63
64 bool fixedSize ( const int dim, const int codim ) const
65 {
66 return true;
67 }
68
69 template< class Entity >
70 size_t size ( const Entity &entity ) const
71 {
72 return (contains_[ Entity::codimension ] ? 1 : 0);
73 }
74
75 template< class Buffer, class Entity >
76 void gather ( Buffer &buffer, const Entity &entity ) const
77 {
78 buffer.write( idSet_.id( entity ) );
79 }
80
81 template< class Buffer, class Entity >
82 void scatter ( Buffer &buffer, const Entity &entity, size_t n )
83 {
84 IdType id;
85 buffer.read( id );
86
87 if( id != idSet_.id( entity ) )
88 {
89 std::cerr << "[ " << rank_ << " ] Error: receive data from entity " << id
90 << " on entity " << idSet_.id( entity ) << "." << std::endl;
91 }
92 }
93
94 private:
95 const int rank_;
96 const GlobalIdSet &idSet_;
97 bool contains_[ dimension+1 ];
98 };
99
100}
101
102#endif // #ifndef DUNE_SPGRID_CHECKIDCOMMUNICATION_HH
void scatter(MessageBufferImp &buff, const EntityType &e, size_t n)
unpack data from message buffer to user.
Definition: datahandleif.hh:207
size_t size(const EntityType &e) const
how many objects of type DataType have to be sent for a given entity
Definition: datahandleif.hh:182
void gather(MessageBufferImp &buff, const EntityType &e) const
pack data from user to message buffer
Definition: datahandleif.hh:193
static constexpr int codimension
Know your own codimension.
Definition: entity.hh:106
Grid view abstract base class.
Definition: gridview.hh:66
GridFamily::Traits::GlobalIdSet GlobalIdSet
A type that is a model of Dune::IdSet which provides a unique and persistent numbering for all entiti...
Definition: grid.hh:502
A set of traits classes to store static information about grid implementation.
Traits::Grid Grid
type of the grid
Definition: gridview.hh:83
static constexpr int dimension
The dimension of the grid.
Definition: gridview.hh:148
@ ForwardCommunication
communicate as given in InterfaceType
Definition: gridenums.hh:171
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition: hybridutilities.hh:268
Dune namespace.
Definition: alignedallocator.hh:13
specialize with 'true' for all codims that a grid can communicate data on (default=false)
Definition: capabilities.hh:97
std::size_t fixedSize
The number of data items per index if it is fixed, 0 otherwise.
Definition: variablesizecommunicator.hh:265
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)