DUNE-ACFEM (2.5.1)

intersectiondatahandle.hh
1#ifndef __DUNE_ACFEM_INTERSECTIONDATAHANDLE_HH__
2#define __DUNE_ACFEM_INTERSECTIONDATAHANDLE_HH__
3
4#include <map>
5#include <dune/grid/common/datahandleif.hh>
6
7namespace Dune {
8
9 namespace ACFem {
10
11 template<class Storage>
12 struct IntersectionDataHandleTraits
13 {
14 typedef Storage StorageType;
15 typedef typename StorageType::value_type IntersectionStorageType;
16 typedef typename IntersectionStorageType::value_type DataItemType;
17 };
18
19 template<class Key, class IntersectionStorage, class... Further>
20 struct IntersectionDataHandleTraits<std::map<Key, IntersectionStorage, Further...> >
21 {
22 typedef std::map<Key, IntersectionStorage, Further...> StorageType;
23 typedef IntersectionStorage IntersectionStorageType;
24 typedef typename IntersectionStorageType::value_type DataItemType;
25 };
26
44 template<class IndexSet, class Storage, class Operation>
46 : public CommDataHandleIF<IntersectionDataHandle<IndexSet, Storage, Operation>,
47 typename IntersectionDataHandleTraits<Storage>::DataItemType>
48 {
49 public:
50 typedef IndexSet IndexSetType;
51 typedef Storage CommunicationStorageType;
52 private:
53 typedef IntersectionDataHandleTraits<Storage> TraitsType;
54 typedef typename TraitsType::IntersectionStorageType IntersectionStorageType;
55 typedef typename TraitsType::DataItemType DataItemType;
56 typedef Operation OperationType;
57 typedef typename IndexSetType::IndexType IndexType;
58 public:
59
60 IntersectionDataHandle(const IndexSetType& idxSet, CommunicationStorageType& storage)
61 : indexSet_(idxSet), storage_(storage)
62 {}
63
65 : indexSet_(other.indexSet_), storage_(other.storage_)
66 {}
67
69 bool contains(int dim, int codim) const
70 {
71 return codim == 1;
72 }
73
79 bool fixedsize(int dim, int codim) const
80 {
81 return false;
82 }
83
87 template<class EntityType>
88 size_t size(EntityType& e) const
89 {
90 IndexType idx = indexSet_.index(e);
91 return storage_[idx].size();
92 }
93
95 template<class MessageBuffer, class EntityType>
96 void gather(MessageBuffer& buff, const EntityType& e) const
97 {
98 IndexType idx = indexSet_.index(e);
99
100 const auto& intersectionStorage(storage_[idx]);
101 const auto end = intersectionStorage.end();
102 for (auto it = intersectionStorage.begin(); it != end; ++it) {
103 buff.write(*it);
104 }
105 }
106
108 template<class MessageBuffer, class EntityType>
109 void scatter(MessageBuffer& buff, const EntityType& e, size_t n)
110 {
111 assert(n == size(e));
112
113 int idx = indexSet_.index(e);
114 auto& intersectionStorage(storage_[idx]);
115 const auto end = intersectionStorage.end();
116 for (auto it = intersectionStorage.begin(); it != end; ++it) {
117 DataItemType tmp;
118 buff.read(tmp);
119#if DUNE_VERSION_NEWER(DUNE_FEM, 2, 5)
120 OperationType()(tmp, *it);
121#else
122 OperationType::apply(tmp, *it);
123#endif
124 }
125 }
126
127 private:
128 const IndexSetType& indexSet_;
129 CommunicationStorageType& storage_;
130 };
131
132 } // namespace ACFem
133
134} // namespace Dune
135
136
137#endif // __DUNE_ACFEM_INTERSECTIONDATAHANDLE_HH__
General intersection - intersection communication which communicates for each intersection a potentia...
Definition: intersectiondatahandle.hh:48
void scatter(MessageBuffer &buff, const EntityType &e, size_t n)
unpack data from message to user buffer
Definition: intersectiondatahandle.hh:109
bool contains(int dim, int codim) const
returns true if data for this codim should be communicated
Definition: intersectiondatahandle.hh:69
void gather(MessageBuffer &buff, const EntityType &e) const
pack data from user to message buffer
Definition: intersectiondatahandle.hh:96
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:79
size_t size(EntityType &e) const
how many objects of type DataItemType have to be sent for a given entity.
Definition: intersectiondatahandle.hh:88
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Aug 13, 22:30, 2024)