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> 47 template <
class Gr
idView,
class ElementMapper>
51 using PeerBlackList = BlackList::PeerBlackList;
52 using PeerBlackLists = BlackList::PeerBlackLists;
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,
66 , blackList_(blackList)
67 , borderList_(borderList)
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 bool fixedSize(
int,
int)
const 84 template <
class EntityType>
85 size_t size(
const EntityType&)
const 88 template <
class MessageBufferImp,
class EntityType>
89 void gather(MessageBufferImp& buff,
const EntityType& e)
const 91 unsigned myIdx =
static_cast<unsigned>(map_.index(e));
92 buff.write(static_cast<unsigned>(gridView_.comm().rank()));
96 template <
class MessageBufferImp>
97 void scatter(MessageBufferImp& buff,
102 bool isInteriorNeighbor =
false;
103 auto isIt = gridView_.ibegin(e);
104 const auto& isEndIt = gridView_.iend(e);
105 for (; isIt != isEndIt; ++isIt) {
106 if (!isIt->neighbor())
108 else if (isIt->outside().partitionType() == Dune::InteriorEntity) {
109 isInteriorNeighbor =
true;
113 if (!isInteriorNeighbor)
123 peerSet_.insert(tmp);
132 borderList_.push_back(bIdx);
138 template <
class MessageBufferImp,
class EntityType>
139 void scatter(MessageBufferImp&,
144 const std::set<ProcessRank>& peerSet()
const 149 const ElementMapper& map_;
150 std::set<ProcessRank> peerSet_;
155 class PeerBlackListHandle_
156 :
public Dune::CommDataHandleIF<PeerBlackListHandle_, int>
159 PeerBlackListHandle_(
const GridView& gridView,
160 const ElementMapper& map,
161 PeerBlackLists& peerBlackLists)
162 : gridView_(gridView)
164 , peerBlackLists_(peerBlackLists)
168 bool contains(
int,
int codim)
const 169 {
return codim == 0; }
171 bool fixedSize(
int,
int)
const 174 template <
class EntityType>
175 size_t size(
const EntityType&)
const 178 template <
class MessageBufferImp,
class EntityType>
179 void gather(MessageBufferImp& buff,
const EntityType& e)
const 181 buff.write(static_cast<int>(gridView_.comm().rank()));
182 buff.write(static_cast<int>(map_.index(e)));
185 template <
class MessageBufferImp,
class EntityType>
186 void scatter(MessageBufferImp& buff,
const EntityType& e,
size_t)
194 localIdx =
static_cast<Index>(map_.index(e));
197 pIdx.nativeIndexOfPeer =
static_cast<Index>(peerIdx);
198 pIdx.myOwnNativeIndex =
static_cast<Index>(localIdx);
200 peerBlackLists_[
static_cast<ProcessRank>(peerRank)].push_back(pIdx);
203 const PeerBlackList& peerBlackList(
ProcessRank peerRank)
const 204 {
return peerBlackLists_.at(peerRank); }
208 const ElementMapper& map_;
209 PeerBlackLists peerBlackLists_;
214 : gridView_(gridView)
217 BorderListHandle_ blh(gridView, map, blackList_, borderList_);
218 gridView.communicate(blh,
219 Dune::InteriorBorder_All_Interface,
220 Dune::BackwardCommunication);
222 PeerBlackListHandle_ pblh(gridView, map, peerBlackLists_);
223 gridView.communicate(pblh,
224 Dune::InteriorBorder_All_Interface,
225 Dune::BackwardCommunication);
227 auto peerIt = blh.peerSet().begin();
228 const auto& peerEndIt = blh.peerSet().end();
229 for (; peerIt != peerEndIt; ++peerIt) {
230 blackList_.setPeerList(*peerIt, pblh.peerBlackList(*peerIt));
236 {
return borderList_; }
240 {
return blackList_; }
243 const GridView gridView_;
244 const ElementMapper& map_;
249 PeerBlackLists peerBlackLists_;
A single index intersecting with the process boundary.
Definition: overlaptypes.hh:101
Expresses which degrees of freedom are blacklisted for the parallel linear solvers and which domestic...
Structs needed for tpfalinearizer and its gpuparams struct extracted to be defined in one place that ...
Definition: blackoilbioeffectsmodules.hh:45
Uses communication on the grid to find the initial seed list of indices for methods which use element...
Definition: elementborderlistfromgrid.hh:48
Index peerIdx
Index of the entity for the peer process.
Definition: overlaptypes.hh:107
This files provides several data structures for storing tuples of indices of remote and/or local proc...
unsigned ProcessRank
The type of the rank of a process.
Definition: overlaptypes.hh:49
Expresses which degrees of freedom are blacklisted for the parallel linear solvers and which domestic...
Definition: blacklist.hh:48
Index localIdx
Index of the entity for the local process.
Definition: overlaptypes.hh:104
Definition: blacklist.hh:51
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
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
int Index
The type of an index of a degree of freedom.
Definition: overlaptypes.hh:44