25 #ifndef EWOMS_ELEMENT_BORDER_LIST_FROM_GRID_HH
26 #define EWOMS_ELEMENT_BORDER_LIST_FROM_GRID_HH
31 #include <dune/grid/common/datahandleif.hh>
32 #include <dune/grid/common/gridenums.hh>
33 #include <dune/istl/bcrsmatrix.hh>
34 #include <dune/istl/scalarproducts.hh>
35 #include <dune/istl/operators.hh>
36 #include <dune/common/version.hh>
47 template <
class Gr
idView,
class ElementMapper>
54 typedef typename GridView::template Codim<0>::Entity Element;
56 class BorderListHandle_
57 :
public Dune::CommDataHandleIF<BorderListHandle_, int>
60 BorderListHandle_(
const GridView &gridView,
61 const ElementMapper &map,
66 , blackList_(blackList)
67 , borderList_(borderList)
69 auto elemIt = gridView_.template begin<0>();
70 const auto& elemEndIt = gridView_.template end<0>();
71 for (; elemIt != elemEndIt; ++elemIt) {
72 if (elemIt->partitionType() != Dune::InteriorEntity) {
73 #if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 4)
74 int elemIdx = map_.index(*elemIt);
76 int elemIdx = map_.map(*elemIt);
78 blackList_.addIndex(elemIdx);
84 bool contains(
int dim,
int codim)
const
85 {
return codim == 0; }
87 bool fixedsize(
int dim,
int codim)
const
90 template <
class EntityType>
91 size_t size(
const EntityType &e)
const
94 template <
class MessageBufferImp,
class EntityType>
95 void gather(MessageBufferImp &buff,
const EntityType &e)
const
97 #if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 4)
98 int myIdx = map_.index(e);
100 int myIdx = map_.map(e);
102 buff.write(static_cast<int>(gridView_.comm().rank()));
106 template <
class MessageBufferImp>
107 void scatter(MessageBufferImp &buff,
const Element &e,
size_t n)
110 bool isInteriorNeighbor =
false;
111 auto isIt = gridView_.ibegin(e);
112 const auto &isEndIt = gridView_.iend(e);
113 for (; isIt != isEndIt; ++isIt) {
114 if (!isIt->neighbor())
116 #if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 4)
117 else if (isIt->outside().partitionType() == Dune::InteriorEntity) {
119 else if (isIt->outside()->partitionType() == Dune::InteriorEntity) {
121 isInteriorNeighbor =
true;
125 if (!isInteriorNeighbor)
130 #if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 4)
139 peerSet_.insert(tmp);
148 borderList_.push_back(bIdx);
154 template <
class MessageBufferImp,
class EntityType>
155 void scatter(MessageBufferImp &buff,
const EntityType &e,
size_t n)
158 const std::set<ProcessRank>& peerSet()
const
163 const ElementMapper &map_;
164 std::set<ProcessRank> peerSet_;
169 class PeerBlackListHandle_
170 :
public Dune::CommDataHandleIF<PeerBlackListHandle_, int>
173 PeerBlackListHandle_(
const GridView &gridView,
174 const ElementMapper &map,
175 PeerBlackLists& peerBlackLists)
176 : gridView_(gridView)
178 , peerBlackLists_(peerBlackLists)
182 bool contains(
int dim,
int codim)
const
183 {
return codim == 0; }
185 bool fixedsize(
int dim,
int codim)
const
188 template <
class EntityType>
189 size_t size(
const EntityType &e)
const
192 template <
class MessageBufferImp,
class EntityType>
193 void gather(MessageBufferImp &buff,
const EntityType &e)
const
195 buff.write(static_cast<int>(gridView_.comm().rank()));
196 #if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 4)
197 buff.write(static_cast<int>(map_.index(e)));
199 buff.write(static_cast<int>(map_.map(e)));
203 template <
class MessageBufferImp,
class EntityType>
204 void scatter(MessageBufferImp &buff,
const EntityType &e,
size_t n)
212 #if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 4)
213 localIdx = map_.index(e);
215 localIdx = map_.map(e);
218 PeerBlackListedEntry pIdx;
222 peerBlackLists_[peerRank].push_back(pIdx);
225 const PeerBlackList& peerBlackList(
ProcessRank peerRank)
const
226 {
return peerBlackLists_.at(peerRank); }
230 const ElementMapper &map_;
231 PeerBlackLists peerBlackLists_;
236 : gridView_(gridView)
239 BorderListHandle_ blh(gridView, map, blackList_, borderList_);
240 gridView.communicate(blh,
241 Dune::InteriorBorder_All_Interface,
242 Dune::BackwardCommunication);
244 PeerBlackListHandle_ pblh(gridView, map, peerBlackLists_);
245 gridView.communicate(pblh,
246 Dune::InteriorBorder_All_Interface,
247 Dune::BackwardCommunication);
249 auto peerIt = blh.peerSet().begin();
250 const auto& peerEndIt = blh.peerSet().end();
251 for (; peerIt != peerEndIt; ++peerIt) {
252 blackList_.setPeerList(*peerIt, pblh.peerBlackList(*peerIt));
258 {
return borderList_; }
262 {
return blackList_; }
265 const GridView gridView_;
266 const ElementMapper &map_;
271 PeerBlackLists peerBlackLists_;
Index nativeIndexOfPeer
Definition: blacklist.hh:49
const BlackList & blackList() const
Definition: elementborderlistfromgrid.hh:261
This files provides several data structures for storing tuples of indices of remote and/or local proc...
const BorderList & borderList() const
Definition: elementborderlistfromgrid.hh:257
std::vector< PeerBlackListedEntry > PeerBlackList
Definition: blacklist.hh:52
ElementBorderListFromGrid(const GridView &gridView, const ElementMapper &map)
Definition: elementborderlistfromgrid.hh:235
Expresses which degrees of freedom are blacklisted for the parallel linear solvers and which domestic...
Definition: blacklist.hh:45
BorderDistance borderDistance
Distance to the process border for the peer (in hops)
Definition: overlaptypes.hh:112
std::list< BorderIndex > BorderList
This class managages a list of indices which are on the border of a process' partition of the grid...
Definition: overlaptypes.hh:119
Index localIdx
Index of the entity for the local process.
Definition: overlaptypes.hh:103
Index peerIdx
Index of the entity for the peer process.
Definition: overlaptypes.hh:106
A single index intersecting with the process boundary.
Definition: overlaptypes.hh:100
Uses communication on the grid to find the initial seed list of indices for methods which use element...
Definition: elementborderlistfromgrid.hh:48
Definition: baseauxiliarymodule.hh:35
Definition: blacklist.hh:48
std::map< ProcessRank, PeerBlackList > PeerBlackLists
Definition: blacklist.hh:53
ProcessRank peerRank
Rank of the peer process.
Definition: overlaptypes.hh:109
Index myOwnNativeIndex
Definition: blacklist.hh:50
Expresses which degrees of freedom are blacklisted for the parallel linear solvers and which domestic...
unsigned ProcessRank
The type of the rank of a process.
Definition: overlaptypes.hh:48