Loading...
Searching...
No Matches
MetisPartition.hpp
/*
Copyright 2024 OPM-OP AS
This file is part of The Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DUNE_CPGRID_METISPARTITION_HEADER
#define DUNE_CPGRID_METISPARTITION_HEADER
#include <unordered_set>
#include <opm/grid/CpGrid.hpp>
#include <opm/grid/common/ZoltanGraphFunctions.hpp>
#include <opm/grid/common/WellConnections.hpp>
#include <opm/grid/common/ZoltanPartition.hpp>
#include <opm/grid/common/GridPartitioning.hpp>
// We want to use METIS, but if METIS is installed together with Scotch, then METIS uses some artifacts from Scotch.
// For this type, we need to include scotch.h.
#if IS_SCOTCH_METIS_HEADER
extern "C" {
#include <scotch.h>
}
// And also, we need to set the version number here manually to 5
#ifndef SCOTCH_METIS_VERSION
#define SCOTCH_METIS_VERSION 5
#endif /* SCOTCH_METIS_VERSION */
#endif
#if defined(HAVE_METIS) && HAVE_MPI
extern "C" {
#include <metis.h>
}
#endif // defined(HAVE_METIS) && HAVE_MPI
#if defined(HAVE_METIS) && HAVE_MPI
namespace Dune
{
namespace cpgrid
{
#if defined(REALTYPEWIDTH)
using real_t = ::real_t;
#else
using real_t = double;
#endif
#if defined(IDXTYPEWIDTH)
using idx_t = ::idx_t;
#elif IS_SCOTCH_METIS_HEADER
using idx_t = SCOTCH_Num;
#else
using idx_t = int;
#endif
#if IS_SCOTCH_METIS_HEADER
// NOTE: scotchmetis does not define a return type for METIS functions
#define METIS_OK 1
#endif
std::tuple<std::vector<int>,
std::vector<std::pair<std::string, bool>>,
std::vector<std::tuple<int, int, char>>,
std::vector<std::tuple<int, int, char, int>>,
WellConnections>
metisSerialGraphPartitionGridOnRoot(const CpGrid& grid,
const std::vector<OpmWellType> * wells,
const std::unordered_map<std::string, std::set<int>>& possibleFutureConnections,
const double* transmissibilities,
const Communication<MPI_Comm>& cc,
EdgeWeightMethod edgeWeightsMethod,
int root,
real_t imbalanceTol,
bool allowDistributedWells,
const std::map<std::string,std::string>& params);
}
}
#endif // defined(HAVE_METIS) && HAVE_MPI
#endif // header guard
Dune::cpgrid::WellConnections
A class calculating and representing all connections of wells.
Definition WellConnections.hpp:51
Dune::cpgrid
Copyright 2019 Equinor AS.
Definition GridPartitioning.cpp:673
Dune
The namespace Dune is the main namespace for all Dune code.
Definition CartesianIndexMapper.hpp:10
Dune::EdgeWeightMethod
EdgeWeightMethod
enum for choosing Methods for weighting graph-edges correspoding to cell interfaces in Zoltan's or Me...
Definition GridEnums.hpp:34