3#ifndef DUNE_GEOGRID_DATAHANDLE_HH
4#define DUNE_GEOGRID_DATAHANDLE_HH
10#include <dune/grid/geometrygrid/capabilities.hh>
11#include <dune/grid/geometrygrid/entity.hh>
22 template<
class Gr
id,
class WrappedHandle >
24 :
public CommDataHandleIF< CommDataHandle< Grid, WrappedHandle >, typename WrappedHandle::DataType >
26 typedef typename remove_const< Grid >::type::Traits Traits;
29 CommDataHandle (
const Grid &grid, WrappedHandle &handle )
31 wrappedHandle_( handle )
34 bool contains (
int dim,
int codim )
const
36 const bool contains = wrappedHandle_.contains( dim, codim );
38 assertHostEntity( dim, codim );
42 bool fixedsize (
int dim,
int codim )
const
44 return wrappedHandle_.fixedsize( dim, codim );
47 template<
class HostEntity >
48 size_t size (
const HostEntity &hostEntity )
const
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 );
56 template<
class MessageBuffer,
class HostEntity >
57 void gather ( MessageBuffer &buffer,
const HostEntity &hostEntity )
const
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 );
65 template<
class MessageBuffer,
class HostEntity >
66 void scatter ( MessageBuffer &buffer,
const HostEntity &hostEntity,
size_t size )
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 );
75 static void assertHostEntity (
int dim,
int codim )
77 if( !Capabilities::CodimCache< Grid >::hasHostEntity( codim ) )
81 static void noEntity (
int codim )
83 DUNE_THROW( NotImplemented,
"Host grid has no entities for codimension " << codim <<
"." );
87 WrappedHandle &wrappedHandle_;
void scatter(MessageBufferImp &buff, const EntityType &e, size_t n)
unpack data from message buffer to user.
Definition: datahandleif.hh:133
size_t size(const EntityType &e) const
how many objects of type DataType have to be sent for a given entity
Definition: datahandleif.hh:110
void gather(MessageBufferImp &buff, const EntityType &e) const
pack data from user to message buffer
Definition: datahandleif.hh:121
Different resources needed by all grid implementations.
Describes the parallel communication interface class for MessageBuffers and DataHandles.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:243
Dune namespace.
Definition: alignment.hh:10
Traits for type conversions and type information.