diff --git a/opm/simulators/linalg/bda/BdaBridge.cpp b/opm/simulators/linalg/bda/BdaBridge.cpp index 46a23fdd2..d88cae9b0 100644 --- a/opm/simulators/linalg/bda/BdaBridge.cpp +++ b/opm/simulators/linalg/bda/BdaBridge.cpp @@ -128,7 +128,7 @@ int checkZeroDiagonal(BridgeMatrix& mat) { int numZeros = 0; const int dim = 3; // might be replaced with mat[0][0].N() or BridgeMatrix::block_type::size() const double zero_replace = 1e-15; - if (diag_indices.size() == 0) { + if (diag_indices.empty()) { int N = mat.N(); diag_indices.reserve(N); for (typename BridgeMatrix::iterator r = mat.begin(); r != mat.end(); ++r) { @@ -169,7 +169,7 @@ void getSparsityPattern(BridgeMatrix& mat, std::vector &h_rows, std::vector int sum_nnzs = 0; // convert colIndices and rowPointers - if (h_rows.size() == 0) { + if (h_rows.empty()) { h_rows.emplace_back(0); for (typename BridgeMatrix::const_iterator r = mat.begin(); r != mat.end(); ++r) { int size_row = 0; diff --git a/opm/simulators/linalg/bda/Reorder.cpp b/opm/simulators/linalg/bda/Reorder.cpp index 13af74656..1834540c8 100644 --- a/opm/simulators/linalg/bda/Reorder.cpp +++ b/opm/simulators/linalg/bda/Reorder.cpp @@ -270,7 +270,7 @@ void findLevelScheduling(int *CSRColIndices, int *CSRRowPointers, int *CSCRowInd std::vector rowsToStart; // since emplace_back() is used to fill, the vector must be empty - assert(rowsPerColor.size() == 0); + assert(rowsPerColor.empty()); // find starting rows: rows that are independent from all rows that come before them. for (thisRow = 0; thisRow < Nb; thisRow++) { diff --git a/opm/simulators/linalg/bda/openclSolverBackend.cpp b/opm/simulators/linalg/bda/openclSolverBackend.cpp index e71f5c9c1..9d9fda463 100644 --- a/opm/simulators/linalg/bda/openclSolverBackend.cpp +++ b/opm/simulators/linalg/bda/openclSolverBackend.cpp @@ -49,7 +49,7 @@ openclSolverBackend::openclSolverBackend(int verbosity_, int maxit_, try { std::vector platforms; cl::Platform::get(&platforms); - if (platforms.size() == 0) { + if (platforms.empty()) { OPM_THROW(std::logic_error, "Error openclSolver is selected but no OpenCL platforms are found"); } out << "Found " << platforms.size() << " OpenCL platforms" << "\n"; @@ -89,7 +89,7 @@ openclSolverBackend::openclSolverBackend(int verbosity_, int maxit_, platforms[platformID].getDevices(CL_DEVICE_TYPE_ALL, &devices); - if (devices.size() == 0){ + if (devices.empty()) { OPM_THROW(std::logic_error, "Error openclSolver is selected but no OpenCL devices are found"); } out << "Found " << devices.size() << " OpenCL devices" << "\n"; diff --git a/opm/simulators/timestepping/AdaptiveSimulatorTimer.cpp b/opm/simulators/timestepping/AdaptiveSimulatorTimer.cpp index 13e06ea5c..d16fcaef2 100644 --- a/opm/simulators/timestepping/AdaptiveSimulatorTimer.cpp +++ b/opm/simulators/timestepping/AdaptiveSimulatorTimer.cpp @@ -137,14 +137,14 @@ AdaptiveSimulatorTimer& AdaptiveSimulatorTimer::operator++ () /// \brief return max step length used so far double AdaptiveSimulatorTimer::maxStepLength () const { - if( steps_.size() == 0 ) return 0.0; + if( steps_.empty() ) return 0.0; return *(std::max_element( steps_.begin(), steps_.end() )); } /// \brief return min step length used so far double AdaptiveSimulatorTimer::minStepLength () const { - if( steps_.size() == 0 ) return 0.0; + if( steps_.empty() ) return 0.0; return *(std::min_element( steps_.begin(), steps_.end() )); } diff --git a/opm/simulators/wells/GasLiftStage2.cpp b/opm/simulators/wells/GasLiftStage2.cpp index 6c7a147a4..78409fca9 100644 --- a/opm/simulators/wells/GasLiftStage2.cpp +++ b/opm/simulators/wells/GasLiftStage2.cpp @@ -705,11 +705,11 @@ GasLiftStage2:: removeSurplusALQ_(const Group &group, std::vector &inc_grads, std::vector &dec_grads) { - if (dec_grads.size() == 0) { + if (dec_grads.empty()) { displayDebugMessage2B_("no wells to remove ALQ from. Skipping"); return; } - assert(dec_grads.size() > 0); + assert(!dec_grads.empty()); const auto &gl_group = this->glo_.group(group.name()); const auto &max_glift = gl_group.max_lift_gas(); const auto controls = group.productionControls(this->summary_state_); @@ -760,7 +760,7 @@ removeSurplusALQ_(const Group &group, // NOTE: recalculateGradientAndUpdateData_() will remove the current gradient // from dec_grads if it cannot calculate a new decremental gradient. // This will invalidate dec_grad_itr and well_name - if (dec_grads.size() == 0) stop_iteration = true; + if (dec_grads.empty()) stop_iteration = true; ++state.it; } else { @@ -907,7 +907,7 @@ std::pair, GasLiftStage2::OptimizeState:: getEcoGradients(std::vector &inc_grads, std::vector &dec_grads) { - if (inc_grads.size() > 0 && dec_grads.size() > 0) { + if (!inc_grads.empty() && !dec_grads.empty()) { this->parent.sortGradients_(inc_grads); this->parent.sortGradients_(dec_grads); // The largest incremental gradient is the last element diff --git a/opm/simulators/wells/StandardWellEval.cpp b/opm/simulators/wells/StandardWellEval.cpp index 02ec45659..a7ac494ce 100644 --- a/opm/simulators/wells/StandardWellEval.cpp +++ b/opm/simulators/wells/StandardWellEval.cpp @@ -716,14 +716,14 @@ template void StandardWellEval:: updatePrimaryVariablesNewton(const BVectorWell& dwells, - const double dFLimit, + [[maybe_unused]] const double dFLimit, const double dBHPLimit) const { const std::vector old_primary_variables = primary_variables_; // for injectors, very typical one of the fractions will be one, and it is easy to get zero value // fractions. not sure what is the best way to handle it yet, so we just use 1.0 here - const double relaxation_factor_fractions = + [[maybe_unused]] const double relaxation_factor_fractions = (baseif_.isProducer()) ? relaxationFactorFractionsProducer(old_primary_variables, dwells) : 1.0; diff --git a/opm/simulators/wells/WellState.cpp b/opm/simulators/wells/WellState.cpp index 90b31b35a..97861d957 100644 --- a/opm/simulators/wells/WellState.cpp +++ b/opm/simulators/wells/WellState.cpp @@ -64,7 +64,7 @@ void WellState::base_init(const std::vector& cellPressures, // Setup wellname -> well index mapping. const int num_perf_this_well = well_perf_data[w].size(); std::string name = well.name(); - assert( name.size() > 0 ); + assert( !name.empty() ); mapentry_t& wellMapEntry = wellMap_[name]; wellMapEntry[ 0 ] = w; wellMapEntry[ 1 ] = connpos;