Loading...
Searching...
No Matches
GraphOfGridWrappers.hpp
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
Copyright 2024 Equinor ASA.
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/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
#ifndef GRAPH_OF_GRID_WRAPPERS_HEADER
#define GRAPH_OF_GRID_WRAPPERS_HEADER
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/grid/GraphOfGrid.hpp>
#include <opm/grid/common/WellConnections.hpp>
#include <opm/grid/common/ZoltanGraphFunctions.hpp> // defines Zoltan and null-callback-functions
namespace Opm {
/*
This file contains wrappers for GraphOfGrid that satisfy interface
requirements of graph partitioners like Zoltan and (TODO!) Metis.
Additionally, parsing wells is done here.
*/
#if HAVE_MPI
int getGraphOfGridNumVertices(void* pGraph, int *err);
void getGraphOfGridVerticesList(void* pGraph,
[[maybe_unused]] int dimGlobalID,
[[maybe_unused]] int dimLocalID,
ZOLTAN_ID_PTR gIDs,
[[maybe_unused]] ZOLTAN_ID_PTR lIDs,
int weightDim,
float *objWeights,
int *err);
void getGraphOfGridNumEdges(void *pGraph,
[[maybe_unused]] int dimGlobalID,
[[maybe_unused]] int dimLocalID,
int numCells,
ZOLTAN_ID_PTR gIDs,
[[maybe_unused]] ZOLTAN_ID_PTR lIDs,
int *numEdges,
int *err);
void getGraphOfGridEdgeList(void *pGraph,
[[maybe_unused]] int dimGlobalID,
[[maybe_unused]] int dimLocalID,
int numCells,
ZOLTAN_ID_PTR gIDs,
[[maybe_unused]] ZOLTAN_ID_PTR lIDs,
int *numEdges,
ZOLTAN_ID_PTR nborGIDs,
int *nborProc,
int weightDim,
float *edgeWeights,
int *err);
template<typename Zoltan_Struct>
void setGraphOfGridZoltanGraphFunctions(Zoltan_Struct *zz,
GraphOfGrid<Dune::CpGrid>& gog,
bool pretendNull);
#endif
void addFutureConnectionWells(GraphOfGrid<Dune::CpGrid>& gog,
const std::unordered_map<std::string, std::set<int>>& wells,
bool checkWellIntersections=true);
void addWellConnections(GraphOfGrid<Dune::CpGrid>& gog,
const Dune::cpgrid::WellConnections& wells,
bool checkWellIntersections=true);
void extendGIDtoRank(const GraphOfGrid<Dune::CpGrid>& gog,
std::vector<int>& gIDtoRank,
const int& root = -1);
#if HAVE_MPI
namespace Impl{
void extendAndSortImportList(std::vector<std::tuple<int,int,char,int>>& importList,
const std::vector<int>& extraCells);
std::vector<std::vector<int>>
extendRootExportList(const GraphOfGrid<Dune::CpGrid>& gog,
std::vector<std::tuple<int,int,char>>& exportList,
int root,
const std::vector<int>& gIDtoRank);
std::vector<int> communicateExportedCells(const std::vector<std::vector<int>>& exportedCells,
const Dune::cpgrid::CpGridDataTraits::Communication& cc,
int root);
} // end namespace Impl
void extendAndSortExportAndImportLists(const GraphOfGrid<Dune::CpGrid>& gog,
const Dune::cpgrid::CpGridDataTraits::Communication& cc,
int root,
std::vector<std::tuple<int, int, char>>& exportList,
std::vector<std::tuple<int, int, char, int>>& importList,
const std::vector<int>& gIDtoRank = {});
#endif // HAVE_MPI
std::vector<int> getWellRanks(const std::vector<int>& gIDtoRank,
const Dune::cpgrid::WellConnections& wellConnections);
#if HAVE_MPI
std::vector<std::pair<std::string, bool>>
wellsOnThisRank(const std::vector<Dune::cpgrid::OpmWellType>& wells,
const std::vector<int>& wellRanks,
const Dune::cpgrid::CpGridDataTraits::Communication& cc,
int root);
template<class Id>
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> > >
makeImportAndExportLists(const GraphOfGrid<Dune::CpGrid>& gog,
const Dune::Communication<MPI_Comm>& cc,
const std::vector<Dune::cpgrid::OpmWellType> * wells,
const Dune::cpgrid::WellConnections& wellConnections,
int root,
int numExport,
int numImport,
[[maybe_unused]] const Id* exportLocalGids,
const Id* exportGlobalGids,
const int* exportToPart,
const Id* importGlobalGids,
int level);
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> >,
Dune::cpgrid::WellConnections>
zoltanPartitioningWithGraphOfGrid(const Dune::CpGrid& grid,
const std::vector<Dune::cpgrid::OpmWellType> * wells,
const std::unordered_map<std::string, std::set<int>>& possibleFutureConnections,
const double* transmissibilities,
const Dune::cpgrid::CpGridDataTraits::Communication& cc,
Dune::EdgeWeightMethod edgeWeightMethod,
int root,
const double zoltanImbalanceTol,
bool allowDistributedWells,
const std::map<std::string,std::string>& params,
int level);
std::vector<std::vector<int> >
makeExportListsFromGIDtoRank(const std::vector<int>& gIDtoRank, int ccsize);
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> >,
Dune::cpgrid::WellConnections>
zoltanSerialPartitioningWithGraphOfGrid(const Dune::CpGrid& grid,
const std::vector<Dune::cpgrid::OpmWellType> * wells,
const std::unordered_map<std::string, std::set<int>>& possibleFutureConnections,
const double* transmissibilities,
const Dune::cpgrid::CpGridDataTraits::Communication& cc,
Dune::EdgeWeightMethod edgeWeightMethod,
int root,
const double zoltanImbalanceTol,
bool allowDistributedWells,
const std::map<std::string,std::string>& params);
#endif // HAVE_MPI
} // end namespace Opm
#endif // GRAPH_OF_GRID_WRAPPERS_HEADER
Opm::GraphOfGrid
A class storing a graph representation of the grid.
Definition GraphOfGrid.hpp:43
Dune::EdgeWeightMethod
EdgeWeightMethod
enum for choosing Methods for weighting graph-edges correspoding to cell interfaces in Zoltan's or Me...
Definition GridEnums.hpp:34
Opm
Holds the implementation of the CpGrid as a pimple.
Definition CellQuadrature.cpp:68
Opm::getWellRanks
std::vector< int > getWellRanks(const std::vector< int > &gIDtoRank, const Dune::cpgrid::WellConnections &wellConnections)
Find to which ranks wells were assigned.
Definition GraphOfGridWrappers.cpp:377
Opm::addWellConnections
void addWellConnections(GraphOfGrid< Dune::CpGrid > &gog, const Dune::cpgrid::WellConnections &wells, bool checkWellIntersections)
Add WellConnections to the GraphOfGrid.
Definition GraphOfGridWrappers.cpp:183
Opm::addFutureConnectionWells
void addFutureConnectionWells(GraphOfGrid< Dune::CpGrid > &gog, const std::unordered_map< std::string, std::set< int > > &wells, bool checkWellIntersections)
Adds well to the GraphOfGrid.
Definition GraphOfGridWrappers.cpp:157
Opm::extendGIDtoRank
void extendGIDtoRank(const GraphOfGrid< Dune::CpGrid > &gog, std::vector< int > &gIDtoRank, const int &root)
Correct gIDtoRank's data about well cells.
Definition GraphOfGridWrappers.cpp:193