Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions opm/grid/GraphOfGridWrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
#include "GraphOfGridWrappers.hpp"
#include <opm/grid/common/CommunicationUtils.hpp>
#include <opm/grid/common/ZoltanPartition.hpp> // function scatterExportInformation
#if HAVE_ZOLTAN
#include <opm/grid/common/ZoltanGraphFunctions.hpp> // makeImportAndExportLists when allowDistributedWells==true
#endif

namespace Opm {

#if HAVE_MPI
#if HAVE_MPI && HAVE_ZOLTAN
int getGraphOfGridNumVertices(void* pGraph, int *err)
{
const GraphOfGrid<Dune::CpGrid>& gog = *static_cast<const GraphOfGrid<Dune::CpGrid>*>(pGraph);
Expand Down Expand Up @@ -152,7 +154,7 @@ void setGraphOfGridZoltanGraphFunctions(Zoltan_Struct *zz,
Zoltan_Set_Edge_List_Multi_Fn(zz, getGraphOfGridEdgeList, pGraph);
}
}
#endif // HAVE_MPI
#endif // HAVE_MPI && HAVE_ZOLTAN

void addFutureConnectionWells(GraphOfGrid<Dune::CpGrid>& gog,
const std::unordered_map<std::string, std::set<int>>& wells,
Expand Down Expand Up @@ -491,6 +493,7 @@ makeImportAndExportLists(const GraphOfGrid<Dune::CpGrid>& gog,
std::move(myImportList) );
}

#if HAVE_ZOLTAN
namespace {
void setDefaultZoltanParameters(Zoltan_Struct* zz)
{
Expand Down Expand Up @@ -653,6 +656,7 @@ zoltanPartitioningWithGraphOfGrid(const Dune::CpGrid& grid,

return importExportLists;
}
#endif // HAVE_ZOLTAN

std::vector<std::vector<int> >
makeExportListsFromGIDtoRank(const std::vector<int>& gIDtoRank, int ccsize)
Expand All @@ -669,6 +673,7 @@ makeExportListsFromGIDtoRank(const std::vector<int>& gIDtoRank, int ccsize)
return exportedCells;
}

#if HAVE_ZOLTAN
namespace {
std::tuple<int, std::vector<int>>
applySerialZoltan (const Dune::CpGrid& grid,
Expand Down Expand Up @@ -849,6 +854,7 @@ zoltanSerialPartitioningWithGraphOfGrid(const Dune::CpGrid& grid,
std::move(myImportList),
std::move(wellConnections));
}
#endif // HAVE_ZOLTAN
#endif // HAVE_MPI

// explicit template instantiations
Expand Down
10 changes: 8 additions & 2 deletions opm/grid/GraphOfGridWrappers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@

#include <opm/grid/GraphOfGrid.hpp>
#include <opm/grid/common/WellConnections.hpp>
#if HAVE_ZOLTAN
#include <opm/grid/common/ZoltanGraphFunctions.hpp> // defines Zoltan and null-callback-functions
#endif

namespace Opm {
/*
Expand All @@ -40,7 +42,7 @@ namespace Opm {
Additionally, parsing wells is done here.
*/

#if HAVE_MPI
#if HAVE_MPI && HAVE_ZOLTAN
/// \brief callback function for ZOLTAN_NUM_OBJ_FN
///
/// returns the number of vertices in the graph
Expand Down Expand Up @@ -97,7 +99,7 @@ template<typename Zoltan_Struct>
void setGraphOfGridZoltanGraphFunctions(Zoltan_Struct *zz,
GraphOfGrid<Dune::CpGrid>& gog,
bool pretendNull);
#endif
#endif // HAVE_MPI && HAVE_ZOLTAN

/// \brief Adds well to the GraphOfGrid
///
Expand Down Expand Up @@ -217,6 +219,7 @@ wellsOnThisRank(const std::vector<Dune::cpgrid::OpmWellType>& wells,
const Dune::cpgrid::CpGridDataTraits::Communication& cc,
int root);

#if HAVE_ZOLTAN
/// \brief Transform Zoltan output into tuples
///
/// \param gog GraphOfGrid, has ref. to CpGrid and knows how well-cells were contracted
Expand Down Expand Up @@ -273,6 +276,7 @@ zoltanPartitioningWithGraphOfGrid(const Dune::CpGrid& grid,
bool allowDistributedWells,
const std::map<std::string,std::string>& params,
int level);
#endif // HAVE_ZOLTAN

/// \brief Make complete export lists from a vector holding destination rank for each global ID
///
Expand All @@ -284,6 +288,7 @@ zoltanPartitioningWithGraphOfGrid(const Dune::CpGrid& grid,
std::vector<std::vector<int> >
makeExportListsFromGIDtoRank(const std::vector<int>& gIDtoRank, int ccsize);

#if HAVE_ZOLTAN
/// \brief Call serial Zoltan partitioner on GraphOfGrid
///
/// GraphOfGrid represents a well by one vertex, so wells can not be
Expand All @@ -302,6 +307,7 @@ zoltanSerialPartitioningWithGraphOfGrid(const Dune::CpGrid& grid,
const double zoltanImbalanceTol,
bool allowDistributedWells,
const std::map<std::string,std::string>& params);
#endif // HAVE_ZOLTAN
#endif // HAVE_MPI

} // end namespace Opm
Expand Down
27 changes: 24 additions & 3 deletions opm/grid/common/ZoltanGraphFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
#endif
#include <limits>


#if defined(HAVE_ZOLTAN) && defined(HAVE_MPI)
#include <opm/grid/utility/OpmWellType.hpp>

#include <opm/grid/common/ZoltanGraphFunctions.hpp>

#if defined(HAVE_ZOLTAN) && defined(HAVE_MPI)
#include <dune/common/parallel/indexset.hh>

namespace Dune
Expand Down Expand Up @@ -340,6 +339,18 @@ void getCpGridWellsEdgeList(void *graphPointer, int sizeGID, int sizeLID,
#endif
}

} // end namespace cpgrid
} // end namespace Dune
#endif // defined(HAVE_ZOLTAN) && defined(HAVE_MPI)

// CombinedGridWellGraph is used by non-Zoltan partitioners too (e.g. vanilla),
// so its implementation must be available even without Zoltan.
#if HAVE_MPI
namespace Dune
{
namespace cpgrid
{

CombinedGridWellGraph::CombinedGridWellGraph(const CpGrid& grid,
const std::vector<OpmWellType> * wells,
const std::unordered_map<std::string, std::set<int>>& possibleFutureConnections,
Expand Down Expand Up @@ -370,6 +381,16 @@ CombinedGridWellGraph::CombinedGridWellGraph(const CpGrid& grid,
findMaxMinTrans();
}

} // end namespace cpgrid
} // end namespace Dune
#endif // HAVE_MPI

#if defined(HAVE_ZOLTAN) && defined(HAVE_MPI)
namespace Dune
{
namespace cpgrid
{

void setCpGridZoltanGraphFunctions(Zoltan_Struct *zz, const Dune::CpGrid& grid,
bool pretendNull)
{
Expand Down
8 changes: 4 additions & 4 deletions tests/test_graphofgrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ BOOST_AUTO_TEST_CASE(SimpleGraphWithInactiveCells)
}
#endif

#if HAVE_MPI
#if HAVE_MPI && HAVE_ZOLTAN
BOOST_AUTO_TEST_CASE(WrapperForZoltan)
{
Dune::CpGrid grid;
Expand Down Expand Up @@ -535,7 +535,7 @@ BOOST_AUTO_TEST_CASE(IntersectingWells)
BOOST_REQUIRE( *wellList.rbegin()==well1 );
}
}
#endif // HAVE_MPI
#endif // HAVE_MPI && HAVE_ZOLTAN

BOOST_AUTO_TEST_CASE(WellWithBuffers)
{
Expand Down Expand Up @@ -665,7 +665,7 @@ namespace {
} // end anonymous namespace
#endif

#if HAVE_MPI && HAVE_OPM_COMMON
#if HAVE_MPI && HAVE_OPM_COMMON && HAVE_ZOLTAN
// Create yet another small grid with wells and test graph properties.
// This time wells are supplied via OpmWellType interface
BOOST_AUTO_TEST_CASE(addWellConnections)
Expand Down Expand Up @@ -774,7 +774,7 @@ BOOST_AUTO_TEST_CASE(addWellConnections)
}

}
#endif // HAVE_MPI && HAVE_OPM_COMMON
#endif // HAVE_MPI && HAVE_OPM_COMMON && HAVE_ZOLTAN

#if HAVE_OPM_COMMON
BOOST_AUTO_TEST_CASE(gIDtoRankCorrection)
Expand Down