diff --git a/opm/core/linalg/ParallelIstlInformation.hpp b/opm/core/linalg/ParallelIstlInformation.hpp index d7f9d383..03c87333 100644 --- a/opm/core/linalg/ParallelIstlInformation.hpp +++ b/opm/core/linalg/ParallelIstlInformation.hpp @@ -481,7 +481,7 @@ private: // for integral types. if( std::is_integral::value ) { - return -std::numeric_limits::min(); + return std::numeric_limits::min(); } else { diff --git a/tests/test_parallelistlinformation.cpp b/tests/test_parallelistlinformation.cpp index 7a4f6f28..762dad4e 100644 --- a/tests/test_parallelistlinformation.cpp +++ b/tests/test_parallelistlinformation.cpp @@ -38,23 +38,24 @@ #include #ifdef HAVE_DUNE_ISTL -void runSumMaxMinTest(const int offset) +template +void runSumMaxMinTest(const T offset) { const int N=100; int start, end, istart, iend; std::tie(start,istart,iend,end) = computeRegions(N); Opm::ParallelISTLInformation comm(MPI_COMM_WORLD); auto mat = create1DLaplacian(*comm.indexSet(), N, start, end, istart, iend); - std::vector x(end-start); + std::vector x(end-start); assert(comm.indexSet()->size()==x.size()); for(auto i=comm.indexSet()->begin(), iend=comm.indexSet()->end(); i!=iend; ++i) x[i->local()]=i->global()+offset; auto containers = std::make_tuple(x, x, x, x); - auto operators = std::make_tuple(Opm::Reduction::makeGlobalSumFunctor(), - Opm::Reduction::makeGlobalMaxFunctor(), - Opm::Reduction::makeGlobalMinFunctor(), - Opm::Reduction::makeInnerProductFunctor()); - auto values = std::make_tuple(0,0,100000, 0); + auto operators = std::make_tuple(Opm::Reduction::makeGlobalSumFunctor(), + Opm::Reduction::makeGlobalMaxFunctor(), + Opm::Reduction::makeGlobalMinFunctor(), + Opm::Reduction::makeInnerProductFunctor()); + auto values = std::tuple(0,0,100000, 0); auto oldvalues = values; start = offset; end = start+N; @@ -65,12 +66,25 @@ void runSumMaxMinTest(const int offset) BOOST_CHECK(std::get<3>(values)==((end-1)*end*(2*end-1)-(start-1)*start*(2*start-1))/6+std::get<3>(oldvalues)); } -BOOST_AUTO_TEST_CASE(tupleReductionTest) +BOOST_AUTO_TEST_CASE(tupleReductionTestInt) { - runSumMaxMinTest(0); - runSumMaxMinTest(20); - runSumMaxMinTest(-20); + runSumMaxMinTest(0); + runSumMaxMinTest(20); + runSumMaxMinTest(-20); } + +BOOST_AUTO_TEST_CASE(tupleReductionTestUnsignedInt) +{ + runSumMaxMinTest(0); + runSumMaxMinTest(20); +} +BOOST_AUTO_TEST_CASE(tupleReductionTestFloat) +{ + runSumMaxMinTest(0); + runSumMaxMinTest(20); + runSumMaxMinTest(-20); +} + BOOST_AUTO_TEST_CASE(singleContainerReductionTest) { int N=100;