Dune Core Modules (2.5.2)

datahandleif.hh
Go to the documentation of this file.
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_DATAHANDLEIF_HH
4#define DUNE_DATAHANDLEIF_HH
5
13
14namespace Dune
15{
16
29 template <class MessageBufferImp>
31 {
32 MessageBufferImp & buff_;
33 public:
35 MessageBufferIF(MessageBufferImp & buff) : buff_(buff) {}
36
42 template <class T>
43 void write(const T & val)
44 {
45 buff_.write(val);
46 }
47
53 template <class T>
54 void read(T & val) const
55 {
56 buff_.read(val);
57 }
58 }; // end class MessageBufferIF
59
60
71 template <class DataHandleImp, class DataTypeImp>
73 {
74 public:
76 typedef DataTypeImp DataType;
77
78 protected:
79 // one should not create an explicit instance of this interface object
81
82 public:
88 bool contains (int dim, int codim) const
89 {
90 CHECK_INTERFACE_IMPLEMENTATION((asImp().contains(dim,codim)));
91 return asImp().contains(dim,codim);
92 }
93
104 bool fixedsize (int dim, int codim) const
105 {
107 auto derPtr = &DataHandleImp::fixedSize;
108 bool hasOverwrittenFixedSize = basePtr != derPtr;
109 if (hasOverwrittenFixedSize)
110 return asImp().fixedSize(dim,codim);
111 else
112 return asImp().fixedsize(dim,codim);
113 }
114
123 bool fixedSize (int dim, int codim) const
124 {
126 auto derPtr = &DataHandleImp::fixedSize;
127 bool hasOverwrittenFixedSize = basePtr != derPtr;
128 if (hasOverwrittenFixedSize)
129 return asImp().fixedSize(dim,codim);
130 else
131 return asImp().fixedsize(dim,codim);
132 }
133
138 template<class EntityType>
139 size_t size (const EntityType& e) const
140 {
141 CHECK_INTERFACE_IMPLEMENTATION((asImp().size(e)));
142 return asImp().size(e);
143 }
144
149 template<class MessageBufferImp, class EntityType>
150 void gather (MessageBufferImp& buff, const EntityType& e) const
151 {
154 }
155
161 template<class MessageBufferImp, class EntityType>
162 void scatter (MessageBufferImp& buff, const EntityType& e, size_t n)
163 {
166 }
167
168 private:
170 DataHandleImp& asImp () {return static_cast<DataHandleImp &> (*this);}
172 const DataHandleImp& asImp () const
173 {
174 return static_cast<const DataHandleImp &>(*this);
175 }
176 }; // end class CommDataHandleIF
177
178#undef CHECK_INTERFACE_IMPLEMENTATION
179#undef CHECK_AND_CALL_INTERFACE_IMPLEMENTATION
180
181} // end namespace Dune
182#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:59
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:73
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:104
void scatter(MessageBufferImp &buff, const EntityType &e, size_t n)
unpack data from message buffer to user.
Definition: datahandleif.hh:162
bool contains(int dim, int codim) const
returns true if data for given valid codim should be communicated
Definition: datahandleif.hh:88
size_t size(const EntityType &e) const
how many objects of type DataType have to be sent for a given entity
Definition: datahandleif.hh:139
void gather(MessageBufferImp &buff, const EntityType &e) const
pack data from user to message buffer
Definition: datahandleif.hh:150
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:123
DataTypeImp DataType
data type of data to communicate
Definition: datahandleif.hh:76
Communication message buffer interface. This class describes the interface for reading and writing da...
Definition: datahandleif.hh:31
MessageBufferIF(MessageBufferImp &buff)
stores reference to original buffer buff
Definition: datahandleif.hh:35
void read(T &val) const
just wraps the call of the internal buffer method read which reads the data of type T from the buffer...
Definition: datahandleif.hh:54
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:43
Dune namespace.
Definition: alignment.hh:11
std::size_t fixedSize
The number of data items per index if it is fixed, 0 otherwise.
Definition: variablesizecommunicator.hh:238
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)