diff --git a/lib/gpu/lal_answer.cpp b/lib/gpu/lal_answer.cpp index a8b3c6258d..361c340ec7 100644 --- a/lib/gpu/lal_answer.cpp +++ b/lib/gpu/lal_answer.cpp @@ -94,13 +94,13 @@ bool AnswerT::init(const int inum, const bool charge, const bool rot, template bool AnswerT::add_fields(const bool charge, const bool rot) { bool realloc=false; - if (charge && _charge==false) { + if (charge && !_charge) { _charge=true; _e_fields++; _ev_fields++; realloc=true; } - if (rot && _rot==false) { + if (rot && !_rot) { _rot=true; realloc=true; } @@ -163,10 +163,8 @@ void AnswerT::copy_answers(const bool eflag, const bool vflag, #endif int csize=_ev_fields; - if (!eflag) - csize-=_e_fields; - if (!vflag) - csize-=6; + if (!eflag) csize-=_e_fields; + if (!vflag) csize-=6; if (csize>0) engv.update_host(_ev_stride*csize,true); @@ -192,8 +190,7 @@ void AnswerT::copy_answers(const bool eflag, const bool vflag, template double AnswerT::energy_virial(double *eatom, double **vatom, double *virial) { - if (_eflag==false && _vflag==false) - return 0.0; + if (!_eflag && !_vflag) return 0.0; double evdwl=0.0; int vstart=0; @@ -241,11 +238,9 @@ double AnswerT::energy_virial(double *eatom, double **vatom, template double AnswerT::energy_virial(double *eatom, double **vatom, double *virial, double &ecoul) { - if (_eflag==false && _vflag==false) - return 0.0; + if (!_eflag && !_vflag) return 0.0; - if (_charge==false) - return energy_virial(eatom,vatom,virial); + if (!_charge) return energy_virial(eatom,vatom,virial); double evdwl=0.0; int vstart=0, iend=_ev_stride; diff --git a/lib/gpu/lal_atom.cpp b/lib/gpu/lal_atom.cpp index cda4d383b5..17cfa0dc5a 100644 --- a/lib/gpu/lal_atom.cpp +++ b/lib/gpu/lal_atom.cpp @@ -107,17 +107,17 @@ bool AtomT::alloc(const int nall) { gpu_bytes+=x_cast.device.row_bytes()+type_cast.device.row_bytes(); #endif - if (_charge && _host_view==false) { + if (_charge && !_host_view) { success=success && (q.alloc(_max_atoms,*dev,UCL_WRITE_ONLY, UCL_READ_ONLY)==UCL_SUCCESS); gpu_bytes+=q.device.row_bytes(); } - if (_rot && _host_view==false) { + if (_rot && !_host_view) { success=success && (quat.alloc(_max_atoms*4,*dev,UCL_WRITE_ONLY, UCL_READ_ONLY)==UCL_SUCCESS); gpu_bytes+=quat.device.row_bytes(); } - if (_vel && _host_view==false) { + if (_vel && !_host_view) { success=success && (v.alloc(_max_atoms*4,*dev,UCL_WRITE_ONLY, UCL_READ_ONLY)==UCL_SUCCESS); gpu_bytes+=v.device.row_bytes(); @@ -161,37 +161,37 @@ bool AtomT::add_fields(const bool charge, const bool rot, // Ignore host/device transfers? int gpu_bytes=0; - if (charge && _charge==false) { + if (charge && !_charge) { _charge=true; _other=true; - if (_host_view==false) { + if (!_host_view) { success=success && (q.alloc(_max_atoms,*dev,UCL_WRITE_ONLY, UCL_READ_ONLY)==UCL_SUCCESS); gpu_bytes+=q.device.row_bytes(); } } - if (rot && _rot==false) { + if (rot && !_rot) { _rot=true; _other=true; - if (_host_view==false) { + if (!_host_view) { success=success && (quat.alloc(_max_atoms*4,*dev,UCL_WRITE_ONLY, UCL_READ_ONLY)==UCL_SUCCESS); gpu_bytes+=quat.device.row_bytes(); } } - if (vel && _vel==false) { + if (vel && !_vel) { _vel=true; _other=true; - if (_host_view==false) { + if (!_host_view) { success=success && (v.alloc(_max_atoms*4,*dev,UCL_WRITE_ONLY, UCL_READ_ONLY)==UCL_SUCCESS); gpu_bytes+=v.device.row_bytes(); } } - if (bonds && _bonds==false) { + if (bonds && !_bonds) { _bonds=true; if (_bonds && _gpu_nbor>0) { success=success && (dev_tag.alloc(_max_atoms,*dev, diff --git a/lib/gpu/lal_device.cpp b/lib/gpu/lal_device.cpp index ad0e2281bf..7bf2caaa74 100644 --- a/lib/gpu/lal_device.cpp +++ b/lib/gpu/lal_device.cpp @@ -201,9 +201,9 @@ int DeviceT::init_device(MPI_Comm world, MPI_Comm replica, const int ngpu, unsigned best_cus = gpu->cus(0); bool type_match = (gpu->device_type(0) == type); for (int i = 1; i < gpu->num_devices(); i++) { - if (type_match==true && gpu->device_type(i)!=type) + if (type_match && gpu->device_type(i)!=type) continue; - if (type_match == false && gpu->device_type(i) == type) { + if (type_match && gpu->device_type(i) == type) { type_match = true; best_cus = gpu->cus(i); best_device = i; @@ -280,7 +280,7 @@ int DeviceT::init_device(MPI_Comm world, MPI_Comm replica, const int ngpu, MPI_Comm_rank(_comm_gpu,&_gpu_rank); #if !defined(CUDA_PROXY) && !defined(CUDA_MPS_SUPPORT) - if (_procs_per_gpu>1 && gpu->sharing_supported(my_gpu)==false) + if (_procs_per_gpu>1 && !gpu->sharing_supported(my_gpu)) return -7; #endif @@ -400,7 +400,7 @@ int DeviceT::set_ocl_params(std::string s_config, const std::string &extra_args) _ocl_compile_string += " -DCONFIG_ID="+params[0]+ " -DSIMD_SIZE="+params[1]+ " -DMEM_THREADS="+params[2]; - if (gpu->has_shuffle_support()==false) + if (!gpu->has_shuffle_support()) _ocl_compile_string+=" -DSHUFFLE_AVAIL=0"; else _ocl_compile_string+=" -DSHUFFLE_AVAIL="+params[3]; @@ -443,7 +443,7 @@ int DeviceT::init(Answer &ans, const bool charge, const bool vel) { if (!_device_init) return -1; - if (sizeof(acctyp)==sizeof(double) && gpu->double_precision()==false) + if (sizeof(acctyp)==sizeof(double) && !gpu->double_precision()) return -5; // Counts of data transfers for timing overhead estimates @@ -480,11 +480,11 @@ int DeviceT::init(Answer &ans, const bool charge, if (vel) _data_in_estimate++; } else { - if (atom.charge()==false && charge) + if (!atom.charge() && charge) _data_in_estimate++; - if (atom.quaternion()==false && rot) + if (!atom.quaternion() && rot) _data_in_estimate++; - if (atom.velocity()==false && vel) + if (!atom.velocity() && vel) _data_in_estimate++; if (!atom.add_fields(charge,rot,gpu_nbor,gpu_nbor>0 && maxspecial,vel)) return -3; @@ -502,7 +502,7 @@ int DeviceT::init(Answer &ans, const int nlocal, const int nall) { if (!_device_init) return -1; - if (sizeof(acctyp)==sizeof(double) && gpu->double_precision()==false) + if (sizeof(acctyp)==sizeof(double) && !gpu->double_precision()) return -5; if (_init_count==0) { diff --git a/lib/gpu/lal_neighbor.cpp b/lib/gpu/lal_neighbor.cpp index f33fdb24c7..58476a173b 100644 --- a/lib/gpu/lal_neighbor.cpp +++ b/lib/gpu/lal_neighbor.cpp @@ -113,7 +113,7 @@ bool Neighbor::init(NeighborShared *shared, const int inum, if (!success) return false; - if (_use_packing==false) { + if (!_use_packing) { #ifndef LAL_USE_OLD_NEIGHBOR _shared->compile_kernels(devi, gpu_nbor, compile_flags+ " -DMAX_SUBGROUPS_PER_BLOCK="+toa(_block_nbor_build/_simd_size)); @@ -153,7 +153,7 @@ void Neighbor::alloc(bool &success) { int nt=_max_atoms+_max_host; if (_max_nbors) _max_nbors = ((_max_nbors-1)/_threads_per_atom+1)*_threads_per_atom; - if (_use_packing==false || _gpu_nbor>0) { + if (!_use_packing || _gpu_nbor>0) { if (_max_nbors) success=success && (dev_nbor.alloc((_max_nbors+2)*_max_atoms,*dev)==UCL_SUCCESS); @@ -166,7 +166,7 @@ void Neighbor::alloc(bool &success) { _c_bytes=dev_nbor.row_bytes(); if (_alloc_packed) { - if (_use_packing==false) { + if (!_use_packing) { dev_packed_begin.clear(); success=success && (dev_packed_begin.alloc(_max_atoms,*dev, _packed_permissions)==UCL_SUCCESS); @@ -373,7 +373,7 @@ void Neighbor::get_host(const int inum, int *ilist, int *numj, time_nbor.stop(); - if (_use_packing==false) { + if (!_use_packing) { time_kernel.start(); int GX=static_cast(ceil(static_cast(inum)*_threads_per_atom/ block_size)); @@ -450,7 +450,7 @@ void Neighbor::get_host3(const int inum, const int nlist, int *ilist, int *numj, } time_nbor.stop(); - if (_use_packing==false) { + if (!_use_packing) { time_kernel.start(); int GX=static_cast(ceil(static_cast(inum)*_threads_per_atom/ block_size)); diff --git a/lib/gpu/lal_pppm.cpp b/lib/gpu/lal_pppm.cpp index 8f95d38532..911efe69f8 100644 --- a/lib/gpu/lal_pppm.cpp +++ b/lib/gpu/lal_pppm.cpp @@ -303,7 +303,7 @@ int PPPMT::spread(const int ago, const int nlocal, const int nall, double *host_q, double *boxlo, const double delxinv, const double delyinv, const double delzinv) { - if (_precompute_done==false) { + if (!_precompute_done) { atom->acc_timers(); _precompute(ago,nlocal,nall,host_x,host_type,success,host_q,boxlo,delxinv, delyinv,delzinv); @@ -359,7 +359,7 @@ void PPPMT::interp(const grdtyp qqrd2e_scale) { time_interp.stop(); ans->copy_answers(false,false,false,false,0); - if (_kspace_split==false) + if (!_kspace_split) device->add_ans_object(ans); } diff --git a/lib/gpu/lal_pppm_ext.cpp b/lib/gpu/lal_pppm_ext.cpp index d548b94be1..cf009b4479 100644 --- a/lib/gpu/lal_pppm_ext.cpp +++ b/lib/gpu/lal_pppm_ext.cpp @@ -101,7 +101,7 @@ float * pppm_gpu_init_f(const int nlocal, const int nall, FILE *screen, float *b=pppm_gpu_init(PPPMF,nlocal,nall,screen,order,nxlo_out,nylo_out, nzlo_out,nxhi_out,nyhi_out,nzhi_out,rho_coeff,vd_brick, slab_volfactor,nx_pppm,ny_pppm,nz_pppm,split,success); - if (split==false && respa==false) + if (!split && !respa) PPPMF.device->set_single_precompute(&PPPMF); return b; } @@ -146,7 +146,7 @@ double * pppm_gpu_init_d(const int nlocal, const int nall, FILE *screen, nzlo_out,nxhi_out,nyhi_out,nzhi_out,rho_coeff, vd_brick,slab_volfactor,nx_pppm,ny_pppm,nz_pppm, split,success); - if (split==false && respa==false) + if (!split && !respa) PPPMD.device->set_double_precompute(&PPPMD); return b; } diff --git a/lib/gpu/lal_yukawa_colloid.cpp b/lib/gpu/lal_yukawa_colloid.cpp index a447bb3889..e73a72c79e 100644 --- a/lib/gpu/lal_yukawa_colloid.cpp +++ b/lib/gpu/lal_yukawa_colloid.cpp @@ -69,7 +69,7 @@ int YukawaColloidT::init(const int ntypes, _max_rad_size=static_cast(static_cast(ef_nall)*1.10); - if (_shared_view==false) + if (!_shared_view) c_rad.alloc(_max_rad_size,*(this->ucl_device),UCL_WRITE_ONLY,UCL_READ_ONLY); rad_tex.get_texture(*(this->pair_program),"rad_tex"); @@ -157,7 +157,7 @@ void YukawaColloidT::compute(const int f_ago, const int inum_full, if (nall>_max_rad_size) { _max_rad_size=static_cast(static_cast(nall)*1.10); - if (_shared_view==false) { + if (!_shared_view) { c_rad.resize(_max_rad_size); rad_tex.bind_float(c_rad,1); } @@ -229,7 +229,7 @@ int** YukawaColloidT::compute(const int ago, const int inum_full, if (nall>_max_rad_size) { _max_rad_size=static_cast(static_cast(nall)*1.10); - if (_shared_view==false) { + if (!_shared_view) { c_rad.resize(_max_rad_size); rad_tex.bind_float(c_rad,1); } diff --git a/src/AWPMD/pair_awpmd_cut.cpp b/src/AWPMD/pair_awpmd_cut.cpp index 0c95801421..fcce6006fd 100644 --- a/src/AWPMD/pair_awpmd_cut.cpp +++ b/src/AWPMD/pair_awpmd_cut.cpp @@ -95,10 +95,7 @@ struct cmp_x{ else if (d>tol) return false; d=xx[left.second][2]-xx[right.second][2]; - if (d<-tol) - return true; - else - return false; + return d < -tol; } else return left.firstsetupflag) ? false : true; + const bool historyupdate = update->setupflag != 0; ev_init(eflag,vflag); diff --git a/src/KIM/kim_param.cpp b/src/KIM/kim_param.cpp index 2d82b18352..d4dfb0ead6 100644 --- a/src/KIM/kim_param.cpp +++ b/src/KIM/kim_param.cpp @@ -181,20 +181,17 @@ void KimParam::command(int narg, char **arg) std::string atom_type_list; - bool isPairStyleAssigned = force->pair ? true : false; - if (isPairStyleAssigned) { + if (force->pair) { Pair *pair = force->pair_match("kim", 1, 0); if (pair) { auto pairKIM = reinterpret_cast(pair); pkim = pairKIM->get_kim_model(); - if (!pkim) - error->all(FLERR, "Unable to get the KIM Portable Model"); + if (!pkim) error->all(FLERR, "Unable to get the KIM Portable Model"); if (kim_param_get_set == "set") { atom_type_list = pairKIM->get_atom_type_list(); - if (atom_type_list.empty()) - error->all(FLERR, "The requested atom type list is empty"); + if (atom_type_list.empty()) error->all(FLERR, "The requested atom type list is empty"); } } else error->all(FLERR, "Pair style is defined, but there is " diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index 0109ce4e52..f3b53ac71f 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -1057,19 +1057,16 @@ int PairKIM::check_for_routine_compatibility() pkim, modelRoutineName, &present, &required); if (error) return true; - if ((present == true) && (required == true)) { - if (!(KIM_ModelRoutineName_Equal(modelRoutineName, - KIM_MODEL_ROUTINE_NAME_Create) - || KIM_ModelRoutineName_Equal( - modelRoutineName, - KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate) + if (present && required) { + if (!(KIM_ModelRoutineName_Equal(modelRoutineName, KIM_MODEL_ROUTINE_NAME_Create) + || KIM_ModelRoutineName_Equal(modelRoutineName, + KIM_MODEL_ROUTINE_NAME_ComputeArgumentsCreate) || KIM_ModelRoutineName_Equal(modelRoutineName, KIM_MODEL_ROUTINE_NAME_Compute) || KIM_ModelRoutineName_Equal(modelRoutineName, KIM_MODEL_ROUTINE_NAME_Refresh) - || KIM_ModelRoutineName_Equal( - modelRoutineName, - KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy) + || KIM_ModelRoutineName_Equal(modelRoutineName, + KIM_MODEL_ROUTINE_NAME_ComputeArgumentsDestroy) || KIM_ModelRoutineName_Equal(modelRoutineName, KIM_MODEL_ROUTINE_NAME_Destroy))) { return true; diff --git a/src/OPENMP/fix_omp.cpp b/src/OPENMP/fix_omp.cpp index 849f1f42b9..4f5e990fcc 100644 --- a/src/OPENMP/fix_omp.cpp +++ b/src/OPENMP/fix_omp.cpp @@ -198,10 +198,8 @@ void FixOMP::init() && !utils::strmatch(update->integrate_style,"^respa/omp")) error->all(FLERR,"Must use respa/omp for r-RESPA with /omp styles"); - if (force->pair && force->pair->compute_flag) _pair_compute_flag = true; - else _pair_compute_flag = false; - if (force->kspace && force->kspace->compute_flag) _kspace_compute_flag = true; - else _kspace_compute_flag = false; + _pair_compute_flag = force->pair && force->pair->compute_flag; + _kspace_compute_flag = force->kspace && force->kspace->compute_flag; int check_hybrid, kspace_split; last_pair_hybrid = nullptr; diff --git a/src/PHONON/dynamical_matrix.cpp b/src/PHONON/dynamical_matrix.cpp index dc1e63e4ca..3723a7a467 100644 --- a/src/PHONON/dynamical_matrix.cpp +++ b/src/PHONON/dynamical_matrix.cpp @@ -427,8 +427,7 @@ void DynamicalMatrix::displace_atom(int local_idx, int direction, int magnitude) void DynamicalMatrix::update_force() { neighbor->ago = 0; - if ((modify->get_fix_by_id("package_intel")) ? true : false) - neighbor->decide(); + if (modify->get_fix_by_id("package_intel")) neighbor->decide(); force_clear(); int n_pre_force = modify->n_pre_force; int n_pre_reverse = modify->n_pre_reverse; diff --git a/src/PHONON/third_order.cpp b/src/PHONON/third_order.cpp index 065575ae58..76d90c65bd 100644 --- a/src/PHONON/third_order.cpp +++ b/src/PHONON/third_order.cpp @@ -485,8 +485,7 @@ void ThirdOrder::displace_atom(int local_idx, int direction, int magnitude) void ThirdOrder::update_force() { neighbor->ago = 0; - if ((modify->get_fix_by_id("package_intel")) ? true : false) - neighbor->decide(); + if (modify->get_fix_by_id("package_intel")) neighbor->decide(); force_clear(); int n_post_force = modify->n_post_force; int n_pre_force = modify->n_pre_force; diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index aa646ecabb..6d1412cbd4 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -2387,7 +2387,7 @@ void AtomVec::setup_fields() else threads = nullptr; for (int i = 0; i < ngrow; i++) { Atom::PerAtom *field = &atom->peratom[mgrow.index[i]]; - threads[i] = (field->threadflag) ? true : false; + threads[i] = field->threadflag == 1; } // set style-specific sizes diff --git a/src/atom_vec_body.cpp b/src/atom_vec_body.cpp index 6308153be6..8d62b6b7e7 100644 --- a/src/atom_vec_body.cpp +++ b/src/atom_vec_body.cpp @@ -105,7 +105,7 @@ void AtomVecBody::process_args(int narg, char **arg) if (narg < 1) error->all(FLERR,"Invalid atom_style body command"); - if (false) { + if (false) { // NOLINT bptr = nullptr; #define BODY_CLASS diff --git a/src/info.cpp b/src/info.cpp index fa713d9ab2..5e53864253 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -785,13 +785,13 @@ bool Info::is_active(const char *category, const char *name) if (strcmp(category,"package") == 0) { if (strcmp(name,"gpu") == 0) { - return (modify->get_fix_by_id("package_gpu")) ? true : false; + return modify->get_fix_by_id("package_gpu") != nullptr; } else if (strcmp(name,"intel") == 0) { - return (modify->get_fix_by_id("package_intel")) ? true : false; + return modify->get_fix_by_id("package_intel") != nullptr; } else if (strcmp(name,"kokkos") == 0) { - return (lmp->kokkos && lmp->kokkos->kokkos_exists) ? true : false; + return lmp->kokkos && lmp->kokkos->kokkos_exists; } else if (strcmp(name,"omp") == 0) { - return (modify->get_fix_by_id("package_omp")) ? true : false; + return modify->get_fix_by_id("package_omp") != nullptr; } else error->all(FLERR,"Unknown name for info package category: {}", name); } else if (strcmp(category,"newton") == 0) { diff --git a/src/read_dump.cpp b/src/read_dump.cpp index 81d1d7e9c2..f1dc8fc62e 100644 --- a/src/read_dump.cpp +++ b/src/read_dump.cpp @@ -233,7 +233,7 @@ void ReadDump::setup_reader(int narg, char **arg) // create Nreader reader classes per reader // match readerstyle to options in style_reader.h - if (false) { + if (false) { // NOLINT return; // dummy line to enable else-if macro expansion #define READER_CLASS diff --git a/src/write_dump.cpp b/src/write_dump.cpp index b28fc586e2..b29da81463 100644 --- a/src/write_dump.cpp +++ b/src/write_dump.cpp @@ -56,7 +56,7 @@ void WriteDump::command(int narg, char **arg) for (int i = 2; i < modindex; ++i) dumpargs[i+2] = arg[i]; - if (false) { + if (false) { // NOLINT return; // dummy branch to enable else-if macro expansion #define DUMP_CLASS