refactored ParallelWellInfo test code for further testing.

This commit is contained in:
Markus Blatt 2020-12-14 16:12:01 +01:00
parent ba1feadb63
commit a9c327b321

View File

@ -222,18 +222,13 @@ BOOST_AUTO_TEST_CASE(CommunicateAboveBelowSelf1)
}
}
BOOST_AUTO_TEST_CASE(CommunicateAboveBelowParallel)
{
using MPIComm = typename Dune::MPIHelper::MPICommunicator;
#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 7)
using Communication = Dune::Communication<MPIComm>;
#else
using Communication = Dune::CollectiveCommunication<MPIComm>;
#endif
auto comm = Communication(Dune::MPIHelper::getCommunicator());
Opm::CommunicateAboveBelow commAboveBelow{ comm };
for(std::size_t count=0; count < 2; ++count)
std::vector<int> createGlobalEclIndex(const Communication& comm)
{
std::vector<int> globalEclIndex = {0, 1, 2, 3, 7 , 8, 10, 11};
auto oldSize = globalEclIndex.size();
@ -249,11 +244,15 @@ BOOST_AUTO_TEST_CASE(CommunicateAboveBelowParallel)
*entry = lastIndex;
}
}
return globalEclIndex;
}
std::vector<double> globalCurrent(globalEclIndex.size());
std::transform(globalEclIndex.begin(), globalEclIndex.end(), globalCurrent.begin(),
[](double v){ return 1+10.0*v;});
template<class C>
std::vector<double> populateCommAbove(C& commAboveBelow,
const Communication& comm,
const std::vector<int>& globalEclIndex,
const std::vector<double> globalCurrent)
{
std::vector<double> current(3);
commAboveBelow.beginReset();
@ -272,6 +271,22 @@ BOOST_AUTO_TEST_CASE(CommunicateAboveBelowParallel)
current[i] = globalCurrent[gi];
}
commAboveBelow.endReset();
return current;
}
BOOST_AUTO_TEST_CASE(CommunicateAboveBelowParallel)
{
auto comm = Communication(Dune::MPIHelper::getCommunicator());
Opm::CommunicateAboveBelow commAboveBelow{ comm };
for(std::size_t count=0; count < 2; ++count)
{
auto globalEclIndex = createGlobalEclIndex(comm);
std::vector<double> globalCurrent(globalEclIndex.size());
std::transform(globalEclIndex.begin(), globalEclIndex.end(), globalCurrent.begin(),
[](double v){ return 1+10.0*v;});
auto current = populateCommAbove(commAboveBelow, comm, globalEclIndex, globalCurrent);
auto above = commAboveBelow.communicateAbove(-10.0, current.data(), current.size());
if (comm.rank() == 0)
BOOST_CHECK(above[0]==-10.0);