All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vertexborderlistfromgrid.hh
Go to the documentation of this file.
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 /*
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 2 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 
19  Consult the COPYING file in the top-level source directory of this
20  module for the precise wording of the license and the list of
21  copyright holders.
22 */
27 #ifndef EWOMS_VERTEX_BORDER_LIST_FROM_GRID_HH
28 #define EWOMS_VERTEX_BORDER_LIST_FROM_GRID_HH
29 
30 #include "overlaptypes.hh"
31 #include "blacklist.hh"
32 
33 #include <opm/common/Unused.hpp>
34 
35 #include <dune/grid/common/datahandleif.hh>
36 #include <dune/grid/common/gridenums.hh>
37 #include <dune/istl/bcrsmatrix.hh>
38 #include <dune/istl/scalarproducts.hh>
39 #include <dune/istl/operators.hh>
40 #include <dune/common/version.hh>
41 
42 #include <algorithm>
43 
44 namespace Ewoms {
45 namespace Linear {
55 template <class GridView, class VertexMapper>
57  : public Dune::CommDataHandleIF<VertexBorderListFromGrid<GridView, VertexMapper>,
58  int>
59 {
60  static const int dimWorld = GridView::dimensionworld;
61 
62 public:
63  VertexBorderListFromGrid(const GridView& gridView, const VertexMapper& map)
64  : gridView_(gridView), map_(map)
65  {
66  gridView.communicate(*this,
67  Dune::InteriorBorder_InteriorBorder_Interface,
68  Dune::ForwardCommunication);
69 
70  auto vIt = gridView.template begin<dimWorld>();
71  const auto& vEndIt = gridView.template end<dimWorld >();
72  for (; vIt != vEndIt; ++vIt) {
73  if (vIt->partitionType() != Dune::InteriorEntity
74  && vIt->partitionType() != Dune::BorderEntity)
75  {
76  Index vIdx = static_cast<Index>(map_.index(*vIt));
77  blackList_.addIndex(vIdx);
78  }
79  }
80  }
81 
82  // data handle methods
83  bool contains(int dim, int codim) const
84  { return dim == codim; }
85 
86  bool fixedsize(int dim OPM_UNUSED, int codim OPM_UNUSED) const
87  { return true; }
88 
89  template <class EntityType>
90  size_t size(const EntityType& e OPM_UNUSED) const
91  { return 2; }
92 
93  template <class MessageBufferImp, class EntityType>
94  void gather(MessageBufferImp& buff, const EntityType& e) const
95  {
96  buff.write(static_cast<int>(gridView_.comm().rank()));
97  buff.write(static_cast<int>(map_.index(e)));
98  }
99 
100  template <class MessageBufferImp, class EntityType>
101  void scatter(MessageBufferImp& buff, const EntityType& e, size_t n OPM_UNUSED)
102  {
103  BorderIndex bIdx;
104 
105  bIdx.localIdx = static_cast<Index>(map_.index(e));
106  {
107  int tmp;
108  buff.read(tmp);
109  bIdx.peerRank = static_cast<ProcessRank>(tmp);
110  }
111  {
112  int tmp;
113  buff.read(tmp);
114  bIdx.peerIdx = static_cast<Index>(tmp);
115  }
116  bIdx.borderDistance = 0;
117 
118  borderList_.push_back(bIdx);
119  }
120 
121  // Access to the border list.
122  const BorderList& borderList() const
123  { return borderList_; }
124 
125  // Access to the black-list indices.
126  const BlackList& blackList() const
127  { return blackList_; }
128 
129 private:
130  const GridView gridView_;
131  const VertexMapper& map_;
132  BorderList borderList_;
133  BlackList blackList_;
134 };
135 
136 } // namespace Linear
137 } // namespace Ewoms
138 
139 #endif
Expresses which degrees of freedom are blacklisted for the parallel linear solvers and which domestic...
Index peerIdx
Index of the entity for the peer process.
Definition: overlaptypes.hh:107
Index localIdx
Index of the entity for the local process.
Definition: overlaptypes.hh:104
Expresses which degrees of freedom are blacklisted for the parallel linear solvers and which domestic...
Definition: blacklist.hh:47
ProcessRank peerRank
Rank of the peer process.
Definition: overlaptypes.hh:110
This files provides several data structures for storing tuples of indices of remote and/or local proc...
BorderDistance borderDistance
Distance to the process border for the peer (in hops)
Definition: overlaptypes.hh:113
Uses communication on the grid to find the initial seed list of indices.
Definition: vertexborderlistfromgrid.hh:56
A single index intersecting with the process boundary.
Definition: overlaptypes.hh:101