Dune Core Modules (2.9.0)

datahandle.hh
1// SPDX-FileCopyrightText: Copyright (C) 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
9
12#include <dune/grid/geometrygrid/capabilities.hh>
13#include <dune/grid/geometrygrid/entity.hh>
14
15namespace Dune
16{
17
18 namespace GeoGrid
19 {
20
21 // GeometryGridDataHandle
22 // ----------------------
23
24 template< class Grid, class WrappedHandle >
25 class CommDataHandle
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 {
79 if( !Capabilities::CodimCache< Grid >::hasHostEntity( codim ) )
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
void scatter(MessageBufferImp &buff, const EntityType &e, size_t n)
unpack data from message buffer to user.
Definition: datahandleif.hh:207
size_t size(const EntityType &e) const
how many objects of type DataType have to be sent for a given entity
Definition: datahandleif.hh:182
void gather(MessageBufferImp &buff, const EntityType &e) const
pack data from user to message buffer
Definition: datahandleif.hh:193
Describes the parallel communication interface class for MessageBuffers and DataHandles.
Traits for type conversions and type information.
Different resources needed by all grid implementations.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Dune namespace.
Definition: alignedallocator.hh:13
std::size_t fixedSize
The number of data items per index if it is fixed, 0 otherwise.
Definition: variablesizecommunicator.hh:265
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)