Dune Core Modules (2.8.0)

datahandle.hh
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
7
10#include <dune/grid/geometrygrid/capabilities.hh>
11#include <dune/grid/geometrygrid/entity.hh>
12
13namespace Dune
14{
15
16 namespace GeoGrid
17 {
18
19 // GeometryGridDataHandle
20 // ----------------------
21
22 template< class Grid, class WrappedHandle >
23 class CommDataHandle
24 : public CommDataHandleIF< CommDataHandle< Grid, WrappedHandle >, typename WrappedHandle::DataType >
25 {
26 typedef typename std::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 , int codim )
76 {
77 if( !Capabilities::CodimCache< Grid >::hasHostEntity( codim ) )
78 DUNE_THROW( NotImplemented, "Host grid has no entities for codimension " << codim << "." );
79 }
80
81 const Grid &grid_;
82 WrappedHandle &wrappedHandle_;
83 };
84
85 } // namespace GeoGrid
86
87} // namespace Dune
88
89#endif // #ifndef DUNE_GEOGRID_DATAHANDLE_HH
void scatter(MessageBufferImp &buff, const EntityType &e, size_t n)
unpack data from message buffer to user.
Definition: datahandleif.hh:205
size_t size(const EntityType &e) const
how many objects of type DataType have to be sent for a given entity
Definition: datahandleif.hh:180
void gather(MessageBufferImp &buff, const EntityType &e) const
pack data from user to message buffer
Definition: datahandleif.hh:191
Different resources needed by all grid implementations.
Describes the parallel communication interface class for MessageBuffers and DataHandles.
Traits for type conversions and type information.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
Dune namespace.
Definition: alignedallocator.hh:11
std::size_t fixedSize
The number of data items per index if it is fixed, 0 otherwise.
Definition: variablesizecommunicator.hh:272
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)