DUNE-ACFEM (unstable)

intersectiondatahandle.hh
1#ifndef __DUNE_ACFEM_INTERSECTIONDATAHANDLE_HH__
2#define __DUNE_ACFEM_INTERSECTIONDATAHANDLE_HH__
3
4#include <map>
5#include <dune/common/version.hh>
6#include <dune/grid/common/datahandleif.hh>
7#include <dune/common/version.hh>
8
9namespace Dune {
10
11 namespace ACFem {
12
13 template<class Storage>
14 struct IntersectionDataHandleTraits
15 {
16 typedef Storage StorageType;
17 typedef typename StorageType::value_type IntersectionStorageType;
18 typedef typename IntersectionStorageType::value_type DataItemType;
19 };
20
21 template<class Key, class IntersectionStorage, class... Further>
22 struct IntersectionDataHandleTraits<std::map<Key, IntersectionStorage, Further...> >
23 {
24 typedef std::map<Key, IntersectionStorage, Further...> StorageType;
25 typedef IntersectionStorage IntersectionStorageType;
26 typedef typename IntersectionStorageType::value_type DataItemType;
27 };
28
46 template<class IndexSet, class Storage, class Operation>
48 : public CommDataHandleIF<IntersectionDataHandle<IndexSet, Storage, Operation>,
49 typename IntersectionDataHandleTraits<Storage>::DataItemType>
50 {
51 public:
52 typedef IndexSet IndexSetType;
53 typedef Storage CommunicationStorageType;
54 private:
55 typedef IntersectionDataHandleTraits<Storage> TraitsType;
56 typedef typename TraitsType::IntersectionStorageType IntersectionStorageType;
57 typedef typename TraitsType::DataItemType DataItemType;
58 typedef Operation OperationType;
59 public:
60
61 IntersectionDataHandle(const IndexSetType& idxSet, CommunicationStorageType& storage)
62 : indexSet_(idxSet), storage_(storage)
63 {}
64
66 : indexSet_(other.indexSet_), storage_(other.storage_)
67 {}
68
70 bool contains(int dim, int codim) const
71 {
72 return codim == 1;
73 }
74
80 bool fixedSize(int dim, int codim) const
81 {
82 return false;
83 }
84
88 template<class Entity>
89 size_t size(const Entity& e) const
90 {
91 return storage_[indexSet_.index(e)].size();
92 }
93
95 template<class MessageBuffer, class Entity>
96 void gather(MessageBuffer& buff, const Entity& e) const
97 {
98 for (const auto data : storage_[indexSet_.index(e)]) {
99 buff.write(data);
100 }
101 }
102
104 template<class MessageBuffer, class Entity>
105 void scatter(MessageBuffer& buff, const Entity& e, size_t n)
106 {
107 assert(n == size(e));
108 for (auto& data : storage_[indexSet_.index(e)]) {
109 typename std::decay<decltype(data)>::type tmp;
110 buff.read(tmp);
111#if DUNE_VERSION_NEWER(DUNE_FEM, 2, 5)
112 OperationType()(tmp, data);
113#else
114 OperationType::apply(tmp, data);
115#endif
116 }
117 }
118
119 private:
120 const IndexSetType& indexSet_;
121 CommunicationStorageType& storage_;
122 };
123
124 } // namespace ACFem
125
126} // namespace Dune
127
128
129#endif // __DUNE_ACFEM_INTERSECTIONDATAHANDLE_HH__
General intersection - intersection communication which communicates for each intersection a potentia...
Definition: intersectiondatahandle.hh:50
void scatter(MessageBuffer &buff, const Entity &e, size_t n)
unpack data from message to user buffer
Definition: intersectiondatahandle.hh:105
size_t size(const Entity &e) const
how many objects of type DataItemType have to be sent for a given entity.
Definition: intersectiondatahandle.hh:89
bool contains(int dim, int codim) const
returns true if data for this codim should be communicated
Definition: intersectiondatahandle.hh:70
bool fixedSize(int dim, int codim) const
This entire beast is meant for communication like arrays of values at each quadrature point,...
Definition: intersectiondatahandle.hh:80
void gather(MessageBuffer &buff, const Entity &e) const
pack data from user to message buffer
Definition: intersectiondatahandle.hh:96
constexpr auto storage(const F &f, T &&... t)
Generate an expression storage container.
Definition: storage.hh:704
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 27, 23:30, 2024)