dune-fem  2.8-git
gridpart/geometrygridpart/datahandle.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_GRIDPART_GEOMETRYGRIDPART_DATAHANDLE_HH
2 #define DUNE_FEM_GRIDPART_GEOMETRYGRIDPART_DATAHANDLE_HH
3 
4 #include <type_traits>
5 
6 #include <dune/grid/common/datahandleif.hh>
7 
9 
10 namespace Dune
11 {
12 
13  namespace Fem
14  {
15 
16  // GeometryGridPartDataHandle
17  // ------------
18 
19  template< class GridFamily, class WrappedHandle >
21  : public CommDataHandleIF< GeometryGridPartDataHandle< GridFamily, WrappedHandle >, typename WrappedHandle::DataType >
22  {
23  typedef typename std::remove_const< GridFamily >::type::Traits Traits;
24  typedef typename GridFamily::GridFunctionType GridFunctionType;
25 
26  template< class HostEntity >
27  class EntityProxy;
28 
29  public:
30  GeometryGridPartDataHandle ( WrappedHandle &handle, const GridFunctionType &gridFunction )
31  : wrappedHandle_( handle ), gridFunction_( gridFunction )
32  {}
33 
34  bool contains ( int dim, int codim ) const
35  {
36  return wrappedHandle_.contains( dim, codim );
37  }
38 
39  bool fixedSize ( int dim, int codim ) const
40  {
41  return wrappedHandle_.fixedSize( dim, codim );
42  }
43 
44  template< class HostEntity >
45  size_t size ( const HostEntity &hostEntity ) const
46  {
47  EntityProxy< HostEntity > proxy( gridFunction_, hostEntity );
48  return wrappedHandle_.size( *proxy );
49  }
50 
51  template< class MessageBuffer, class HostEntity >
52  void gather ( MessageBuffer &buffer, const HostEntity &hostEntity ) const
53  {
54  EntityProxy< HostEntity > proxy( gridFunction_, hostEntity );
55  wrappedHandle_.gather( buffer, *proxy );
56  }
57 
58  template< class MessageBuffer, class HostEntity >
59  void scatter ( MessageBuffer &buffer, const HostEntity &hostEntity, size_t size )
60  {
61  EntityProxy< HostEntity > proxy( gridFunction_, hostEntity );
62  wrappedHandle_.scatter( buffer, *proxy, size );
63  }
64 
65  private:
66  WrappedHandle &wrappedHandle_;
67  const GridFunctionType &gridFunction_;
68  };
69 
70 
71 
72  template< class GridFamily, class WrappedHandle >
73  template< class HostEntity >
74  class GeometryGridPartDataHandle< GridFamily, WrappedHandle >::EntityProxy
75  {
76  public:
77  static const int dimension = HostEntity::dimension;
78  static const int codimension = HostEntity::codimension;
79 
80  typedef Dune::Entity< codimension, dimension, const GridFamily, GeometryGridPartEntity > Entity;
81 
82  private:
83  typedef GeometryGridPartEntity< codimension, dimension, const GridFamily > EntityImpl;
84 
85  public:
86  EntityProxy ( const GridFunctionType &gridFunction_, const HostEntity &hostEntity )
87  : entity_( EntityImpl( gridFunction_, hostEntity ) )
88  {}
89 
90  const Entity &operator* () const
91  {
92  return entity_;
93  }
94 
95  private:
96  Entity entity_;
97  };
98 
99  } // namespace Fem
100 
101 } // namespace Dune
102 
103 #endif // #ifndef DUNE_FEM_GRIDPART_GEOMETRYGRIDPART_DATAHANDLE_HH
Definition: bindguard.hh:11
Double operator*(const Double &a, const Double &b)
Definition: double.hh:506
Definition: gridpart/geometrygridpart/datahandle.hh:22
bool contains(int dim, int codim) const
Definition: gridpart/geometrygridpart/datahandle.hh:34
bool fixedSize(int dim, int codim) const
Definition: gridpart/geometrygridpart/datahandle.hh:39
GeometryGridPartDataHandle(WrappedHandle &handle, const GridFunctionType &gridFunction)
Definition: gridpart/geometrygridpart/datahandle.hh:30
size_t size(const HostEntity &hostEntity) const
Definition: gridpart/geometrygridpart/datahandle.hh:45
void scatter(MessageBuffer &buffer, const HostEntity &hostEntity, size_t size)
Definition: gridpart/geometrygridpart/datahandle.hh:59
void gather(MessageBuffer &buffer, const HostEntity &hostEntity) const
Definition: gridpart/geometrygridpart/datahandle.hh:52