32#ifndef OPM_DATAHANDLEWRAPPERS_HEADER
33#define OPM_DATAHANDLEWRAPPERS_HEADER
39#include "OrientedEntityTable.hpp"
40#include "EntityRep.hpp"
42#include <dune/common/version.hh>
63 using DataType =
typename Handle::DataType;
74 : handle_(handle), c2fGather_(c2fGather), c2f_(c2f)
77#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 7)
78 bool fixedSize(
int,
int)
80 bool fixedsize(
int,
int)
86 typename std::enable_if<T::codimension != 0, std::size_t>::type
89 OPM_THROW(std::logic_error,
"This should never throw! We only know sizes for cells");
92 std::size_t size(
const EntityRep<0>& t)
94 const auto& faces = c2fGather_[t];
96 for (
const auto& face : faces)
98 size += handle_.size(face);
102 bool contains(std::size_t dim, std::size_t codim)
104 return dim==3 && codim == 0;
106 template<
class B,
class T>
107 typename std::enable_if<T::codimension != 0, void>::type
110 OPM_THROW(std::logic_error,
"This should never throw! We can only gather cell values and indicate that");
113 void gather(B& buffer,
const EntityRep<0>& t)
115 const auto& faces = c2fGather_[t];
116 for (
const auto& face : faces)
118 handle_.gather(buffer, face);
121 template<
class B,
class T>
122 typename std::enable_if<T::codimension != 0, void>::type
123 scatter(B&,
const T&, std::size_t)
125 OPM_THROW(std::logic_error,
"This should never throw! We can only gather cell values and indicate that");
128 void scatter(B& buffer,
const EntityRep<0>& t, std::size_t)
130 const auto& faces = c2f_[t];
131 for (
const auto& face : faces)
136 handle_.scatter(buffer, face, 1);
141 const C2FTable& c2fGather_, c2f_;
146 static bool printWarn;
151 std::cerr <<
"Communication of variable data attached to points is "
152 <<
"not fully supported. Your code/handle must not use the"
153 <<
"last parameter of "
154 <<
"DataHandle::scatter(B& buffer, E& entity, int size) "
155 <<
"as it will not be correct!";
170template<
class Handle>
173 using DataType =
typename Handle::DataType;
174 using C2PTable = std::vector< std::array<int,8> >;
182 const C2PTable& c2pGather,
184 : handle_(handle), c2pGather_(c2pGather), c2p_(c2p)
186#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 7)
187 bool fixedSize(
int i,
int j)
189 if( ! handle_.fixedSize(i, j))
193 return handle_.fixedSize(i, j);
196 bool fixedsize(
int i,
int j)
198 if( ! handle_.fixedsize(i, j))
202 return handle_.fixedsize(i, j);
206 typename std::enable_if<T::codimension != 0, std::size_t>::type
209 OPM_THROW(std::logic_error,
"This should never throw! We only know sizes for cells");
212 std::size_t size(
const EntityRep<0>& t)
214 const auto& points = c2pGather_[t.index()];
216 for (
const auto& point : points)
218 size += handle_.size(EntityRep<3>(point,
true));
222 bool contains(std::size_t dim, std::size_t codim)
224 return dim==3 && codim == 0;
226 template<
class B,
class T>
227 typename std::enable_if<T::codimension != 0, void>::type
230 OPM_THROW(std::logic_error,
"This should never throw! We can only gather cell values and indicate that");
233 void gather(B& buffer,
const EntityRep<0>& t)
235 const auto& points = c2pGather_[t.index()];
236 for (
const auto& point : points)
238 handle_.gather(buffer, EntityRep<3>(point,
true));
241 template<
class B,
class T>
242 typename std::enable_if<T::codimension != 0, void>::type
243 scatter(B&,
const T&, std::size_t)
245 OPM_THROW(std::logic_error,
"This should never throw! We can only gather cell values and indicate that");
248 void scatter(B& buffer,
const EntityRep<0>& t, std::size_t s)
250 const auto& points = c2p_[t.index()];
251 for (
const auto& point : points)
253 handle_.scatter(buffer, EntityRep<3>(point,
true), s/8);
258 const C2PTable& c2pGather_, c2p_;
Copyright 2019 Equinor AS.
Definition: CartesianIndexMapper.hpp:10
A data handle to send data attached to faces via cell communication.
Definition: DataHandleWrappers.hpp:62
FaceViaCellHandleWrapper(Handle &handle, const C2FTable &c2fGather, const C2FTable &c2f)
Constructs the data handle.
Definition: DataHandleWrappers.hpp:71
A data handle to send data attached to points via cell communication.
Definition: DataHandleWrappers.hpp:172
PointViaCellHandleWrapper(Handle &handle, const C2PTable &c2pGather, const C2PTable &c2p)
Constructs the data handle.
Definition: DataHandleWrappers.hpp:181
Definition: DataHandleWrappers.hpp:145