opm-grid
GridPartitioning.hpp
1 //===========================================================================
2 //
3 // File: GridPartitioning.hpp
4 //
5 // Created: Mon Sep 7 10:09:13 2009
6 //
7 // Author(s): Atgeirr F Rasmussen <atgeirr@sintef.no>
8 // Bård Skaflestad <bard.skaflestad@sintef.no>
9 //
10 // $Date$
11 //
12 // $Revision$
13 //
14 //===========================================================================
15 
16 /*
17  Copyright 2009, 2010, 2013 SINTEF ICT, Applied Mathematics.
18  Copyright 2009, 2010 Statoil ASA.
19  Copyright 2013, 2025 Dr. Markus Blatt - HPC-Simulation-Software & Services
20  Copyright 2020, 2021 OPM-OP AS
21 
22  This file is part of The Open Porous Media project (OPM).
23 
24  OPM is free software: you can redistribute it and/or modify
25  it under the terms of the GNU General Public License as published by
26  the Free Software Foundation, either version 3 of the License, or
27  (at your option) any later version.
28 
29  OPM is distributed in the hope that it will be useful,
30  but WITHOUT ANY WARRANTY; without even the implied warranty of
31  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32  GNU General Public License for more details.
33 
34  You should have received a copy of the GNU General Public License
35  along with OPM. If not, see <http://www.gnu.org/licenses/>.
36 */
37 
38 #ifndef OPM_GRIDPARTITIONING_HEADER
39 #define OPM_GRIDPARTITIONING_HEADER
40 
41 #include <vector>
42 #include <array>
43 #include <set>
44 #include <tuple>
45 
46 #include <dune/common/parallel/mpihelper.hh>
47 
48 #include <opm/grid/utility/OpmWellType.hpp>
49 #include <opm/grid/common/WellConnections.hpp>
50 #include <opm/grid/common/ZoltanGraphFunctions.hpp>
51 
52 namespace Dune
53 {
54 
55  class CpGrid;
56 
57  struct OrderByFirst
58  {
59  bool operator()(const std::pair<int,int>& o, const std::pair<int,int>& v)
60  {
61  return o.first < v.first;
62  }
63  };
64 
75  void partition(const CpGrid& grid,
76  const std::array<int, 3>& initial_split,
77  int& num_part,
78  std::vector<int>& cell_part,
79  bool recursive = false,
80  bool ensureConnectivity = true);
81 
92  void addOverlapLayer(const CpGrid& grid,
93  const std::vector<int>& cell_part,
94  std::vector<std::set<int> >& cell_overlap,
95  int mypart,
96  int overlapLayers,
97  bool all=false,
98  int level = -1);
99 
114  int addOverlapLayer(const CpGrid& grid,
115  const std::vector<int>& cell_part,
116  std::vector<std::tuple<int,int,char>>& exportList,
117  std::vector<std::tuple<int,int,char,int>>& importList,
118  const Communication<Dune::MPIHelper::MPICommunicator>& cc,
119  bool addCornerCells,
120  const double* trans,
121  bool useTransToFilterOverlap = true,
122  int layers = 1,
123  int level = -1);
124 
125 namespace cpgrid
126 {
127 #if HAVE_MPI
128  std::tuple<std::vector<int>, std::vector<std::pair<std::string,bool>>,
153  std::vector<std::tuple<int,int,char> >,
154  std::vector<std::tuple<int,int,char,int> >,
155  WellConnections>
156  createListsFromParts(const CpGrid& grid,
157  const std::vector<cpgrid::OpmWellType> * wells,
158  const std::unordered_map<std::string, std::set<int>>& possibleFutureConnections,
159  const double* transmissibilities,
160  const std::vector<int>& parts,
161  bool allowDistributedWells,
162  std::shared_ptr<cpgrid::CombinedGridWellGraph> gridAndWells = nullptr,
163  int level = -1);
164 
185  std::tuple<std::vector<int>, std::vector<std::pair<std::string,bool>>,
186  std::vector<std::tuple<int,int,char> >,
187  std::vector<std::tuple<int,int,char,int> >,
188  WellConnections>
189  vanillaPartitionGridOnRoot(const CpGrid& grid,
190  const std::vector<cpgrid::OpmWellType> * wells,
191  const std::unordered_map<std::string, std::set<int>>& possibleFutureConnections,
192  const double* transmissibilities,
193  bool allowDistributedWells);
194 #endif
195 } // namespace cpgrid
196 } // namespace Dune
197 
198 
199 #endif // OPM_GRIDPARTITIONING_HEADER
Definition: GridPartitioning.hpp:57
The namespace Dune is the main namespace for all Dune code.
Definition: CartesianIndexMapper.hpp:9
[ provides Dune::Grid ]
Definition: CpGrid.hpp:201
void partition(const CpGrid &grid, const coord_t &initial_split, int &num_part, std::vector< int > &cell_part, bool recursive, bool ensureConnectivity)
Partition a CpGrid based on (ijk) coordinates, with splitting to ensure that each partition is connec...
Definition: GridPartitioning.cpp:198