27#ifndef EWOMS_ELEMENT_BORDER_LIST_FROM_GRID_HH
28#define EWOMS_ELEMENT_BORDER_LIST_FROM_GRID_HH
33#include <dune/grid/common/datahandleif.hh>
34#include <dune/grid/common/gridenums.hh>
35#include <dune/grid/common/partitionset.hh>
36#include <dune/common/version.hh>
47template <
class Gr
idView,
class ElementMapper>
54 using Element =
typename GridView::template Codim<0>::Entity;
56 class BorderListHandle_
57 :
public Dune::CommDataHandleIF<BorderListHandle_, ProcessRank>
60 BorderListHandle_(
const GridView& gridView,
61 const ElementMapper& map,
69 for (
const auto& elem : elements(gridView_)) {
70 if (elem.partitionType() != Dune::InteriorEntity) {
71 Index elemIdx =
static_cast<Index>(map_.index(elem));
72 blackList_.addIndex(elemIdx);
78 bool contains(
int,
int codim)
const
79 {
return codim == 0; }
81#if DUNE_VERSION_LT(DUNE_GRID, 2, 8)
82 bool fixedsize(
int,
int)
const
84 bool fixedSize(
int,
int)
const
88 template <
class EntityType>
89 size_t size(
const EntityType&)
const
92 template <
class MessageBufferImp,
class EntityType>
93 void gather(MessageBufferImp& buff,
const EntityType& e)
const
95 unsigned myIdx =
static_cast<unsigned>(map_.index(e));
96 buff.write(
static_cast<unsigned>(gridView_.comm().rank()));
100 template <
class MessageBufferImp>
101 void scatter(MessageBufferImp& buff,
106 bool isInteriorNeighbor =
false;
107 auto isIt = gridView_.ibegin(e);
108 const auto& isEndIt = gridView_.iend(e);
109 for (; isIt != isEndIt; ++isIt) {
110 if (!isIt->neighbor())
112 else if (isIt->outside().partitionType() == Dune::InteriorEntity) {
113 isInteriorNeighbor =
true;
117 if (!isInteriorNeighbor)
127 peerSet_.insert(tmp);
136 borderList_.push_back(bIdx);
142 template <
class MessageBufferImp,
class EntityType>
143 void scatter(MessageBufferImp&,
148 const std::set<ProcessRank>& peerSet()
const
153 const ElementMapper& map_;
154 std::set<ProcessRank> peerSet_;
159 class PeerBlackListHandle_
160 :
public Dune::CommDataHandleIF<PeerBlackListHandle_, int>
163 PeerBlackListHandle_(
const GridView& gridView,
164 const ElementMapper& map,
165 PeerBlackLists& peerBlackLists)
166 : gridView_(gridView)
168 , peerBlackLists_(peerBlackLists)
172 bool contains(
int,
int codim)
const
173 {
return codim == 0; }
175#if DUNE_VERSION_LT(DUNE_GRID, 2, 8)
176 bool fixedsize(
int,
int)
const
178 bool fixedSize(
int,
int)
const
182 template <
class EntityType>
183 size_t size(
const EntityType&)
const
186 template <
class MessageBufferImp,
class EntityType>
187 void gather(MessageBufferImp& buff,
const EntityType& e)
const
189 buff.write(
static_cast<int>(gridView_.comm().rank()));
190 buff.write(
static_cast<int>(map_.index(e)));
193 template <
class MessageBufferImp,
class EntityType>
194 void scatter(MessageBufferImp& buff,
const EntityType& e,
size_t)
202 localIdx =
static_cast<Index>(map_.index(e));
208 peerBlackLists_[
static_cast<ProcessRank>(peerRank)].push_back(pIdx);
211 const PeerBlackList& peerBlackList(
ProcessRank peerRank)
const
212 {
return peerBlackLists_.at(peerRank); }
216 const ElementMapper& map_;
217 PeerBlackLists peerBlackLists_;
222 : gridView_(gridView)
225 BorderListHandle_ blh(gridView, map, blackList_, borderList_);
226 gridView.communicate(blh,
227 Dune::InteriorBorder_All_Interface,
228 Dune::BackwardCommunication);
230 PeerBlackListHandle_ pblh(gridView, map, peerBlackLists_);
231 gridView.communicate(pblh,
232 Dune::InteriorBorder_All_Interface,
233 Dune::BackwardCommunication);
235 auto peerIt = blh.peerSet().begin();
236 const auto& peerEndIt = blh.peerSet().end();
237 for (; peerIt != peerEndIt; ++peerIt) {
238 blackList_.
setPeerList(*peerIt, pblh.peerBlackList(*peerIt));
244 {
return borderList_; }
248 {
return blackList_; }
251 const GridView gridView_;
252 const ElementMapper& map_;
257 PeerBlackLists peerBlackLists_;
Expresses which degrees of freedom are blacklisted for the parallel linear solvers and which domestic...
Definition: blacklist.hh:49
std::vector< PeerBlackListedEntry > PeerBlackList
Definition: blacklist.hh:55
void setPeerList(ProcessRank peerRank, const PeerBlackList &peerBlackList)
Definition: blacklist.hh:77
std::map< ProcessRank, PeerBlackList > PeerBlackLists
Definition: blacklist.hh:56
Uses communication on the grid to find the initial seed list of indices for methods which use element...
Definition: elementborderlistfromgrid.hh:49
const BorderList & borderList() const
Definition: elementborderlistfromgrid.hh:243
const BlackList & blackList() const
Definition: elementborderlistfromgrid.hh:247
ElementBorderListFromGrid(const GridView &gridView, const ElementMapper &map)
Definition: elementborderlistfromgrid.hh:221
unsigned ProcessRank
The type of the rank of a process.
Definition: overlaptypes.hh:49
int Index
The type of an index of a degree of freedom.
Definition: overlaptypes.hh:44
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:120
Definition: blackoilboundaryratevector.hh:37
This files provides several data structures for storing tuples of indices of remote and/or local proc...
Definition: blacklist.hh:51
Index myOwnNativeIndex
Definition: blacklist.hh:53
Index nativeIndexOfPeer
Definition: blacklist.hh:52
A single index intersecting with the process boundary.
Definition: overlaptypes.hh:102
Index localIdx
Index of the entity for the local process.
Definition: overlaptypes.hh:104
BorderDistance borderDistance
Distance to the process border for the peer (in hops)
Definition: overlaptypes.hh:113
ProcessRank peerRank
Rank of the peer process.
Definition: overlaptypes.hh:110
Index peerIdx
Index of the entity for the peer process.
Definition: overlaptypes.hh:107