diff --git a/opm/simulators/flow/GenericOutputBlackoilModule.cpp b/opm/simulators/flow/GenericOutputBlackoilModule.cpp index 82f41af7f7..5a69c1872d 100644 --- a/opm/simulators/flow/GenericOutputBlackoilModule.cpp +++ b/opm/simulators/flow/GenericOutputBlackoilModule.cpp @@ -980,7 +980,7 @@ int GenericOutputBlackoilModule:: regionMax(const std::vector& region, const Parallel::Communication& comm) { - const auto max_value = region.empty() ? 0 : *std::max_element(region.begin(), region.end()); + const auto max_value = region.empty() ? 0 : *std::ranges::max_element(region); return comm.max(max_value); } diff --git a/opm/simulators/flow/InterRegFlows.cpp b/opm/simulators/flow/InterRegFlows.cpp index 32218fe791..e383ca2340 100644 --- a/opm/simulators/flow/InterRegFlows.cpp +++ b/opm/simulators/flow/InterRegFlows.cpp @@ -34,7 +34,7 @@ InterRegFlowMapSingleFIP(const std::vector& region) { if (! region.empty()) { this->maxLocalRegionID_= this->maxGlobalRegionID_ = - *std::max_element(region.begin(), region.end()); + *std::ranges::max_element(region); } std::ranges::transform(region, this->region_.begin(), diff --git a/opm/simulators/flow/RegionPhasePVAverage.cpp b/opm/simulators/flow/RegionPhasePVAverage.cpp index 990c5f5009..356be125ca 100644 --- a/opm/simulators/flow/RegionPhasePVAverage.cpp +++ b/opm/simulators/flow/RegionPhasePVAverage.cpp @@ -58,7 +58,7 @@ namespace { for (auto rset = 0*nset; rset < nset; ++rset) { const auto& reg = getRegionArray(regionNames[rset]); - auto m = std::max_element(reg.begin(), reg.end()); + const auto m = std::ranges::max_element(reg); if (m == reg.end()) { // reg.empty() continue; } diff --git a/opm/simulators/linalg/getQuasiImpesWeights.hpp b/opm/simulators/linalg/getQuasiImpesWeights.hpp index 66b0778b55..786faf1d50 100644 --- a/opm/simulators/linalg/getQuasiImpesWeights.hpp +++ b/opm/simulators/linalg/getQuasiImpesWeights.hpp @@ -98,8 +98,10 @@ namespace Amg diag_block_transpose.solve(bweights, rhs); } - double abs_max = *std::max_element( - bweights.begin(), bweights.end(), [](double a, double b) { return std::fabs(a) < std::fabs(b); }); + const double abs_max = + *std::ranges::max_element(bweights, + [](double a, double b) + { return std::fabs(a) < std::fabs(b); }); bweights /= std::fabs(abs_max); weights[row_idx] = bweights; } @@ -208,8 +210,10 @@ namespace Amg } block_transpose.solve(bweights, rhs); - double abs_max = *std::max_element( - bweights.begin(), bweights.end(), [](double a, double b) { return std::fabs(a) < std::fabs(b); }); + const double abs_max = + *std::ranges::max_element(bweights, + [](double a, double b) + { return std::fabs(a) < std::fabs(b); }); // probably a scaling which could give approximately total compressibility would be better bweights /= std::fabs(abs_max); // given normal densities this scales weights to about 1. diff --git a/opm/simulators/timestepping/AdaptiveSimulatorTimer.cpp b/opm/simulators/timestepping/AdaptiveSimulatorTimer.cpp index faaf9a52e3..428e953894 100644 --- a/opm/simulators/timestepping/AdaptiveSimulatorTimer.cpp +++ b/opm/simulators/timestepping/AdaptiveSimulatorTimer.cpp @@ -150,8 +150,8 @@ namespace Opm /// \brief return max step length used so far double AdaptiveSimulatorTimer::maxStepLength () const { - if( steps_.empty() ) return 0.0; - return *(std::max_element( steps_.begin(), steps_.end() )); + if (steps_.empty()) return 0.0; + return *std::ranges::max_element(steps_); } /// \brief return min step length used so far diff --git a/opm/simulators/wells/ParallelPAvgDynamicSourceData.cpp b/opm/simulators/wells/ParallelPAvgDynamicSourceData.cpp index 1f9e14bfcb..cebca774f8 100644 --- a/opm/simulators/wells/ParallelPAvgDynamicSourceData.cpp +++ b/opm/simulators/wells/ParallelPAvgDynamicSourceData.cpp @@ -157,7 +157,7 @@ void Opm::ParallelPAvgDynamicSourceData::defineCommunication() // permutation of 0..allIndices.size()-1 and the maximum source // location may exceed size()-1. Resize the storageIndex_ according // to the largest source location ID. - if (auto maxIxPos = std::max_element(allIndices.begin(), allIndices.end()); + if (const auto maxIxPos = std::ranges::max_element(allIndices); maxIxPos != allIndices.end()) { // +1 for zero-based indices. diff --git a/tests/test_tuning_TRGMBE.cpp b/tests/test_tuning_TRGMBE.cpp index 68e8324d47..90abe55478 100644 --- a/tests/test_tuning_TRGMBE.cpp +++ b/tests/test_tuning_TRGMBE.cpp @@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE(CheckMassBalanceWithinTRGMBE) auto mbw = data["MB_Water"]; auto mbg = data["MB_Gas"]; - const int num_reports = 1 + *std::max_element(rstep.begin(), rstep.end()); + const int num_reports = 1 + *std::ranges::max_element(rstep); std::vector max_mb; max_mb.reserve(num_reports);