dune-grid  2.4.1
geometrygrid/datahandle.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_GEOGRID_DATAHANDLE_HH
4 #define DUNE_GEOGRID_DATAHANDLE_HH
5 
6 #include <dune/common/typetraits.hh>
7 
12 
13 namespace Dune
14 {
15 
16  namespace GeoGrid
17  {
18 
19  // GeometryGridDataHandle
20  // ----------------------
21 
22  template< class Grid, class WrappedHandle >
24  : public CommDataHandleIF< CommDataHandle< Grid, WrappedHandle >, typename WrappedHandle::DataType >
25  {
26  typedef typename remove_const< Grid >::type::Traits Traits;
27 
28  public:
29  CommDataHandle ( const Grid &grid, WrappedHandle &handle )
30  : grid_( grid ),
31  wrappedHandle_( handle )
32  {}
33 
34  bool contains ( int dim, int codim ) const
35  {
36  const bool contains = wrappedHandle_.contains( dim, codim );
37  if( contains )
38  assertHostEntity( dim, codim );
39  return contains;
40  }
41 
42  bool fixedsize ( int dim, int codim ) const
43  {
44  return wrappedHandle_.fixedsize( dim, codim );
45  }
46 
47  template< class HostEntity >
48  size_t size ( const HostEntity &hostEntity ) const
49  {
50  typedef typename Grid::Traits::template Codim< HostEntity::codimension >::Entity Entity;
51  typedef typename Grid::Traits::template Codim< HostEntity::codimension >::EntityImpl EntityImpl;
52  Entity entity( EntityImpl( grid_, hostEntity ) );
53  return wrappedHandle_.size( entity );
54  }
55 
56  template< class MessageBuffer, class HostEntity >
57  void gather ( MessageBuffer &buffer, const HostEntity &hostEntity ) const
58  {
59  typedef typename Grid::Traits::template Codim< HostEntity::codimension >::Entity Entity;
60  typedef typename Grid::Traits::template Codim< HostEntity::codimension >::EntityImpl EntityImpl;
61  Entity entity( EntityImpl( grid_, hostEntity ) );
62  wrappedHandle_.gather( buffer, entity );
63  }
64 
65  template< class MessageBuffer, class HostEntity >
66  void scatter ( MessageBuffer &buffer, const HostEntity &hostEntity, size_t size )
67  {
68  typedef typename Grid::Traits::template Codim< HostEntity::codimension >::Entity Entity;
69  typedef typename Grid::Traits::template Codim< HostEntity::codimension >::EntityImpl EntityImpl;
70  Entity entity( EntityImpl( grid_, hostEntity ) );
71  wrappedHandle_.scatter( buffer, entity, size );
72  }
73 
74  private:
75  static void assertHostEntity ( int dim, int codim )
76  {
78  noEntity( codim );
79  }
80 
81  static void noEntity ( int codim )
82  {
83  DUNE_THROW( NotImplemented, "Host grid has no entities for codimension " << codim << "." );
84  }
85 
86  const Grid &grid_;
87  WrappedHandle &wrappedHandle_;
88  };
89 
90  } // namespace GeoGrid
91 
92 } // namespace Dune
93 
94 #endif // #ifndef DUNE_GEOGRID_DATAHANDLE_HH
size_t size(const HostEntity &hostEntity) const
Definition: geometrygrid/datahandle.hh:48
bool fixedsize(int dim, int codim) const
Definition: geometrygrid/datahandle.hh:42
CommDataHandle(const Grid &grid, WrappedHandle &handle)
Definition: geometrygrid/datahandle.hh:29
Definition: geometrygrid/datahandle.hh:23
Definition: geometrygrid/capabilities.hh:112
Different resources needed by all grid implementations.
void gather(MessageBuffer &buffer, const HostEntity &hostEntity) const
Definition: geometrygrid/datahandle.hh:57
void scatter(MessageBuffer &buffer, const HostEntity &hostEntity, size_t size)
Definition: geometrygrid/datahandle.hh:66
Describes the parallel communication interface class for MessageBuffers and DataHandles.
Grid abstract base classThis class is the base class for all grid implementations. Although no virtual functions are used we call it abstract since its methods do not contain an implementation but forward to the methods of the derived class via the Barton-Nackman trick.
Definition: common/grid.hh:388
bool contains(int dim, int codim) const
Definition: geometrygrid/datahandle.hh:34
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:72
Include standard header files.
Definition: agrid.hh:59
DUNE-conform implementation of the entityThis class merely changes the template parameters of the ent...
Definition: geometrygrid/entity.hh:49