DUNE PDELab (git)

datahandleif.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_GRID_COMMON_DATAHANDLEIF_HH
6#define DUNE_GRID_COMMON_DATAHANDLEIF_HH
7
15
16namespace Dune
17{
18
31 template <class MessageBufferImp>
33 {
34 MessageBufferImp & buff_;
35 public:
37 MessageBufferIF(MessageBufferImp & buff) : buff_(buff) {}
38
44 template <class T>
45 void write(const T & val)
46 {
47 buff_.write(val);
48 }
49
58 template <class T>
59 void read(T & val)
60 {
61 buff_.read(val);
62 }
63 }; // end class MessageBufferIF
64
65
76 template <class DataHandleImp, class DataTypeImp>
78 {
79
80 public:
82 typedef DataTypeImp DataType;
83
84 protected:
85 // one should not create an explicit instance of this interface object
87
88 public:
94 bool contains (int dim, int codim) const
95 {
96 CHECK_INTERFACE_IMPLEMENTATION((asImp().contains(dim,codim)));
97 return asImp().contains(dim,codim);
98 }
99
107 bool fixedSize (int dim, int codim) const
108 {
109 CHECK_INTERFACE_IMPLEMENTATION((asImp().fixedSize(dim, codim)));
110 return asImp().fixedSize(dim, codim);
111 }
112
117 template<class EntityType>
118 size_t size (const EntityType& e) const
119 {
120 CHECK_INTERFACE_IMPLEMENTATION((asImp().size(e)));
121 return asImp().size(e);
122 }
123
128 template<class MessageBufferImp, class EntityType>
129 void gather (MessageBufferImp& buff, const EntityType& e) const
130 {
133 }
134
142 template<class MessageBufferImp, class EntityType>
143 void scatter (MessageBufferImp& buff, const EntityType& e, size_t n)
144 {
147 }
148
149 private:
151 DataHandleImp& asImp () {return static_cast<DataHandleImp &> (*this);}
153 const DataHandleImp& asImp () const
154 {
155 return static_cast<const DataHandleImp &>(*this);
156 }
157 }; // end class CommDataHandleIF
158
159#undef CHECK_INTERFACE_IMPLEMENTATION
160#undef CHECK_AND_CALL_INTERFACE_IMPLEMENTATION
161
162} // end namespace Dune
163#endif
Provides check for implementation of interface methods when using static polymorphism,...
#define CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(__interface_method_to_call__)
Definition: bartonnackmanifcheck.hh:61
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:78
void scatter(MessageBufferImp &buff, const EntityType &e, size_t n)
unpack data from message buffer to user.
Definition: datahandleif.hh:143
bool contains(int dim, int codim) const
returns true if data for given valid codim should be communicated
Definition: datahandleif.hh:94
size_t size(const EntityType &e) const
how many objects of type DataType have to be sent for a given entity
Definition: datahandleif.hh:118
void gather(MessageBufferImp &buff, const EntityType &e) const
pack data from user to message buffer
Definition: datahandleif.hh:129
bool fixedSize(int dim, int codim) const
returns true if size of data per entity of given dim and codim is a constant
Definition: datahandleif.hh:107
DataTypeImp DataType
data type of data to communicate
Definition: datahandleif.hh:82
Communication message buffer interface. This class describes the interface for reading and writing da...
Definition: datahandleif.hh:33
MessageBufferIF(MessageBufferImp &buff)
stores reference to original buffer buff
Definition: datahandleif.hh:37
void write(const T &val)
just wraps the call of the internal buffer method write which writes the data of type T from the buff...
Definition: datahandleif.hh:45
void read(T &val)
just wraps the call of the internal buffer method read which reads the data of type T from the buffer...
Definition: datahandleif.hh:59
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 23, 23:29, 2024)