diff --git a/examples/plugins/helloplugin.cpp b/examples/plugins/helloplugin.cpp index 9f3406a282..ba87c48367 100644 --- a/examples/plugins/helloplugin.cpp +++ b/examples/plugins/helloplugin.cpp @@ -12,7 +12,7 @@ namespace LAMMPS_NS { class Hello : public Command { public: Hello(class LAMMPS *lmp) : Command(lmp){}; - void command(int, char **); + void command(int, char **) override; }; } // namespace LAMMPS_NS diff --git a/lib/gpu/lal_device.cpp b/lib/gpu/lal_device.cpp index b8bca4f0fd..580a3e81b6 100644 --- a/lib/gpu/lal_device.cpp +++ b/lib/gpu/lal_device.cpp @@ -81,7 +81,7 @@ int DeviceT::init_device(MPI_Comm world, MPI_Comm replica, const int ngpu, gpu=new UCL_Device(); // ---------------------- OpenCL Compiler Args ------------------------- - std::string extra_args=""; + std::string extra_args; if (ocl_args) extra_args+=":"+std::string(ocl_args); #ifdef LAL_OCL_EXTRA_ARGS extra_args+=":" LAL_PRE_STRINGIFY(LAL_OCL_EXTRA_ARGS); @@ -144,7 +144,7 @@ int DeviceT::init_device(MPI_Comm world, MPI_Comm replica, const int ngpu, // Setup OpenCL platform and parameters based on platform // and device type specifications - std::string ocl_vstring=""; + std::string ocl_vstring; if (device_type_flags != nullptr) ocl_vstring=device_type_flags; // Setup the OpenCL platform @@ -161,7 +161,7 @@ int DeviceT::init_device(MPI_Comm world, MPI_Comm replica, const int ngpu, if (_platform_id>=0) pres=gpu->set_platform(_platform_id); else { - std::string vendor=""; + std::string vendor; if (device_type_flags!=nullptr) { if (ocl_vstring=="intelgpu") vendor="intel"; @@ -578,7 +578,7 @@ template void DeviceT::init_message(FILE *screen, const char *name, const int first_gpu, const int last_gpu) { #if defined(USE_OPENCL) - std::string fs=""; + std::string fs; #elif defined(USE_CUDART) std::string fs=""; #else diff --git a/lib/gpu/lal_neighbor.cpp b/lib/gpu/lal_neighbor.cpp index 58476a173b..373da141ad 100644 --- a/lib/gpu/lal_neighbor.cpp +++ b/lib/gpu/lal_neighbor.cpp @@ -64,10 +64,7 @@ bool Neighbor::init(NeighborShared *shared, const int inum, // Not yet implemented assert(0==1); - if (pre_cut || gpu_nbor==0) - _alloc_packed=true; - else - _alloc_packed=false; + _alloc_packed = pre_cut || gpu_nbor==0; if (pre_cut) _packed_permissions=UCL_READ_WRITE; diff --git a/lib/gpu/lal_pppm.cpp b/lib/gpu/lal_pppm.cpp index 911efe69f8..8b3a6b1dde 100644 --- a/lib/gpu/lal_pppm.cpp +++ b/lib/gpu/lal_pppm.cpp @@ -70,7 +70,7 @@ grdtyp *PPPMT::init(const int nlocal, const int nall, FILE *_screen, flag=device->init(*ans,nlocal,nall); if (flag!=0) return nullptr; - if (sizeof(grdtyp)==sizeof(double) && device->double_precision()==false) { + if (sizeof(grdtyp)==sizeof(double) && !device->double_precision()) { flag=-15; return nullptr; } @@ -374,7 +374,7 @@ void PPPMT::compile_kernels(UCL_Device &dev) { if (_compiled) return; - if (sizeof(grdtyp)==sizeof(double) && ucl_device->double_precision()==false) + if (sizeof(grdtyp)==sizeof(double) && !ucl_device->double_precision()) return; std::string flags=device->compile_string(); diff --git a/lib/gpu/lal_yukawa_colloid.cpp b/lib/gpu/lal_yukawa_colloid.cpp index e73a72c79e..b6aa526db3 100644 --- a/lib/gpu/lal_yukawa_colloid.cpp +++ b/lib/gpu/lal_yukawa_colloid.cpp @@ -56,10 +56,7 @@ int YukawaColloidT::init(const int ntypes, if (success!=0) return success; - if (this->ucl_device->shared_memory() && sizeof(numtyp)==sizeof(double)) - _shared_view=true; - else - _shared_view=false; + _shared_view = this->ucl_device->shared_memory() && sizeof(numtyp)==sizeof(double); // allocate rad diff --git a/src/BROWNIAN/fix_brownian.cpp b/src/BROWNIAN/fix_brownian.cpp index de984e3736..97c4017a14 100644 --- a/src/BROWNIAN/fix_brownian.cpp +++ b/src/BROWNIAN/fix_brownian.cpp @@ -70,8 +70,7 @@ void FixBrownian::initial_integrate(int /*vflag */) initial_integrate_templated<1, 0, 0>(); } } - return; -} + } /* ---------------------------------------------------------------------- */ @@ -127,5 +126,4 @@ template void FixBrownian::initial_int v[i][2] = dz / dt; } } - return; -} + } diff --git a/src/BROWNIAN/fix_brownian_asphere.cpp b/src/BROWNIAN/fix_brownian_asphere.cpp index 18321cdafd..63b618ea2c 100644 --- a/src/BROWNIAN/fix_brownian_asphere.cpp +++ b/src/BROWNIAN/fix_brownian_asphere.cpp @@ -157,8 +157,7 @@ void FixBrownianAsphere::initial_integrate(int /*vflag */) } } } - return; -} + } /* ---------------------------------------------------------------------- */ @@ -298,5 +297,4 @@ void FixBrownianAsphere::initial_integrate_templated() } } - return; -} + } diff --git a/src/BROWNIAN/fix_brownian_sphere.cpp b/src/BROWNIAN/fix_brownian_sphere.cpp index ad2f5ff967..763d20fdd7 100644 --- a/src/BROWNIAN/fix_brownian_sphere.cpp +++ b/src/BROWNIAN/fix_brownian_sphere.cpp @@ -85,8 +85,7 @@ void FixBrownianSphere::initial_integrate(int /*vflag */) initial_integrate_templated<1, 0, 0, 0>(); } } - return; -} + } /* ---------------------------------------------------------------------- */ diff --git a/src/COMPRESS/gz_file_writer.cpp b/src/COMPRESS/gz_file_writer.cpp index cd02832cca..d53576b9c2 100644 --- a/src/COMPRESS/gz_file_writer.cpp +++ b/src/COMPRESS/gz_file_writer.cpp @@ -21,7 +21,7 @@ using namespace LAMMPS_NS; -GzFileWriter::GzFileWriter() : FileWriter(), compression_level(Z_BEST_COMPRESSION), gzFp(nullptr) {} +GzFileWriter::GzFileWriter() : compression_level(Z_BEST_COMPRESSION), gzFp(nullptr) {} /* ---------------------------------------------------------------------- */ diff --git a/src/COMPRESS/zstd_file_writer.cpp b/src/COMPRESS/zstd_file_writer.cpp index c628cc0078..f2f64fcc1c 100644 --- a/src/COMPRESS/zstd_file_writer.cpp +++ b/src/COMPRESS/zstd_file_writer.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; ZstdFileWriter::ZstdFileWriter() : - FileWriter(), compression_level(0), checksum_flag(1), cctx(nullptr), fp(nullptr) + compression_level(0), checksum_flag(1), cctx(nullptr), fp(nullptr) { out_buffer_size = ZSTD_CStreamOutSize(); out_buffer = new char[out_buffer_size]; diff --git a/src/DPD-REACT/fix_rx.cpp b/src/DPD-REACT/fix_rx.cpp index 9a32f39268..a85c6bfdd7 100644 --- a/src/DPD-REACT/fix_rx.cpp +++ b/src/DPD-REACT/fix_rx.cpp @@ -1109,8 +1109,7 @@ void FixRX::rkf45_step (const int neq, const double h, double y[], double y_out[ y_out[k] = y[k] + r4; } - return; -} + } int FixRX::rkf45_h0 (const int neq, const double t, const double /*t_stop*/, const double hmin, const double hmax, @@ -1422,8 +1421,6 @@ void FixRX::odeDiagnostics() // Reset the counters. for (int i = 0; i < numDiagnosticCounters; ++i) diagnosticCounter[i] = 0; - - return; } void FixRX::rkf45(int id, double *rwork, void *v_param, int ode_counter[]) diff --git a/src/ELECTRODE/fix_electrode_conp.cpp b/src/ELECTRODE/fix_electrode_conp.cpp index d6180e3064..0122aeeffe 100644 --- a/src/ELECTRODE/fix_electrode_conp.cpp +++ b/src/ELECTRODE/fix_electrode_conp.cpp @@ -1105,7 +1105,7 @@ void FixElectrodeConp::write_to_file(FILE *file, const std::vector &tags /*----------------------------------------------------------------------- */ -void FixElectrodeConp::read_from_file(std::string input_file, double **array, +void FixElectrodeConp::read_from_file(const std::string& input_file, double **array, const std::string &filetype) { if (comm->me == 0) { diff --git a/src/ELECTRODE/fix_electrode_conp.h b/src/ELECTRODE/fix_electrode_conp.h index 5113ad46cb..cc24aa6b76 100644 --- a/src/ELECTRODE/fix_electrode_conp.h +++ b/src/ELECTRODE/fix_electrode_conp.h @@ -101,7 +101,7 @@ class FixElectrodeConp : public Fix { double potential_energy(int); double self_energy(int); void write_to_file(FILE *, const std::vector &, const std::vector> &); - void read_from_file(std::string input_file, double **, const std::string &); + void read_from_file(const std::string& input_file, double **, const std::string &); void compute_sd_vectors(); void compute_sd_vectors_ffield(); std::vector setvars_types, setvars_groups, setvars_vars; diff --git a/src/EXTRA-FIX/fix_ave_correlate_long.cpp b/src/EXTRA-FIX/fix_ave_correlate_long.cpp index 3987449279..c51ff7f3bd 100644 --- a/src/EXTRA-FIX/fix_ave_correlate_long.cpp +++ b/src/EXTRA-FIX/fix_ave_correlate_long.cpp @@ -474,9 +474,6 @@ void FixAveCorrelateLong::end_of_step() error->warning(FLERR,"Error while tuncating output: {}", utils::getsyserror()); } } - - return; - } void FixAveCorrelateLong::evaluate() { diff --git a/src/EXTRA-FIX/fix_gld.cpp b/src/EXTRA-FIX/fix_gld.cpp index b183526d65..3af37005c3 100644 --- a/src/EXTRA-FIX/fix_gld.cpp +++ b/src/EXTRA-FIX/fix_gld.cpp @@ -633,6 +633,4 @@ void FixGLD::init_s_gld() } } } - - return; } diff --git a/src/EXTRA-FIX/fix_gle.cpp b/src/EXTRA-FIX/fix_gle.cpp index 1d07b05d91..cabc876ab5 100644 --- a/src/EXTRA-FIX/fix_gle.cpp +++ b/src/EXTRA-FIX/fix_gle.cpp @@ -434,7 +434,6 @@ void FixGLE::init_gles() delete[] rootCT; delete[] news; delete[] newg; - return; } /* ---------------------------------------------------------------------- */ diff --git a/src/GPU/pair_eam_alloy_gpu.cpp b/src/GPU/pair_eam_alloy_gpu.cpp index ef939f81fb..65fc0fcdfb 100644 --- a/src/GPU/pair_eam_alloy_gpu.cpp +++ b/src/GPU/pair_eam_alloy_gpu.cpp @@ -179,10 +179,7 @@ void PairEAMAlloyGPU::init_style() GPU_EXTRA::check_flag(success, error, world); if (gpu_mode == GPU_FORCE) neighbor->add_request(this, NeighConst::REQ_FULL); - if (fp_size == sizeof(double)) - fp_single = false; - else - fp_single = true; + fp_single = fp_size != sizeof(double); embedstep = -1; } diff --git a/src/GPU/pair_eam_fs_gpu.cpp b/src/GPU/pair_eam_fs_gpu.cpp index f174243ced..ed8ce0c78b 100644 --- a/src/GPU/pair_eam_fs_gpu.cpp +++ b/src/GPU/pair_eam_fs_gpu.cpp @@ -179,10 +179,7 @@ void PairEAMFSGPU::init_style() GPU_EXTRA::check_flag(success, error, world); if (gpu_mode == GPU_FORCE) neighbor->add_request(this, NeighConst::REQ_FULL); - if (fp_size == sizeof(double)) - fp_single = false; - else - fp_single = true; + fp_single = fp_size != sizeof(double); embedstep = -1; } diff --git a/src/GPU/pair_eam_gpu.cpp b/src/GPU/pair_eam_gpu.cpp index c04418720c..1ef3a0a3a8 100644 --- a/src/GPU/pair_eam_gpu.cpp +++ b/src/GPU/pair_eam_gpu.cpp @@ -176,10 +176,7 @@ void PairEAMGPU::init_style() GPU_EXTRA::check_flag(success, error, world); if (gpu_mode == GPU_FORCE) neighbor->add_request(this, NeighConst::REQ_FULL); - if (fp_size == sizeof(double)) - fp_single = false; - else - fp_single = true; + fp_single = fp_size != sizeof(double); embedstep = -1; } diff --git a/src/H5MD/dump_h5md.cpp b/src/H5MD/dump_h5md.cpp index a59de9773c..868dd81093 100644 --- a/src/H5MD/dump_h5md.cpp +++ b/src/H5MD/dump_h5md.cpp @@ -338,13 +338,6 @@ void DumpH5MD::openfile() /* ---------------------------------------------------------------------- */ -void DumpH5MD::write_header(bigint /* nbig */) -{ - return; -} - -/* ---------------------------------------------------------------------- */ - void DumpH5MD::pack(tagint *ids) { int m,n; diff --git a/src/H5MD/dump_h5md.h b/src/H5MD/dump_h5md.h index 04c0cd2e09..6634cdb8ae 100644 --- a/src/H5MD/dump_h5md.h +++ b/src/H5MD/dump_h5md.h @@ -60,7 +60,7 @@ class DumpH5MD : public Dump { void init_style() override; int modify_param(int, char **) override; void openfile() override; - void write_header(bigint) override; + void write_header(bigint) override {}; void pack(tagint *) override; void write_data(int, double *) override; diff --git a/src/INTEL/npair_intel.cpp b/src/INTEL/npair_intel.cpp index eeed7844b3..f6783fce40 100644 --- a/src/INTEL/npair_intel.cpp +++ b/src/INTEL/npair_intel.cpp @@ -39,15 +39,15 @@ NPairIntel::NPairIntel(LAMMPS *lmp) : NPair(lmp) { /* ---------------------------------------------------------------------- */ +#ifdef _LMP_INTEL_OFFLOAD NPairIntel::~NPairIntel() { - #ifdef _LMP_INTEL_OFFLOAD if (_off_map_stencil) { const int * stencil = this->stencil; #pragma offload_transfer target(mic:_cop) \ nocopy(stencil:alloc_if(0) free_if(1)) } - #endif } +#endif /* ---------------------------------------------------------------------- */ diff --git a/src/INTEL/npair_intel.h b/src/INTEL/npair_intel.h index 04093d5ca1..22560cbdcb 100644 --- a/src/INTEL/npair_intel.h +++ b/src/INTEL/npair_intel.h @@ -76,7 +76,9 @@ namespace LAMMPS_NS { class NPairIntel : public NPair { public: NPairIntel(class LAMMPS *); + #ifdef _LMP_INTEL_OFFLOAD ~NPairIntel() override; + #endif void copy_neighbor_info() override; #ifdef _LMP_INTEL_OFFLOAD diff --git a/src/INTEL/pair_airebo_intel.cpp b/src/INTEL/pair_airebo_intel.cpp index 939a1873a9..25e52d02d2 100644 --- a/src/INTEL/pair_airebo_intel.cpp +++ b/src/INTEL/pair_airebo_intel.cpp @@ -4464,10 +4464,8 @@ static void aut_lj_with_bo( } exceed_limits: for (int l = 0; l < fvec::VL; l++) { - ref_lennard_jones_single_interaction(ka, ivec::at(i, l), ivec::at(j, l), - MORSEFLAG); + ref_lennard_jones_single_interaction(ka, ivec::at(i, l), ivec::at(j, l), MORSEFLAG); } - return; } /* diff --git a/src/KIM/kim_query.cpp b/src/KIM/kim_query.cpp index e85df32755..f3d1815aed 100644 --- a/src/KIM/kim_query.cpp +++ b/src/KIM/kim_query.cpp @@ -88,7 +88,7 @@ using namespace LAMMPS_NS; #if defined(LMP_KIM_CURL) namespace { -static constexpr int kBufSize{10240}; +constexpr int kBufSize{10240}; struct WriteBuf { char *dataptr; diff --git a/src/KOKKOS/dynamical_matrix_kokkos.cpp b/src/KOKKOS/dynamical_matrix_kokkos.cpp index b8ea494f09..0075324ac4 100644 --- a/src/KOKKOS/dynamical_matrix_kokkos.cpp +++ b/src/KOKKOS/dynamical_matrix_kokkos.cpp @@ -164,7 +164,7 @@ void DynamicalMatrixKokkos::update_force() force_clear(); neighbor->ago = 0; - if ((modify->get_fix_by_id("package_intel")) ? true : false) + if ((modify->get_fix_by_id("package_intel")) != nullptr) neighbor->decide(); diff --git a/src/KOKKOS/fix_rx_kokkos.cpp b/src/KOKKOS/fix_rx_kokkos.cpp index 257a010fa9..c4254043f6 100644 --- a/src/KOKKOS/fix_rx_kokkos.cpp +++ b/src/KOKKOS/fix_rx_kokkos.cpp @@ -361,8 +361,6 @@ void FixRxKokkos::k_rkf45_step (const int neq, const double h, Vecto //y_out[k] = y[k] + r5; // Local extrapolation y_out[k] = y[k] + r4; } - - return; } template @@ -682,8 +680,6 @@ void FixRxKokkos::rkf45_step (const int neq, const double h, double //y_out[k] = y[k] + r5; // Local extrapolation y_out[k] = y[k] + r4; } - - return; } template @@ -1426,7 +1422,7 @@ void FixRxKokkos::solve_reactions(const int /*vflag*/, const bool is const int newton_pair = force->newton_pair; // Set the forward rates to zero if acting as setup_pre_force. - const bool setRatesToZero = (isPreForce == false); + const bool setRatesToZero = (!isPreForce); if (localTempFlag) { @@ -1875,8 +1871,6 @@ void FixRxKokkos::odeDiagnostics() // Reset the counters. for (int i = 0; i < numDiagnosticCounters; ++i) diagnosticCounter[i] = 0; - - return; } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_exp6_rx_kokkos.cpp b/src/KOKKOS/pair_exp6_rx_kokkos.cpp index c9333c37cd..534551e7e6 100644 --- a/src/KOKKOS/pair_exp6_rx_kokkos.cpp +++ b/src/KOKKOS/pair_exp6_rx_kokkos.cpp @@ -1254,7 +1254,7 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& delx_j [niters] = delx; dely_j [niters] = dely; delz_j [niters] = delz; - if (OneType == false) + if (!OneType) cutsq_j[niters] = cutsq_ij; neigh_j[niters] = d_neighbors(i,jptr); diff --git a/src/KOKKOS/pair_tersoff_kokkos.cpp b/src/KOKKOS/pair_tersoff_kokkos.cpp index ce84496b95..0e78fa785c 100644 --- a/src/KOKKOS/pair_tersoff_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_kokkos.cpp @@ -539,7 +539,6 @@ void PairTersoffKokkos::ters_fc_k_and_ters_dfc(const Param& param, c fc = 0.5*(1.0 - sin(arg)); dfc = -(MY_PI4/ters_D) * cos(arg); - return; } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/third_order_kokkos.cpp b/src/KOKKOS/third_order_kokkos.cpp index d29ce4bf99..5216b7910c 100644 --- a/src/KOKKOS/third_order_kokkos.cpp +++ b/src/KOKKOS/third_order_kokkos.cpp @@ -165,7 +165,7 @@ void ThirdOrderKokkos::update_force() force_clear(); neighbor->ago = 0; - if ((modify->get_fix_by_id("package_intel")) ? true : false) + if ((modify->get_fix_by_id("package_intel")) != nullptr) neighbor->decide(); if (n_pre_force) { diff --git a/src/KSPACE/fix_tune_kspace.cpp b/src/KSPACE/fix_tune_kspace.cpp index e2e0e4d622..34fe89c651 100644 --- a/src/KSPACE/fix_tune_kspace.cpp +++ b/src/KSPACE/fix_tune_kspace.cpp @@ -36,17 +36,15 @@ #define SWAP(a,b) {temp=(a);(a)=(b);(b)=temp;} #define SIGN(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a)) -#define GOLD 1.618034 +static constexpr double GOLD = 1.618034; -using namespace std; using namespace LAMMPS_NS; using namespace FixConst; /* ---------------------------------------------------------------------- */ FixTuneKspace::FixTuneKspace(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), - acc_str(""), kspace_style(""), pair_style(""), base_pair_style("") + Fix(lmp, narg, arg) { if (narg < 3) error->all(FLERR,"Illegal fix tune/kspace command"); @@ -245,7 +243,7 @@ void FixTuneKspace::update_pair_style(const std::string &new_pair_style, utils::logmesg(lmp,"Creating new pair style: {}\n",new_pair_style); // delete old pair style and create new one - force->create_pair(new_pair_style.c_str(),1); + force->create_pair(new_pair_style,1); // restore current pair settings from temporary file force->pair->read_restart(p_pair_settings_file); @@ -269,7 +267,7 @@ void FixTuneKspace::update_kspace_style(const std::string &new_kspace_style, // delete old kspace style and create new one auto tmp_acc_str = (char *)new_acc_str.c_str(); - force->create_kspace(new_kspace_style.c_str(),1); + force->create_kspace(new_kspace_style,1); force->kspace->settings(1,&tmp_acc_str); force->kspace->differentiation_flag = old_differentiation_flag; force->kspace->slabflag = old_slabflag; @@ -475,8 +473,8 @@ void FixTuneKspace::brent0() void FixTuneKspace::brent1() { - const double CGOLD=0.3819660; - const double ZEPS=numeric_limits::epsilon()*1.0e-3; + constexpr double CGOLD=0.3819660; + const double ZEPS=std::numeric_limits::epsilon()*1.0e-3; double d=0.0,etemp; double p,q,r,tol1,tol2,xm; double e=0.0; @@ -512,8 +510,6 @@ void FixTuneKspace::brent1() dx_brent=(fabs(d) >= tol1 ? x_brent+d : x_brent+SIGN(tol1,d)); first_brent_pass = false; - - return; } /* ---------------------------------------------------------------------- diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index bd2e48aa5b..7377ec6f39 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -2957,8 +2957,6 @@ void PPPMDisp::final_accuracy_6(double& acc, double& acc_real, double& acc_kspac double qopt = compute_qopt_6(); acc_kspace = sqrt(qopt/natoms)*csum/(xprd*yprd*zprd_slab); acc = sqrt(acc_real*acc_real + acc_kspace*acc_kspace); - - return; } /* ---------------------------------------------------------------------- diff --git a/src/MACHDYN/compute_smd_tlsph_stress.cpp b/src/MACHDYN/compute_smd_tlsph_stress.cpp index f8592fec8d..724fff5b88 100644 --- a/src/MACHDYN/compute_smd_tlsph_stress.cpp +++ b/src/MACHDYN/compute_smd_tlsph_stress.cpp @@ -43,7 +43,7 @@ using namespace LAMMPS_NS; /* * deviator of a tensor */ -static Matrix3d Deviator(Matrix3d M) { +static Matrix3d Deviator(const Matrix3d& M) { Matrix3d eye; eye.setIdentity(); eye *= M.trace() / 3.0; diff --git a/src/MACHDYN/compute_smd_ulsph_stress.cpp b/src/MACHDYN/compute_smd_ulsph_stress.cpp index b7bf3fd546..22f563f918 100644 --- a/src/MACHDYN/compute_smd_ulsph_stress.cpp +++ b/src/MACHDYN/compute_smd_ulsph_stress.cpp @@ -42,7 +42,7 @@ using namespace LAMMPS_NS; /* * deviator of a tensor */ -static Matrix3d Deviator(Matrix3d M) { +static Matrix3d Deviator(const Matrix3d& M) { Matrix3d eye; eye.setIdentity(); eye *= M.trace() / 3.0; diff --git a/src/MACHDYN/pair_smd_tlsph.cpp b/src/MACHDYN/pair_smd_tlsph.cpp index ac1ccd7eb2..6a55948426 100644 --- a/src/MACHDYN/pair_smd_tlsph.cpp +++ b/src/MACHDYN/pair_smd_tlsph.cpp @@ -1770,7 +1770,7 @@ void PairTlsph::unpack_forward_comm(int n, int first, double *buf) { ------------------------------------------------------------------------- */ void PairTlsph::effective_longitudinal_modulus(const int itype, const double dt, const double d_iso, const double p_rate, - const Matrix3d d_dev, const Matrix3d sigma_dev_rate, const double /*damage*/, double &K_eff, double &mu_eff, double &M_eff) { + const Matrix3d& d_dev, const Matrix3d& sigma_dev_rate, const double /*damage*/, double &K_eff, double &mu_eff, double &M_eff) { double M0; // initial longitudinal modulus double shear_rate_sq; @@ -1859,7 +1859,7 @@ void PairTlsph::ComputePressure(const int i, const double rho, const double mass /* ---------------------------------------------------------------------- Compute stress deviator. Called from AssembleStress(). ------------------------------------------------------------------------- */ -void PairTlsph::ComputeStressDeviator(const int i, const Matrix3d sigmaInitial_dev, const Matrix3d d_dev, Matrix3d &sigmaFinal_dev, +void PairTlsph::ComputeStressDeviator(const int i, const Matrix3d& sigmaInitial_dev, const Matrix3d& d_dev, Matrix3d &sigmaFinal_dev, Matrix3d &sigma_dev_rate, double &plastic_strain_increment) { double *eff_plastic_strain = atom->eff_plastic_strain; double *eff_plastic_strain_rate = atom->eff_plastic_strain_rate; @@ -1915,7 +1915,7 @@ void PairTlsph::ComputeStressDeviator(const int i, const Matrix3d sigmaInitial_d /* ---------------------------------------------------------------------- Compute damage. Called from AssembleStress(). ------------------------------------------------------------------------- */ -void PairTlsph::ComputeDamage(const int i, const Matrix3d strain, const Matrix3d stress, Matrix3d &/*stress_damaged*/) { +void PairTlsph::ComputeDamage(const int i, const Matrix3d& strain, const Matrix3d& stress, Matrix3d &/*stress_damaged*/) { double *eff_plastic_strain = atom->eff_plastic_strain; double *eff_plastic_strain_rate = atom->eff_plastic_strain_rate; double *radius = atom->radius; diff --git a/src/MACHDYN/pair_smd_tlsph.h b/src/MACHDYN/pair_smd_tlsph.h index e58f51fe76..abcf05ba75 100644 --- a/src/MACHDYN/pair_smd_tlsph.h +++ b/src/MACHDYN/pair_smd_tlsph.h @@ -59,17 +59,17 @@ class PairTlsph : public Pair { void PreCompute(); void ComputeForces(int eflag, int vflag); void effective_longitudinal_modulus(const int itype, const double dt, const double d_iso, - const double p_rate, const Eigen::Matrix3d d_dev, - const Eigen::Matrix3d sigma_dev_rate, const double damage, + const double p_rate, const Eigen::Matrix3d& d_dev, + const Eigen::Matrix3d& sigma_dev_rate, const double damage, double &K_eff, double &mu_eff, double &M_eff); void ComputePressure(const int i, const double rho, const double mass_specific_energy, const double vol_specific_energy, const double pInitial, const double d_iso, double &pFinal, double &p_rate); - void ComputeStressDeviator(const int i, const Eigen::Matrix3d sigmaInitial_dev, - const Eigen::Matrix3d d_dev, Eigen::Matrix3d &sigmaFinal_dev, + void ComputeStressDeviator(const int i, const Eigen::Matrix3d& sigmaInitial_dev, + const Eigen::Matrix3d& d_dev, Eigen::Matrix3d &sigmaFinal_dev, Eigen::Matrix3d &sigma_dev_rate, double &plastic_strain_increment); - void ComputeDamage(const int i, const Eigen::Matrix3d strain, const Eigen::Matrix3d sigmaFinal, + void ComputeDamage(const int i, const Eigen::Matrix3d& strain, const Eigen::Matrix3d& sigmaFinal, Eigen::Matrix3d &sigma_damaged); protected: diff --git a/src/MACHDYN/pair_smd_triangulated_surface.cpp b/src/MACHDYN/pair_smd_triangulated_surface.cpp index cecdf43ff0..a1d1cd4572 100644 --- a/src/MACHDYN/pair_smd_triangulated_surface.cpp +++ b/src/MACHDYN/pair_smd_triangulated_surface.cpp @@ -734,8 +734,8 @@ double PairTriSurf::memory_usage() { % https://www.geometrictools.com/Documentation/DistancePoint3Triangle3.pdf */ -void PairTriSurf::PointTriangleDistance(const Vector3d sourcePosition, const Vector3d TRI0, const Vector3d TRI1, - const Vector3d TRI2, Vector3d &CP, double &dist) { +void PairTriSurf::PointTriangleDistance(const Vector3d& sourcePosition, const Vector3d& TRI0, const Vector3d& TRI1, + const Vector3d& TRI2, Vector3d &CP, double &dist) { Vector3d edge0 = TRI1 - TRI0; Vector3d edge1 = TRI2 - TRI0; diff --git a/src/MACHDYN/pair_smd_triangulated_surface.h b/src/MACHDYN/pair_smd_triangulated_surface.h index ebb04870b8..64acae2576 100644 --- a/src/MACHDYN/pair_smd_triangulated_surface.h +++ b/src/MACHDYN/pair_smd_triangulated_surface.h @@ -47,8 +47,8 @@ class PairTriSurf : public Pair { void init_style() override; void init_list(int, class NeighList *) override; double memory_usage() override; - void PointTriangleDistance(const Eigen::Vector3d P, const Eigen::Vector3d TRI1, - const Eigen::Vector3d TRI2, const Eigen::Vector3d TRI3, + void PointTriangleDistance(const Eigen::Vector3d& P, const Eigen::Vector3d& TRI1, + const Eigen::Vector3d& TRI2, const Eigen::Vector3d& TRI3, Eigen::Vector3d &CP, double &dist); double clamp(const double a, const double min, const double max); void *extract(const char *, int &) override; diff --git a/src/MACHDYN/pair_smd_ulsph.cpp b/src/MACHDYN/pair_smd_ulsph.cpp index d4e7053446..d19f45900f 100644 --- a/src/MACHDYN/pair_smd_ulsph.cpp +++ b/src/MACHDYN/pair_smd_ulsph.cpp @@ -1135,7 +1135,7 @@ void PairULSPH::coeff(int narg, char **arg) { } // end Linear EOS else if (strcmp(arg[ioffset], "*STRENGTH_LINEAR_PLASTIC") == 0) { - if (velocity_gradient != true) { + if (!velocity_gradient) { error->all(FLERR, "A strength model was requested but *VELOCITY_GRADIENT is not set"); } @@ -1180,7 +1180,7 @@ void PairULSPH::coeff(int narg, char **arg) { } // end *STRENGTH_LINEAR_PLASTIC else if (strcmp(arg[ioffset], "*STRENGTH_LINEAR") == 0) { - if (velocity_gradient != true) { + if (!velocity_gradient) { error->all(FLERR, "A strength model was requested but *VELOCITY_GRADIENT is not set"); } @@ -1218,7 +1218,7 @@ void PairULSPH::coeff(int narg, char **arg) { } // end *STRENGTH_LINEAR else if (strcmp(arg[ioffset], "*VISCOSITY_NEWTON") == 0) { - if (velocity_gradient != true) { + if (!velocity_gradient) { error->all(FLERR, "A viscosity model was requested but *VELOCITY_GRADIENT is not set"); } @@ -1581,7 +1581,7 @@ void *PairULSPH::extract(const char *str, int &/*i*/) { compute effective shear modulus by dividing rate of deviatoric stress with rate of shear deformation ------------------------------------------------------------------------- */ -double PairULSPH::effective_shear_modulus(const Matrix3d d_dev, const Matrix3d deltaStressDev, const double dt, const int itype) { +double PairULSPH::effective_shear_modulus(const Matrix3d& d_dev, const Matrix3d& deltaStressDev, const double dt, const int itype) { double G_eff; // effective shear modulus, see Pronto 2d eq. 3.4.7 double deltaStressDevSum, shearRateSq, strain_increment; @@ -1615,8 +1615,8 @@ double PairULSPH::effective_shear_modulus(const Matrix3d d_dev, const Matrix3d d input: particles indices i, j, particle types ityep, jtype ------------------------------------------------------------------------- */ -Vector3d PairULSPH::ComputeHourglassForce(const int i, const int itype, const int j, const int jtype, const Vector3d dv, - const Vector3d xij, const Vector3d g, const double c_ij, const double mu_ij, const double rho_ij) { +Vector3d PairULSPH::ComputeHourglassForce(const int i, const int itype, const int j, const int jtype, const Vector3d& dv, + const Vector3d& xij, const Vector3d& g, const double c_ij, const double mu_ij, const double rho_ij) { double *rmass = atom->rmass; Vector3d dv_est, f_hg; diff --git a/src/MACHDYN/pair_smd_ulsph.h b/src/MACHDYN/pair_smd_ulsph.h index 12fd018738..4f50367e8e 100644 --- a/src/MACHDYN/pair_smd_ulsph.h +++ b/src/MACHDYN/pair_smd_ulsph.h @@ -53,12 +53,12 @@ class PairULSPH : public Pair { void *extract(const char *, int &) override; void PreCompute(); void PreCompute_DensitySummation(); - double effective_shear_modulus(const Eigen::Matrix3d d_dev, const Eigen::Matrix3d deltaStressDev, + double effective_shear_modulus(const Eigen::Matrix3d& d_dev, const Eigen::Matrix3d& deltaStressDev, const double dt, const int itype); Eigen::Vector3d ComputeHourglassForce(const int i, const int itype, const int j, const int jtype, - const Eigen::Vector3d dv, const Eigen::Vector3d xij, - const Eigen::Vector3d g, const double c_ij, + const Eigen::Vector3d& dv, const Eigen::Vector3d& xij, + const Eigen::Vector3d& g, const double c_ij, const double mu_ij, const double rho_ij); protected: diff --git a/src/MACHDYN/smd_material_models.cpp b/src/MACHDYN/smd_material_models.cpp index cee0a3822e..d0c1038f79 100644 --- a/src/MACHDYN/smd_material_models.cpp +++ b/src/MACHDYN/smd_material_models.cpp @@ -184,7 +184,7 @@ void PerfectGasEOS(const double gamma, const double vol, const double mass, cons input: dt: time-step output: sigmaFinal_dev, sigmaFinal_dev_rate__: final stress deviator and its rate. ------------------------------------------------------------------------- */ -void LinearStrength(const double mu, const Matrix3d sigmaInitial_dev, const Matrix3d d_dev, const double dt, +void LinearStrength(const double mu, const Matrix3d& sigmaInitial_dev, const Matrix3d& d_dev, const double dt, Matrix3d &sigmaFinal_dev__, Matrix3d &sigma_dev_rate__) { /* @@ -242,7 +242,7 @@ void LinearStrength(const double mu, const Matrix3d sigmaInitial_dev, const Matr input: dt: time-step output: sigmaFinal_dev, sigmaFinal_dev_rate__: final stress deviator and its rate. ------------------------------------------------------------------------- */ -void LinearPlasticStrength(const double G, const double yieldStress, const Matrix3d sigmaInitial_dev, const Matrix3d d_dev, +void LinearPlasticStrength(const double G, const double yieldStress, const Matrix3d& sigmaInitial_dev, const Matrix3d& d_dev, const double dt, Matrix3d &sigmaFinal_dev__, Matrix3d &sigma_dev_rate__, double &plastic_strain_increment) { Matrix3d sigmaTrial_dev, dev_rate; @@ -314,7 +314,7 @@ void LinearPlasticStrength(const double G, const double yieldStress, const Matri ------------------------------------------------------------------------- */ void JohnsonCookStrength(const double G, const double cp, const double espec, const double A, const double B, const double a, const double C, const double epdot0, const double T0, const double Tmelt, const double /*M*/, const double dt, const double ep, - const double epdot, const Matrix3d sigmaInitial_dev, const Matrix3d d_dev, Matrix3d &sigmaFinal_dev__, + const double epdot, const Matrix3d& sigmaInitial_dev, const Matrix3d& d_dev, Matrix3d &sigmaFinal_dev__, Matrix3d &sigma_dev_rate__, double &plastic_strain_increment) { Matrix3d sigmaTrial_dev, dev_rate; @@ -386,7 +386,7 @@ void JohnsonCookStrength(const double G, const double cp, const double espec, co ------------------------------------------------------------------------- */ -bool IsotropicMaxStrainDamage(const Matrix3d E, const double maxStrain) { +bool IsotropicMaxStrainDamage(const Matrix3d& E, const double maxStrain) { /* * compute Eigenvalues of strain matrix @@ -396,11 +396,7 @@ bool IsotropicMaxStrainDamage(const Matrix3d E, const double maxStrain) { double max_eigenvalue = es.eigenvalues().maxCoeff(); - if (max_eigenvalue > maxStrain) { - return true; - } else { - return false; - } + return max_eigenvalue > maxStrain; } /* ---------------------------------------------------------------------- @@ -414,7 +410,7 @@ bool IsotropicMaxStrainDamage(const Matrix3d E, const double maxStrain) { ------------------------------------------------------------------------- */ -bool IsotropicMaxStressDamage(const Matrix3d S, const double maxStress) { +bool IsotropicMaxStressDamage(const Matrix3d& S, const double maxStress) { /* * compute Eigenvalues of strain matrix @@ -424,11 +420,7 @@ bool IsotropicMaxStressDamage(const Matrix3d S, const double maxStress) { double max_eigenvalue = es.eigenvalues().maxCoeff(); - if (max_eigenvalue > maxStress) { - return true; - } else { - return false; - } + return max_eigenvalue > maxStress; } /* ---------------------------------------------------------------------- @@ -441,7 +433,7 @@ bool IsotropicMaxStressDamage(const Matrix3d S, const double maxStress) { ------------------------------------------------------------------------- */ -double JohnsonCookFailureStrain(const double p, const Matrix3d Sdev, const double d1, const double d2, const double d3, +double JohnsonCookFailureStrain(const double p, const Matrix3d& Sdev, const double d1, const double d2, const double d3, const double d4, const double epdot0, const double epdot) { diff --git a/src/MACHDYN/smd_material_models.h b/src/MACHDYN/smd_material_models.h index df1d830445..dd7130d77a 100644 --- a/src/MACHDYN/smd_material_models.h +++ b/src/MACHDYN/smd_material_models.h @@ -44,18 +44,18 @@ void PerfectGasEOS(const double gamma, const double vol, const double mass, cons /* * Material strength models */ -void LinearStrength(const double mu, const Eigen::Matrix3d sigmaInitial_dev, - const Eigen::Matrix3d d_dev, const double dt, Eigen::Matrix3d &sigmaFinal_dev__, +void LinearStrength(const double mu, const Eigen::Matrix3d& sigmaInitial_dev, + const Eigen::Matrix3d& d_dev, const double dt, Eigen::Matrix3d &sigmaFinal_dev__, Eigen::Matrix3d &sigma_dev_rate__); void LinearPlasticStrength(const double G, const double yieldStress, - const Eigen::Matrix3d sigmaInitial_dev, const Eigen::Matrix3d d_dev, + const Eigen::Matrix3d& sigmaInitial_dev, const Eigen::Matrix3d& d_dev, const double dt, Eigen::Matrix3d &sigmaFinal_dev__, Eigen::Matrix3d &sigma_dev_rate__, double &plastic_strain_increment); void JohnsonCookStrength(const double G, const double cp, const double espec, const double A, const double B, const double a, const double C, const double epdot0, const double T0, const double Tmelt, const double M, const double dt, const double ep, const double epdot, - const Eigen::Matrix3d sigmaInitial_dev, const Eigen::Matrix3d d_dev, + const Eigen::Matrix3d& sigmaInitial_dev, const Eigen::Matrix3d& d_dev, Eigen::Matrix3d &sigmaFinal_dev__, Eigen::Matrix3d &sigma_dev_rate__, double &plastic_strain_increment); @@ -63,9 +63,9 @@ void JohnsonCookStrength(const double G, const double cp, const double espec, co * Damage models */ -bool IsotropicMaxStrainDamage(const Eigen::Matrix3d E, const double maxStrain); -bool IsotropicMaxStressDamage(const Eigen::Matrix3d E, const double maxStrain); -double JohnsonCookFailureStrain(const double p, const Eigen::Matrix3d Sdev, const double d1, +bool IsotropicMaxStrainDamage(const Eigen::Matrix3d& E, const double maxStrain); +bool IsotropicMaxStressDamage(const Eigen::Matrix3d& E, const double maxStrain); +double JohnsonCookFailureStrain(const double p, const Eigen::Matrix3d& Sdev, const double d1, const double d2, const double d3, const double d4, const double epdot0, const double epdot); diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index 4f1c4df4eb..7dcb16d3f6 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -408,7 +408,7 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) // map lat string to an integer std::string lattice_type = values.next_string(); - if (!MEAM::str_to_lat(lattice_type.c_str(), true, lat[index])) + if (!MEAM::str_to_lat(lattice_type, true, lat[index])) error->one(FLERR,"Unrecognized lattice type in MEAM " "library file: {}", lattice_type); diff --git a/src/MISC/fix_imd.cpp b/src/MISC/fix_imd.cpp index da2a110e4d..33a7aa5d2b 100644 --- a/src/MISC/fix_imd.cpp +++ b/src/MISC/fix_imd.cpp @@ -159,8 +159,6 @@ static void rebuild_table_tagint(taginthash_t *tptr) { /* free memory used by old table */ free(old_bucket); - - return; } /* @@ -190,8 +188,6 @@ void taginthash_init(taginthash_t *tptr, tagint buckets) { /* allocate memory for table */ tptr->bucket=(taginthash_node_t **) calloc(tptr->size, sizeof(taginthash_node_t *)); - - return; } /* @@ -579,7 +575,6 @@ FixIMD::~FixIMD() imdsock_destroy(localsock); clientsock=nullptr; localsock=nullptr; - return; } /* ---------------------------------------------------------------------- */ @@ -596,8 +591,6 @@ void FixIMD::init() { if (utils::strmatch(update->integrate_style,"^respa")) nlevels_respa = (dynamic_cast( update->integrate))->nlevels; - - return; } /* ---------------------------------------------------------------------- */ @@ -757,8 +750,7 @@ void FixIMD::setup(int) MPI_Rsend(comm_buf, nme*size_one, MPI_BYTE, 0, 0, world); } - return; -} + } /* worker threads for asynchronous i/o */ #if defined(LAMMPS_ASYNC_IMD) @@ -1139,15 +1131,13 @@ void FixIMD::post_force(int /*vflag*/) MPI_Rsend(comm_buf, nme*size_one, MPI_BYTE, 0, 0, world); } - return; -} + } /* ---------------------------------------------------------------------- */ void FixIMD::post_force_respa(int vflag, int ilevel, int /*iloop*/) { /* only process IMD on the outmost RESPA level. */ if (ilevel == nlevels_respa-1) post_force(vflag); - return; } /* ---------------------------------------------------------------------- */ diff --git a/src/ML-HDNNP/pair_hdnnp.cpp b/src/ML-HDNNP/pair_hdnnp.cpp index f226bb601b..eb79a396b2 100644 --- a/src/ML-HDNNP/pair_hdnnp.cpp +++ b/src/ML-HDNNP/pair_hdnnp.cpp @@ -96,7 +96,7 @@ void PairHDNNP::compute(int eflag, int vflag) interface->process(); // Do all stuff related to extrapolation warnings. - if (showew == true || showewsum > 0 || maxew >= 0) { handleExtrapolationWarnings(); } + if (showew || showewsum > 0 || maxew >= 0) { handleExtrapolationWarnings(); } // Calculate forces of local and ghost atoms. interface->getForces(atom->f); diff --git a/src/ML-IAP/mliap_so3.cpp b/src/ML-IAP/mliap_so3.cpp index 55418c9821..29e436279b 100644 --- a/src/ML-IAP/mliap_so3.cpp +++ b/src/ML-IAP/mliap_so3.cpp @@ -756,8 +756,6 @@ void MLIAP_SO3::get_sbes_array(int nlocal, int *numneighs, double **rij, int lma } } } - - return; } /* ---------------------------------------------------------------------- */ @@ -806,8 +804,6 @@ void MLIAP_SO3::get_rip_array(int nlocal, int *numneighs, double **rij, int nmax integrald * expfac; } } - - return; } /* ---------------------------------------------------------------------- */ @@ -928,8 +924,6 @@ void MLIAP_SO3::spectrum(int nlocal, int *numneighs, int *jelems, double *wjelem } compute_pi(nmax, lmax, m_clisttot_r, m_clisttot_i, m_numYlms, m_plist_r, m_plist_i, ncoefs, ii); } - - return; } /* ---------------------------------------------------------------------- */ diff --git a/src/PTM/ptm_canonical_coloured.cpp b/src/PTM/ptm_canonical_coloured.cpp index e1a338562c..91947c4258 100644 --- a/src/PTM/ptm_canonical_coloured.cpp +++ b/src/PTM/ptm_canonical_coloured.cpp @@ -61,7 +61,7 @@ static bool weinberg_coloured(int num_nodes, int num_edges, int8_t common[PTM_MA c = common[a][b]; } - else if (m[b][a] == false) + else if (!m[b][a]) { //When an old vertex is reached on a new path, go back //in the opposite direction. @@ -75,7 +75,7 @@ static bool weinberg_coloured(int num_nodes, int num_edges, int8_t common[PTM_MA //been traversed in that direction. c = common[a][b]; - while (m[b][c] == true) + while (m[b][c]) c = common[c][b]; } diff --git a/src/PTM/ptm_index.cpp b/src/PTM/ptm_index.cpp index aff81af2e3..453d79dfde 100644 --- a/src/PTM/ptm_index.cpp +++ b/src/PTM/ptm_index.cpp @@ -185,7 +185,7 @@ static void output_data(ptm::result_t *res, double (*points)[3], memcpy(q, res->q, 4 * sizeof(double)); } -extern bool ptm_initialized; + int ptm_index(ptm_local_handle_t local_handle, size_t atom_index, int(get_neighbours)(void *vdata, size_t central_index, size_t atom_index, int num, diff --git a/src/PTM/ptm_voronoi_cell.cpp b/src/PTM/ptm_voronoi_cell.cpp index 10a5710f99..57f0492fbc 100644 --- a/src/PTM/ptm_voronoi_cell.cpp +++ b/src/PTM/ptm_voronoi_cell.cpp @@ -500,7 +500,7 @@ bool voronoicell_base::nplane(vc_class &vc,double x,double y,double z,double rsq break; } } - if (qp==p) return qw==-1?true:false; + if (qp==p) return qw==-1; } // We're about to add the first point of the new facet. In either diff --git a/src/QMMM/fix_qmmm.cpp b/src/QMMM/fix_qmmm.cpp index df1a45ebcb..ee297aa5d0 100644 --- a/src/QMMM/fix_qmmm.cpp +++ b/src/QMMM/fix_qmmm.cpp @@ -121,8 +121,6 @@ static void rebuild_table_tagint(taginthash_t *tptr) { /* free memory used by old table */ free(old_bucket); - - return; } /* @@ -152,8 +150,6 @@ void taginthash_init(taginthash_t *tptr, tagint buckets) { /* allocate memory for table */ tptr->bucket=(taginthash_node_t **) calloc(tptr->size, sizeof(taginthash_node_t *)); - - return; } /* @@ -520,8 +516,6 @@ void FixQMMM::exchange_positions() } } } - - return; } /* ---------------------------------------------------------------------- */ @@ -632,7 +626,6 @@ void FixQMMM::exchange_forces() // use qm_coord array as a communication buffer MPI_Send(reduced_mm_force_on_qm_atoms, 3*num_qm, MPI_DOUBLE, 0, QMMM_TAG_FORCE, mm_comm); } - return; } /* ---------------------------------------------------------------------- */ diff --git a/src/REACTION/fix_bond_react.cpp b/src/REACTION/fix_bond_react.cpp index c05ad4f8b3..6efb9630a2 100644 --- a/src/REACTION/fix_bond_react.cpp +++ b/src/REACTION/fix_bond_react.cpp @@ -2202,7 +2202,7 @@ void FixBondReact::get_customvars() evaulate expression for variable constraint ------------------------------------------------------------------------- */ -double FixBondReact::custom_constraint(std::string varstr) +double FixBondReact::custom_constraint(const std::string& varstr) { int pos,pos1,pos2,pos3,irxnfunc; int prev3 = -1; @@ -2254,8 +2254,8 @@ double FixBondReact::custom_constraint(std::string varstr) currently two 'rxn' functions: rxnsum and rxnave ------------------------------------------------------------------------- */ -double FixBondReact::rxnfunction(std::string rxnfunc, std::string varid, - std::string fragid) +double FixBondReact::rxnfunction(const std::string& rxnfunc, const std::string& varid, + const std::string& fragid) { int ivar = -1; for (int i = 0; i < ncustomvars; i++) { diff --git a/src/REACTION/fix_bond_react.h b/src/REACTION/fix_bond_react.h index 503438ced6..f38fa1f136 100644 --- a/src/REACTION/fix_bond_react.h +++ b/src/REACTION/fix_bond_react.h @@ -181,9 +181,10 @@ class FixBondReact : public Fix { double get_temperature(tagint **, int, int); void customvarnames(); // get per-atom variables names used by custom constraint void get_customvars(); // evaluate local values for variables names used by custom constraint - double custom_constraint(std::string); // evaulate expression for custom constraint - double rxnfunction(std::string, std::string, std::string); // eval rxn_sum and rxn_ave - int get_chirality(double[12]); // get handedness given an ordered set of coordinates + double custom_constraint(const std::string &); // evaulate expression for custom constraint + double rxnfunction(const std::string &, const std::string &, + const std::string &); // eval rxn_sum and rxn_ave + int get_chirality(double[12]); // get handedness given an ordered set of coordinates void open(char *); void readline(char *); diff --git a/src/SMTBQ/pair_smtbq.cpp b/src/SMTBQ/pair_smtbq.cpp index f5649b9214..bf6181cb94 100644 --- a/src/SMTBQ/pair_smtbq.cpp +++ b/src/SMTBQ/pair_smtbq.cpp @@ -3844,8 +3844,6 @@ void PairSMTBQ::gammas(double &na, double &nb, double &za, double &zb, double &r d2zra=d2zra*trm3+rfct1*dgam; d2zrb=d2zrb*trm3; d2gamr2=d2gamr2*trm3; - return; - } /* -------------------------------------------------------------------------------- Css @@ -4010,8 +4008,6 @@ void PairSMTBQ::css(double &s, double nn1, double nn2, double alpha, double beta memory->destroy(a); memory->destroy(b); - - return; } /* ------------------------------------------------------------------------------- coeffs @@ -4063,7 +4059,6 @@ void PairSMTBQ::caintgs (double x, int k, double *a) for (i = 1; i <= k; i++) { a[i+1]=(a[i]*static_cast(i)+cste)*rx; } - return; } /* ----------------------------------------------------------------------------------- Cbintgs diff --git a/src/balance.cpp b/src/balance.cpp index c2f3ee2d5c..0e75419433 100644 --- a/src/balance.cpp +++ b/src/balance.cpp @@ -491,7 +491,7 @@ void Balance::options(int iarg, int narg, char **arg) void Balance::weight_storage(char *prefix) { - std::string cmd = ""; + std::string cmd; if (prefix) cmd = prefix; cmd += "IMBALANCE_WEIGHTS"; diff --git a/src/citeme.cpp b/src/citeme.cpp index c0ab27e37e..e1032f7143 100644 --- a/src/citeme.cpp +++ b/src/citeme.cpp @@ -131,6 +131,5 @@ void CiteMe::flush() logbuffer.clear(); } } - return; } diff --git a/src/imbalance_group.cpp b/src/imbalance_group.cpp index bbd6bc056a..d69bc34ea7 100644 --- a/src/imbalance_group.cpp +++ b/src/imbalance_group.cpp @@ -74,7 +74,7 @@ void ImbalanceGroup::compute(double *weight) std::string ImbalanceGroup::info() { - std::string mesg = ""; + std::string mesg; if (num > 0) { const char *const *const names = group->names; diff --git a/src/info.cpp b/src/info.cpp index f81ed06aa7..2261b1d12d 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -272,12 +272,11 @@ void Info::command(int narg, char **arg) fmt::print(out,"Printed on {:%a %b %d %H:%M:%S %Y}\n", fmt::localtime(now)); if (flags & CONFIG) { - fmt::print(out,"\nLAMMPS version: {} / {}\n", - lmp->version, lmp->num_ver); + fmt::print(out,"\nLAMMPS version: {} / {}\n", lmp->version, lmp->num_ver); - if (lmp->has_git_info()) + if (LAMMPS::has_git_info()) fmt::print(out,"Git info: {} / {} / {}\n", - lmp->git_branch(), lmp->git_descriptor(),lmp->git_commit()); + LAMMPS::git_branch(), LAMMPS::git_descriptor(),LAMMPS::git_commit()); fmt::print(out,"\nOS information: {}\n\n",platform::os_info()); @@ -310,7 +309,7 @@ void Info::command(int narg, char **arg) int ncword, ncline = 0; fputs("\nInstalled packages:\n\n",out); - for (const char **pkg = lmp->installed_packages; *pkg != nullptr; ++pkg) { + for (const char **pkg = LAMMPS::installed_packages; *pkg != nullptr; ++pkg) { ncword = strlen(*pkg); if (ncline + ncword > 78) { ncline = 0; @@ -842,7 +841,7 @@ bool Info::is_active(const char *category, const char *name) if (name_w_suffix == style) match = 1; } } - return match ? true : false; + return match != 0; } /* ---------------------------------------------------------------------- */ @@ -1174,8 +1173,7 @@ bool Info::has_accelerator_feature(const std::string &package, #if defined(LMP_KOKKOS) if (package == "KOKKOS") { if (category == "precision") { - if (setting == "double") return true; - else return false; + return setting == "double"; } if (category == "api") { #if defined(KOKKOS_ENABLE_OPENMP) @@ -1208,8 +1206,7 @@ bool Info::has_accelerator_feature(const std::string &package, #if defined(LMP_OPENMP) if (package == "OPENMP") { if (category == "precision") { - if (setting == "double") return true; - else return false; + return setting == "double"; } if (category == "api") { #if defined(_OPENMP) @@ -1246,7 +1243,7 @@ bool Info::has_accelerator_feature(const std::string &package, std::string Info::get_accelerator_info(const std::string &package) { - std::string mesg(""); + std::string mesg; if ((package.empty() || (package == "GPU")) && has_package("GPU")) { mesg += "GPU package API:"; if (has_accelerator_feature("GPU","api","cuda")) mesg += " CUDA"; diff --git a/src/min_hftn.cpp b/src/min_hftn.cpp index 6786379cd7..d49821bedd 100644 --- a/src/min_hftn.cpp +++ b/src/min_hftn.cpp @@ -87,8 +87,6 @@ MinHFTN::MinHFTN(LAMMPS *lmp) : Min(lmp) _daExtraAtom[i] = nullptr; _fpPrint = nullptr; - - return; } /* ---------------------------------------------------------------------- @@ -103,8 +101,6 @@ MinHFTN::~MinHFTN() for (int i = 0; i < NUM_HFTN_ATOM_BASED_VECTORS; i++) if (_daExtraAtom[i] != nullptr) delete [] _daExtraAtom[i]; - - return; } /* ---------------------------------------------------------------------- @@ -128,8 +124,6 @@ void MinHFTN::init() delete [] _daExtraAtom[i]; _daExtraAtom[i] = nullptr; } - - return; } /* ---------------------------------------------------------------------- @@ -162,8 +156,6 @@ void MinHFTN::setup_style() fix_minimize->add_vector (extra_peratom[m]); } } - - return; } /* ---------------------------------------------------------------------- @@ -196,8 +188,6 @@ void MinHFTN::reset_vectors() _daExtraAtom[i][m] = fix_minimize->request_vector (n++); } } - - return; } /* ---------------------------------------------------------------------- @@ -318,14 +308,14 @@ int MinHFTN::execute_hftn_(const bool bPrintProgress, int nStepType; double dStepLength2; double dStepLengthInf; - if (compute_inner_cg_step_ (dTrustRadius, + if (!compute_inner_cg_step_ (dTrustRadius, dCgForce2StopTol, update->max_eval, bHaveEvaluatedAtX, dCurrentEnergy, dCurrentForce2, dNewEnergy, dNewForce2, nStepType, - dStepLength2, dStepLengthInf) == false) { + dStepLength2, dStepLengthInf)) { //---- THERE WAS AN ERROR. RESTORE TO LAST ACCEPTED STEP. if (nextra_global) modify->min_step (0.0, _daExtraGlobal[VEC_CG_P]); @@ -543,7 +533,7 @@ int MinHFTN::execute_hftn_(const bool bPrintProgress, //---- IF THE LAST STEP WAS REJECTED, THEN REEVALUATE ENERGY AND //---- FORCES AT THE OLD POINT SO THE OUTPUT DOES NOT DISPLAY //---- THE INCREASED ENERGY OF THE REJECTED STEP. - if (bStepAccepted == false) { + if (!bStepAccepted) { dCurrentEnergy = energy_force (1); neval++; } @@ -637,7 +627,7 @@ bool MinHFTN::compute_inner_cg_step_(const double dTrustRadius, //---- OBTAIN THE ENERGY AND FORCES AT THE INPUT POSITION. double dEnergyAtX = dEnergyAtXin; double dForce2AtX = dForce2AtXin; - if (bHaveEvalAtXin == false) { + if (!bHaveEvalAtXin) { dEnergyAtX = energy_force (0); neval++; dForce2AtX = sqrt (fnorm_sqr()); @@ -1030,8 +1020,6 @@ void MinHFTN::calc_dhd_dd_using_mpi_(double & dDHD, } dDHD = daDots[0]; dDD = daDots[1]; - - return; } /* ---------------------------------------------------------------------- @@ -1080,8 +1068,6 @@ void MinHFTN::calc_ppnew_pdold_using_mpi_(double & dPnewDotPnew, dPnewDotPnew = daDots[0]; dPoldDotD = daDots[1]; - - return; } /* ---------------------------------------------------------------------- @@ -1124,7 +1110,6 @@ void MinHFTN::calc_plengths_using_mpi_(double & dStepLength2, dStepLength2 = sqrt (dPP); dStepLengthInf = dPInf; - return; } /* ---------------------------------------------------------------------- @@ -1232,7 +1217,6 @@ void MinHFTN::adjust_step_to_tau_(const double tau) pAtom[i] = d1Atom[i] + (tau * dAtom[i]); } } - return; } /* ---------------------------------------------------------------------- @@ -1281,7 +1265,7 @@ double MinHFTN::compute_to_tr_(const double dPP, double dRootPos = (-dPD + dDiscr) / dDD; double dRootNeg = (-dPD - dDiscr) / dDD; - if (bConsiderBothRoots == false) + if (!bConsiderBothRoots) return( dRootPos ); //---- EVALUATE THE CG OBJECTIVE FUNCTION FOR EACH ROOT. @@ -1603,8 +1587,6 @@ void MinHFTN::evaluate_dir_der_(const bool bUseForwardDiffs, neval++; } } - - return; } /* ---------------------------------------------------------------------- @@ -1627,7 +1609,6 @@ void MinHFTN::open_hftn_print_file_() fprintf (_fpPrint, " Iter Evals Energy |F|_2" " Step TR used |step|_2 ared pred\n"); - return; } /* ---------------------------------------------------------------------- @@ -1693,7 +1674,6 @@ void MinHFTN::hftn_print_line_(const bool bIsStepAccepted, } fflush (_fpPrint); - return; } /* ---------------------------------------------------------------------- @@ -1703,5 +1683,4 @@ void MinHFTN::hftn_print_line_(const bool bIsStepAccepted, void MinHFTN::close_hftn_print_file_() { if (_fpPrint != nullptr) fclose (_fpPrint); - return; } diff --git a/src/platform.cpp b/src/platform.cpp index d37309c043..907b4ef677 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -673,7 +673,7 @@ bool platform::is_console(FILE *fp) std::string platform::current_directory() { - std::string cwd = ""; + std::string cwd; #if defined(_WIN32) char *buf = new char[MAX_PATH]; diff --git a/src/potential_file_reader.cpp b/src/potential_file_reader.cpp index f134892501..8d190efdef 100644 --- a/src/potential_file_reader.cpp +++ b/src/potential_file_reader.cpp @@ -166,7 +166,7 @@ ValueTokenizer PotentialFileReader::next_values(int nparams, const std::string & } catch (FileReaderException &e) { error->one(FLERR, e.what()); } - return ValueTokenizer(""); + return {""}; } /** Read next line and convert first word to a double diff --git a/src/read_dump.cpp b/src/read_dump.cpp index f1dc8fc62e..8af19ee601 100644 --- a/src/read_dump.cpp +++ b/src/read_dump.cpp @@ -286,7 +286,7 @@ bigint ReadDump::seek(bigint nrequest, int exact) if (multiproc) { std::string multiname = files[ifile]; multiname.replace(multiname.find('%'),1,"0"); - readers[0]->open_file(multiname.c_str()); + readers[0]->open_file(multiname); } else readers[0]->open_file(files[ifile]); while (true) { @@ -330,7 +330,7 @@ bigint ReadDump::seek(bigint nrequest, int exact) if (me == 0 && i == 0) continue; // proc 0, reader 0 already found it std::string multiname = files[currentfile]; multiname.replace(multiname.find('%'),1,fmt::format("{}",firstfile+i)); - readers[i]->open_file(multiname.c_str()); + readers[i]->open_file(multiname); bigint step; while (true) { @@ -378,7 +378,7 @@ bigint ReadDump::next(bigint ncurrent, bigint nlast, int nevery, int nskip) if (multiproc) { std::string multiname = files[ifile]; multiname.replace(multiname.find('%'),1,"0"); - readers[0]->open_file(multiname.c_str()); + readers[0]->open_file(multiname); } else readers[0]->open_file(files[ifile]); } @@ -432,7 +432,7 @@ bigint ReadDump::next(bigint ncurrent, bigint nlast, int nevery, int nskip) if (me == 0 && i == 0) continue; std::string multiname = files[currentfile]; multiname.replace(multiname.find('%'),1,fmt::format("{}",firstfile+i)); - readers[i]->open_file(multiname.c_str()); + readers[i]->open_file(multiname); bigint step; while (true) { diff --git a/src/text_file_reader.cpp b/src/text_file_reader.cpp index 6e6b14a519..26124fb924 100644 --- a/src/text_file_reader.cpp +++ b/src/text_file_reader.cpp @@ -215,5 +215,5 @@ ValueTokenizer TextFileReader::next_values(int nparams, const std::string &separ { char *ptr = next_line(nparams); if (ptr == nullptr) throw EOFException(fmt::format("Missing line in {} file!", filetype)); - return ValueTokenizer(line, separators); + return {line, separators}; } diff --git a/src/utils.cpp b/src/utils.cpp index 690bb10b2b..71f90145c8 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -234,7 +234,6 @@ void utils::sfgets(const char *srcname, int srcline, char *s, int size, FILE *fp if (error) error->one(srcname, srcline, errmsg); if (s) *s = '\0'; // truncate string to empty in case error is null pointer } - return; } /* like fread() but aborts with an error or EOF is encountered */ @@ -262,7 +261,6 @@ void utils::sfread(const char *srcname, int srcline, void *s, size_t size, size_ if (error) error->one(srcname, srcline, errmsg); } - return; } /* ------------------------------------------------------------------ */ @@ -303,7 +301,7 @@ std::string utils::check_packages_for_style(const std::string &style, const std: if (pkg) { errmsg += fmt::format(" is part of the {} package", pkg); - if (lmp->is_installed_pkg(pkg)) + if (LAMMPS::is_installed_pkg(pkg)) errmsg += ", but seems to be missing because of a dependency"; else errmsg += " which is not enabled in this LAMMPS binary."; diff --git a/src/variable.cpp b/src/variable.cpp index 51c216fab0..7392379017 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -4594,7 +4594,6 @@ void Variable::print_tree(Tree *tree, int level) if (tree->second) print_tree(tree->second,level+1); if (tree->nextra) for (int i = 0; i < tree->nextra; i++) print_tree(tree->extra[i],level+1); - return; } /* ---------------------------------------------------------------------- diff --git a/tools/lammps-shell/lammps-shell.cpp b/tools/lammps-shell/lammps-shell.cpp index 19730b8552..f4f4db9362 100644 --- a/tools/lammps-shell/lammps-shell.cpp +++ b/tools/lammps-shell/lammps-shell.cpp @@ -144,7 +144,7 @@ static char *dupstring(const std::string &text) return copy; } -static int save_history(std::string range, std::string file) +static int save_history(const std::string &range, const std::string &file) { int from = history_base; int to = from + history_length - 1; diff --git a/unittest/utils/test_platform.cpp b/unittest/utils/test_platform.cpp index a0db06be4a..8101c1adc6 100644 --- a/unittest/utils/test_platform.cpp +++ b/unittest/utils/test_platform.cpp @@ -108,7 +108,7 @@ TEST(Platform, sharedload) double (*doublefunc)(double, int); for (const auto &obj : objs) { - handle = platform::dlopen(obj.c_str()); + handle = platform::dlopen(obj); EXPECT_NE(handle, nullptr); intvar = (int *)platform::dlsym(handle, "some_int_val"); EXPECT_NE(intvar, nullptr);