MetisPartition.hpp
Go to the documentation of this file.
1/*
2 Copyright 2024 OPM-OP AS
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 3 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#ifndef DUNE_CPGRID_METISPARTITION_HEADER
20#define DUNE_CPGRID_METISPARTITION_HEADER
21
22#include <unordered_set>
23
24#include <opm/grid/CpGrid.hpp>
29
30// We want to use METIS, but if METIS is installed together with Scotch, then METIS uses some artifacts from Scotch.
31// For this type, we need to include scotch.h.
32#if IS_SCOTCH_METIS_HEADER
33extern "C" {
34 #include <scotch.h>
35}
36// And also, we need to set the version number here manually to 5
37#ifndef SCOTCH_METIS_VERSION
38#define SCOTCH_METIS_VERSION 5
39#endif /* SCOTCH_METIS_VERSION */
40#endif
41
42#if defined(HAVE_METIS) && HAVE_MPI
43extern "C" {
44 #include <metis.h>
45}
46#endif // defined(HAVE_METIS) && HAVE_MPI
47
48#if defined(HAVE_METIS) && HAVE_MPI
49namespace Dune
50{
51namespace cpgrid
52{
53#if defined(REALTYPEWIDTH)
54 using real_t = ::real_t;
55#else
56 using real_t = double;
57#endif
58
59#if defined(IDXTYPEWIDTH)
60 using idx_t = ::idx_t;
61#elif IS_SCOTCH_METIS_HEADER
62 using idx_t = SCOTCH_Num;
63#else
64 using idx_t = int;
65#endif
66
67#if IS_SCOTCH_METIS_HEADER
68 // NOTE: scotchmetis does not define a return type for METIS functions
69 #define METIS_OK 1
70#endif
71
76
102
103std::tuple<std::vector<int>,
104 std::vector<std::pair<std::string, bool>>,
105 std::vector<std::tuple<int, int, char>>,
106 std::vector<std::tuple<int, int, char, int>>,
107 WellConnections>
108metisSerialGraphPartitionGridOnRoot(const CpGrid& grid,
109 const std::vector<OpmWellType> * wells,
110 const std::unordered_map<std::string, std::set<int>>& possibleFutureConnections,
111 const double* transmissibilities,
112 const Communication<MPI_Comm>& cc,
113 EdgeWeightMethod edgeWeightsMethod,
114 int root,
115 real_t imbalanceTol,
116 bool allowDistributedWells,
117 const std::map<std::string,std::string>& params);
118}
119}
120
121
122#endif // defined(HAVE_METIS) && HAVE_MPI
123#endif // header guard
The namespace Dune is the main namespace for all Dune code.
Definition: common/CartesianIndexMapper.hpp:10
EdgeWeightMethod
enum for choosing Methods for weighting graph-edges correspoding to cell interfaces in Zoltan's or Me...
Definition: GridEnums.hpp:34