dune-grid  2.11
geometrygrid/datahandle.hh
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 // vi: set et ts=4 sw=2 sts=2:
5 #ifndef DUNE_GEOGRID_DATAHANDLE_HH
6 #define DUNE_GEOGRID_DATAHANDLE_HH
7 
8 #include <dune/common/typetraits.hh>
9 
11 #include <dune/grid/common/grid.hh>
14 
15 namespace Dune
16 {
17 
18  namespace GeoGrid
19  {
20 
21  // GeometryGridDataHandle
22  // ----------------------
23 
24  template< class Grid, class WrappedHandle >
26  : public CommDataHandleIF< CommDataHandle< Grid, WrappedHandle >, typename WrappedHandle::DataType >
27  {
28  typedef typename std::remove_const< Grid >::type::Traits Traits;
29 
30  public:
31  CommDataHandle ( const Grid &grid, WrappedHandle &handle )
32  : grid_( grid ),
33  wrappedHandle_( handle )
34  {}
35 
36  bool contains ( int dim, int codim ) const
37  {
38  const bool contains = wrappedHandle_.contains( dim, codim );
39  if( contains )
40  assertHostEntity( dim, codim );
41  return contains;
42  }
43 
44  bool fixedSize ( int dim, int codim ) const
45  {
46  return wrappedHandle_.fixedSize( dim, codim );
47  }
48 
49  template< class HostEntity >
50  size_t size ( const HostEntity &hostEntity ) const
51  {
52  typedef typename Grid::Traits::template Codim< HostEntity::codimension >::Entity Entity;
53  typedef typename Grid::Traits::template Codim< HostEntity::codimension >::EntityImpl EntityImpl;
54  Entity entity( EntityImpl( grid_, hostEntity ) );
55  return wrappedHandle_.size( entity );
56  }
57 
58  template< class MessageBuffer, class HostEntity >
59  void gather ( MessageBuffer &buffer, const HostEntity &hostEntity ) const
60  {
61  typedef typename Grid::Traits::template Codim< HostEntity::codimension >::Entity Entity;
62  typedef typename Grid::Traits::template Codim< HostEntity::codimension >::EntityImpl EntityImpl;
63  Entity entity( EntityImpl( grid_, hostEntity ) );
64  wrappedHandle_.gather( buffer, entity );
65  }
66 
67  template< class MessageBuffer, class HostEntity >
68  void scatter ( MessageBuffer &buffer, const HostEntity &hostEntity, size_t size_ )
69  {
70  typedef typename Grid::Traits::template Codim< HostEntity::codimension >::Entity Entity;
71  typedef typename Grid::Traits::template Codim< HostEntity::codimension >::EntityImpl EntityImpl;
72  Entity entity( EntityImpl( grid_, hostEntity ) );
73  wrappedHandle_.scatter( buffer, entity, size_ );
74  }
75 
76  private:
77  static void assertHostEntity ( int , int codim )
78  {
80  DUNE_THROW( NotImplemented, "Host grid has no entities for codimension " << codim << "." );
81  }
82 
83  const Grid &grid_;
84  WrappedHandle &wrappedHandle_;
85  };
86 
87  } // namespace GeoGrid
88 
89 } // namespace Dune
90 
91 #endif // #ifndef DUNE_GEOGRID_DATAHANDLE_HH
concept Entity
Model of a grid entity.
Definition: concepts/entity.hh:119
CommDataHandle(const Grid &grid, WrappedHandle &handle)
Definition: geometrygrid/datahandle.hh:31
concept MessageBuffer
Model of a message buffer.
Definition: messagebuffer.hh:17
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:375
size_t size(const HostEntity &hostEntity) const
Definition: geometrygrid/datahandle.hh:50
Different resources needed by all grid implementations.
void scatter(MessageBuffer &buffer, const HostEntity &hostEntity, size_t size_)
Definition: geometrygrid/datahandle.hh:68
bool fixedSize(int dim, int codim) const
Definition: geometrygrid/datahandle.hh:44
Include standard header files.
Definition: agrid.hh:59
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:77
Describes the parallel communication interface class for MessageBuffers and DataHandles.
DUNE-conform implementation of the entityThis class merely changes the template parameters of the ent...
Definition: geometrygrid/entity.hh:49
Definition: geometrygrid/datahandle.hh:25
Definition: geometrygrid/capabilities.hh:115
bool contains(int dim, int codim) const
Definition: geometrygrid/datahandle.hh:36
void gather(MessageBuffer &buffer, const HostEntity &hostEntity) const
Definition: geometrygrid/datahandle.hh:59