mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
use .empty() instead of .size() comparisons
This commit is contained in:
@@ -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<int> &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;
|
||||
|
@@ -270,7 +270,7 @@ void findLevelScheduling(int *CSRColIndices, int *CSRRowPointers, int *CSCRowInd
|
||||
std::vector <int> 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++) {
|
||||
|
@@ -49,7 +49,7 @@ openclSolverBackend<block_size>::openclSolverBackend(int verbosity_, int maxit_,
|
||||
try {
|
||||
std::vector<cl::Platform> 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<block_size>::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";
|
||||
|
@@ -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() ));
|
||||
}
|
||||
|
||||
|
@@ -705,11 +705,11 @@ GasLiftStage2::
|
||||
removeSurplusALQ_(const Group &group,
|
||||
std::vector<GradPair> &inc_grads, std::vector<GradPair> &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<std::optional<GasLiftStage2::GradPairItr>,
|
||||
GasLiftStage2::OptimizeState::
|
||||
getEcoGradients(std::vector<GradPair> &inc_grads, std::vector<GradPair> &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
|
||||
|
@@ -65,7 +65,7 @@ void WellState::base_init(const std::vector<double>& 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;
|
||||
|
Reference in New Issue
Block a user