diff --git a/src/ASPHERE/pair_line_lj.cpp b/src/ASPHERE/pair_line_lj.cpp index c8a3e04dca..07b3ea4e9f 100644 --- a/src/ASPHERE/pair_line_lj.cpp +++ b/src/ASPHERE/pair_line_lj.cpp @@ -301,8 +301,7 @@ void PairLineLJ::compute(int eflag, int vflag) } } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); } } diff --git a/src/ASPHERE/pair_tri_lj.cpp b/src/ASPHERE/pair_tri_lj.cpp index 8585b5792b..6ed422f7a4 100644 --- a/src/ASPHERE/pair_tri_lj.cpp +++ b/src/ASPHERE/pair_tri_lj.cpp @@ -375,8 +375,7 @@ void PairTriLJ::compute(int eflag, int vflag) } } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); } } diff --git a/src/BODY/fix_wall_body_polygon.cpp b/src/BODY/fix_wall_body_polygon.cpp index ec506b15f0..e4d25e8489 100644 --- a/src/BODY/fix_wall_body_polygon.cpp +++ b/src/BODY/fix_wall_body_polygon.cpp @@ -337,8 +337,7 @@ void FixWallBodyPolygon::post_force(int /*vflag*/) num_contacts = 0; facc[0] = facc[1] = facc[2] = 0; - vertex_against_wall(i, wall_pos, x, f, torque, side, - contact_list, num_contacts, facc); + vertex_against_wall(i, wall_pos, x, f, torque, side, contact_list, num_contacts, facc); if (num_contacts >= 2) { diff --git a/src/BODY/pair_body_nparticle.cpp b/src/BODY/pair_body_nparticle.cpp index 8c7c671cb8..c3e146aff0 100644 --- a/src/BODY/pair_body_nparticle.cpp +++ b/src/BODY/pair_body_nparticle.cpp @@ -324,8 +324,7 @@ void PairBodyNparticle::compute(int eflag, int vflag) } } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); } } diff --git a/src/BODY/pair_body_rounded_polygon.cpp b/src/BODY/pair_body_rounded_polygon.cpp index 23a4da7f07..14f305e7d4 100644 --- a/src/BODY/pair_body_rounded_polygon.cpp +++ b/src/BODY/pair_body_rounded_polygon.cpp @@ -207,8 +207,7 @@ void PairBodyRoundedPolygon::compute(int eflag, int vflag) if (r > radi + radj + cut_inner) continue; if (npi == 1 && npj == 1) { - sphere_against_sphere(i, j, delx, dely, delz, rsq, - k_nij, k_naij, x, v, f, evflag); + sphere_against_sphere(i, j, delx, dely, delz, rsq, k_nij, k_naij, x, v, f, evflag); continue; } diff --git a/src/CLASS2/pair_lj_class2.cpp b/src/CLASS2/pair_lj_class2.cpp index 84e571436f..7762e261cd 100644 --- a/src/CLASS2/pair_lj_class2.cpp +++ b/src/CLASS2/pair_lj_class2.cpp @@ -397,8 +397,7 @@ void PairLJClass2::compute_outer(int eflag, int vflag) fpair = factor_lj*forcelj*r2inv; } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); } } } diff --git a/src/COLVARS/fix_colvars.cpp b/src/COLVARS/fix_colvars.cpp index 45e12951bb..cf20c28a7e 100644 --- a/src/COLVARS/fix_colvars.cpp +++ b/src/COLVARS/fix_colvars.cpp @@ -1000,7 +1000,7 @@ double FixColvars::compute_scalar() /* ---------------------------------------------------------------------- */ /* local memory usage. approximately. */ -double FixColvars::memory_usage(void) +double FixColvars::memory_usage() { double bytes = (double) (num_coords * (2*sizeof(int)+3*sizeof(double))); bytes += (double)(double) (nmax*size_one) + sizeof(this); diff --git a/src/COMPRESS/gz_file_writer.cpp b/src/COMPRESS/gz_file_writer.cpp index d56c389d60..cd02832cca 100644 --- a/src/COMPRESS/gz_file_writer.cpp +++ b/src/COMPRESS/gz_file_writer.cpp @@ -1,4 +1,3 @@ -// clang-format off /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -17,46 +16,41 @@ ------------------------------------------------------------------------- */ #include "gz_file_writer.h" -#include #include "fmt/format.h" +#include using namespace LAMMPS_NS; -GzFileWriter::GzFileWriter() : FileWriter(), - compression_level(Z_BEST_COMPRESSION), - gzFp(nullptr) -{ -} +GzFileWriter::GzFileWriter() : FileWriter(), compression_level(Z_BEST_COMPRESSION), gzFp(nullptr) {} /* ---------------------------------------------------------------------- */ GzFileWriter::~GzFileWriter() { - close(); + GzFileWriter::close(); } /* ---------------------------------------------------------------------- */ void GzFileWriter::open(const std::string &path, bool append) { - if (isopen()) return; + if (isopen()) return; - std::string mode; - if (append) { - mode = fmt::format("ab{}", mode, compression_level); - } else { - mode = fmt::format("wb{}", mode, compression_level); - } + std::string mode; + if (append) { + mode = fmt::format("ab{}", mode, compression_level); + } else { + mode = fmt::format("wb{}", mode, compression_level); + } - gzFp = gzopen(path.c_str(), mode.c_str()); + gzFp = gzopen(path.c_str(), mode.c_str()); - if (gzFp == nullptr) - throw FileWriterException(fmt::format("Could not open file '{}'", path)); + if (gzFp == nullptr) throw FileWriterException(fmt::format("Could not open file '{}'", path)); } /* ---------------------------------------------------------------------- */ -size_t GzFileWriter::write(const void * buffer, size_t length) +size_t GzFileWriter::write(const void *buffer, size_t length) { if (!isopen()) return 0; @@ -76,7 +70,7 @@ void GzFileWriter::flush() void GzFileWriter::close() { - if (!isopen()) return; + if (!GzFileWriter::isopen()) return; gzclose(gzFp); gzFp = nullptr; @@ -100,7 +94,8 @@ void GzFileWriter::setCompressionLevel(int level) const int max_level = Z_BEST_COMPRESSION; if (level < min_level || level > max_level) - throw FileWriterException(fmt::format("Compression level must in the range of [{}, {}]", min_level, max_level)); + throw FileWriterException( + fmt::format("Compression level must in the range of [{}, {}]", min_level, max_level)); compression_level = level; } diff --git a/src/COMPRESS/zstd_file_writer.cpp b/src/COMPRESS/zstd_file_writer.cpp index 609a78b216..c628cc0078 100644 --- a/src/COMPRESS/zstd_file_writer.cpp +++ b/src/COMPRESS/zstd_file_writer.cpp @@ -1,4 +1,3 @@ -// clang-format off /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -19,16 +18,13 @@ #ifdef LAMMPS_ZSTD #include "zstd_file_writer.h" -#include #include "fmt/format.h" +#include using namespace LAMMPS_NS; -ZstdFileWriter::ZstdFileWriter() : FileWriter(), - compression_level(0), - checksum_flag(1), - cctx(nullptr), - fp(nullptr) +ZstdFileWriter::ZstdFileWriter() : + FileWriter(), compression_level(0), checksum_flag(1), cctx(nullptr), fp(nullptr) { out_buffer_size = ZSTD_CStreamOutSize(); out_buffer = new char[out_buffer_size]; @@ -38,9 +34,9 @@ ZstdFileWriter::ZstdFileWriter() : FileWriter(), ZstdFileWriter::~ZstdFileWriter() { - close(); + ZstdFileWriter::close(); - delete [] out_buffer; + delete[] out_buffer; out_buffer = nullptr; out_buffer_size = 0; } @@ -49,41 +45,39 @@ ZstdFileWriter::~ZstdFileWriter() void ZstdFileWriter::open(const std::string &path, bool append) { - if (isopen()) return; + if (isopen()) return; - if (append) { - fp = fopen(path.c_str(), "ab"); - } else { - fp = fopen(path.c_str(), "wb"); - } + if (append) { + fp = fopen(path.c_str(), "ab"); + } else { + fp = fopen(path.c_str(), "wb"); + } - if (!fp) { - throw FileWriterException(fmt::format("Could not open file '{}'", path)); - } + if (!fp) { throw FileWriterException(fmt::format("Could not open file '{}'", path)); } - cctx = ZSTD_createCCtx(); + cctx = ZSTD_createCCtx(); - if (!cctx) { - fclose(fp); - fp = nullptr; - throw FileWriterException("Could not create Zstd context"); - } + if (!cctx) { + fclose(fp); + fp = nullptr; + throw FileWriterException("Could not create Zstd context"); + } - ZSTD_CCtx_setParameter(cctx, ZSTD_c_compressionLevel, compression_level); - ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, checksum_flag); + ZSTD_CCtx_setParameter(cctx, ZSTD_c_compressionLevel, compression_level); + ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, checksum_flag); } /* ---------------------------------------------------------------------- */ -size_t ZstdFileWriter::write(const void * buffer, size_t length) +size_t ZstdFileWriter::write(const void *buffer, size_t length) { if (!isopen()) return 0; - ZSTD_inBuffer input = { buffer, length, 0 }; + ZSTD_inBuffer input = {buffer, length, 0}; ZSTD_EndDirective mode = ZSTD_e_continue; do { - ZSTD_outBuffer output = { out_buffer, out_buffer_size, 0 }; + ZSTD_outBuffer output = {out_buffer, out_buffer_size, 0}; ZSTD_compressStream2(cctx, &output, &input, mode); fwrite(out_buffer, sizeof(char), output.pos, fp); } while (input.pos < input.size); @@ -98,11 +92,11 @@ void ZstdFileWriter::flush() if (!isopen()) return; size_t remaining; - ZSTD_inBuffer input = { nullptr, 0, 0 }; + ZSTD_inBuffer input = {nullptr, 0, 0}; ZSTD_EndDirective mode = ZSTD_e_flush; do { - ZSTD_outBuffer output = { out_buffer, out_buffer_size, 0 }; + ZSTD_outBuffer output = {out_buffer, out_buffer_size, 0}; remaining = ZSTD_compressStream2(cctx, &output, &input, mode); fwrite(out_buffer, sizeof(char), output.pos, fp); } while (remaining); @@ -114,14 +108,14 @@ void ZstdFileWriter::flush() void ZstdFileWriter::close() { - if (!isopen()) return; + if (!ZstdFileWriter::isopen()) return; size_t remaining; - ZSTD_inBuffer input = { nullptr, 0, 0 }; + ZSTD_inBuffer input = {nullptr, 0, 0}; ZSTD_EndDirective mode = ZSTD_e_end; do { - ZSTD_outBuffer output = { out_buffer, out_buffer_size, 0 }; + ZSTD_outBuffer output = {out_buffer, out_buffer_size, 0}; remaining = ZSTD_compressStream2(cctx, &output, &input, mode); fwrite(out_buffer, sizeof(char), output.pos, fp); } while (remaining); @@ -150,7 +144,8 @@ void ZstdFileWriter::setCompressionLevel(int level) const int max_level = ZSTD_maxCLevel(); if (level < min_level || level > max_level) - throw FileWriterException(fmt::format("Compression level must in the range of [{}, {}]", min_level, max_level)); + throw FileWriterException( + fmt::format("Compression level must in the range of [{}, {}]", min_level, max_level)); compression_level = level; } @@ -159,8 +154,7 @@ void ZstdFileWriter::setCompressionLevel(int level) void ZstdFileWriter::setChecksum(bool enabled) { - if (isopen()) - throw FileWriterException("Checksum flag can not be changed while file is open"); + if (isopen()) throw FileWriterException("Checksum flag can not be changed while file is open"); checksum_flag = enabled ? 1 : 0; } diff --git a/src/DIELECTRIC/compute_efield_atom.cpp b/src/DIELECTRIC/compute_efield_atom.cpp index c6ea0db94f..e5626c9c6c 100644 --- a/src/DIELECTRIC/compute_efield_atom.cpp +++ b/src/DIELECTRIC/compute_efield_atom.cpp @@ -38,7 +38,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ComputeEfieldAtom::ComputeEfieldAtom(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), efield(NULL) + Compute(lmp, narg, arg), efield(nullptr) { if (narg < 3) error->all(FLERR,"Illegal compute efield/atom command"); diff --git a/src/DIELECTRIC/fix_polarize_bem_gmres.cpp b/src/DIELECTRIC/fix_polarize_bem_gmres.cpp index 62febf13c2..2ea5536722 100644 --- a/src/DIELECTRIC/fix_polarize_bem_gmres.cpp +++ b/src/DIELECTRIC/fix_polarize_bem_gmres.cpp @@ -69,8 +69,8 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ FixPolarizeBEMGMRES::FixPolarizeBEMGMRES(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), q_backup(NULL), c(NULL), g(NULL), h(NULL), r(NULL), s(NULL), v(NULL), - y(NULL) + Fix(lmp, narg, arg), q_backup(nullptr), c(nullptr), g(nullptr), h(nullptr), r(nullptr), s(nullptr), v(nullptr), + y(nullptr) { if (narg < 5) error->all(FLERR, "Illegal fix polarize/bem/gmres command"); @@ -110,7 +110,7 @@ FixPolarizeBEMGMRES::FixPolarizeBEMGMRES(LAMMPS *lmp, int narg, char **arg) : if (atom->torque_flag) torqueflag = 1; if (atom->avec->forceclearflag) extraflag = 1; - grow_arrays(atom->nmax); + FixPolarizeBEMGMRES::grow_arrays(atom->nmax); atom->add_callback(0); // to ensure to work with atom->sort() // output the residual and actual number of iterations @@ -133,7 +133,7 @@ FixPolarizeBEMGMRES::~FixPolarizeBEMGMRES() memory->destroy(mat2tag); memory->destroy(tag2mat); - if (allocated) deallocate(); + if (allocated) FixPolarizeBEMGMRES::deallocate(); atom->delete_callback(id, 0); } diff --git a/src/DIELECTRIC/fix_polarize_functional.cpp b/src/DIELECTRIC/fix_polarize_functional.cpp index 84f68e79b1..34c1ba2f60 100644 --- a/src/DIELECTRIC/fix_polarize_functional.cpp +++ b/src/DIELECTRIC/fix_polarize_functional.cpp @@ -131,7 +131,7 @@ FixPolarizeFunctional::FixPolarizeFunctional(LAMMPS *lmp, int narg, char **arg) cg_r = cg_p = cg_Ap = nullptr; cg_A = nullptr; - grow_arrays(atom->nmax); + FixPolarizeFunctional::grow_arrays(atom->nmax); atom->add_callback(0); // to ensure to work with atom->sort() } diff --git a/src/DIELECTRIC/pair_coul_long_dielectric.cpp b/src/DIELECTRIC/pair_coul_long_dielectric.cpp index fd5110cdb6..a079c3abf7 100644 --- a/src/DIELECTRIC/pair_coul_long_dielectric.cpp +++ b/src/DIELECTRIC/pair_coul_long_dielectric.cpp @@ -221,10 +221,10 @@ void PairCoulLongDielectric::init_style() // insure use of KSpace long-range solver, set g_ewald - if (force->kspace == NULL) error->all(FLERR, "Pair style requires a KSpace style"); + if (force->kspace == nullptr) error->all(FLERR, "Pair style requires a KSpace style"); g_ewald = force->kspace->g_ewald; // setup force tables - if (ncoultablebits) init_tables(cut_coul, NULL); + if (ncoultablebits) init_tables(cut_coul, nullptr); } diff --git a/src/DIELECTRIC/pair_lj_cut_coul_debye_dielectric.cpp b/src/DIELECTRIC/pair_lj_cut_coul_debye_dielectric.cpp index 4f3b46b14d..8c90e1f84b 100644 --- a/src/DIELECTRIC/pair_lj_cut_coul_debye_dielectric.cpp +++ b/src/DIELECTRIC/pair_lj_cut_coul_debye_dielectric.cpp @@ -40,8 +40,8 @@ using namespace MathConst; PairLJCutCoulDebyeDielectric::PairLJCutCoulDebyeDielectric(LAMMPS *lmp) : PairLJCutCoulDebye(lmp) { - efield = NULL; - epot = NULL; + efield = nullptr; + epot = nullptr; nmax = 0; } diff --git a/src/DIELECTRIC/pair_lj_cut_coul_long_dielectric.cpp b/src/DIELECTRIC/pair_lj_cut_coul_long_dielectric.cpp index 7f5b67a22b..bbb8bba728 100644 --- a/src/DIELECTRIC/pair_lj_cut_coul_long_dielectric.cpp +++ b/src/DIELECTRIC/pair_lj_cut_coul_long_dielectric.cpp @@ -257,7 +257,7 @@ void PairLJCutCoulLongDielectric::init_style() // insure use of KSpace long-range solver, set g_ewald - if (force->kspace == NULL) error->all(FLERR, "Pair style requires a KSpace style"); + if (force->kspace == nullptr) error->all(FLERR, "Pair style requires a KSpace style"); g_ewald = force->kspace->g_ewald; // setup force tables diff --git a/src/DIELECTRIC/pair_lj_cut_coul_msm_dielectric.cpp b/src/DIELECTRIC/pair_lj_cut_coul_msm_dielectric.cpp index 5fd8b499f8..e22ee4b665 100644 --- a/src/DIELECTRIC/pair_lj_cut_coul_msm_dielectric.cpp +++ b/src/DIELECTRIC/pair_lj_cut_coul_msm_dielectric.cpp @@ -365,7 +365,7 @@ void PairLJCutCoulMSMDielectric::init_style() // insure use of KSpace long-range solver, set g_ewald - if (force->kspace == NULL) error->all(FLERR, "Pair style requires a KSpace style"); + if (force->kspace == nullptr) error->all(FLERR, "Pair style requires a KSpace style"); g_ewald = force->kspace->g_ewald; // setup force tables @@ -382,5 +382,5 @@ void *PairLJCutCoulMSMDielectric::extract(const char *str, int &dim) dim = 2; if (strcmp(str, "epsilon") == 0) return (void *) epsilon; if (strcmp(str, "sigma") == 0) return (void *) sigma; - return NULL; + return nullptr; } diff --git a/src/DPD-REACT/fix_rx.cpp b/src/DPD-REACT/fix_rx.cpp index 91eb3f54df..a37a6ad7b6 100644 --- a/src/DPD-REACT/fix_rx.cpp +++ b/src/DPD-REACT/fix_rx.cpp @@ -59,7 +59,7 @@ namespace /* anonymous */ { typedef double TimerType; -TimerType getTimeStamp(void) { return MPI_Wtime(); } +TimerType getTimeStamp() { return MPI_Wtime(); } double getElapsedTime( const TimerType &t0, const TimerType &t1) { return t1-t0; } } // end namespace @@ -1246,7 +1246,7 @@ int FixRX::rkf45_h0 (const int neq, const double t, const double /*t_stop*/, return (iter + 1); } -void FixRX::odeDiagnostics(void) +void FixRX::odeDiagnostics() { TimerType timer_start = getTimeStamp(); diff --git a/src/DPD-SMOOTH/fix_meso_move.cpp b/src/DPD-SMOOTH/fix_meso_move.cpp index 85eee5ffbe..ba32962b3c 100644 --- a/src/DPD-SMOOTH/fix_meso_move.cpp +++ b/src/DPD-SMOOTH/fix_meso_move.cpp @@ -224,7 +224,7 @@ FixMesoMove::FixMesoMove (LAMMPS *lmp, int narg, char **arg) : // perform initial allocation of atom-based array // register with Atom class - grow_arrays(atom->nmax); + FixMesoMove::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); atom->add_callback(Atom::RESTART); diff --git a/src/DRUDE/fix_drude.cpp b/src/DRUDE/fix_drude.cpp index e0b313c35e..39b0158e06 100644 --- a/src/DRUDE/fix_drude.cpp +++ b/src/DRUDE/fix_drude.cpp @@ -55,7 +55,7 @@ FixDrude::FixDrude(LAMMPS *lmp, int narg, char **arg) : } drudeid = nullptr; - grow_arrays(atom->nmax); + FixDrude::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); atom->add_callback(Atom::RESTART); atom->add_callback(Atom::BORDER); @@ -516,7 +516,8 @@ void FixDrude::ring_copy_drude(int size, char *cbuf, void *ptr) { * ----------------------------------------------------------------------*/ void FixDrude::set_arrays(int i) { if (drudetype[atom->type[i]] != NOPOL_TYPE) { - if (atom->nspecial[i] ==0) error->all(FLERR, "Polarizable atoms cannot be inserted with special lists info from the molecule template"); + if (atom->nspecial[i] == nullptr) + error->all(FLERR, "Polarizable atoms cannot be inserted with special lists info from the molecule template"); drudeid[i] = atom->special[i][0]; // Drude partner should be at first place in the special list } else { drudeid[i] = 0; diff --git a/src/EXTRA-FIX/fix_flow_gauss.cpp b/src/EXTRA-FIX/fix_flow_gauss.cpp index 1a48488ab6..415f1eecc0 100644 --- a/src/EXTRA-FIX/fix_flow_gauss.cpp +++ b/src/EXTRA-FIX/fix_flow_gauss.cpp @@ -84,14 +84,14 @@ FixFlowGauss::FixFlowGauss(LAMMPS *lmp, int narg, char **arg) : // by default, do not compute work done - workflag=0; + workflag=false; // process optional keyword int iarg = 6; while (iarg < narg) { if (strcmp(arg[iarg],"energy") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal energy keyword"); - if (strcmp(arg[iarg+1],"yes") == 0) workflag = 1; + if (strcmp(arg[iarg+1],"yes") == 0) workflag = true; else if (strcmp(arg[iarg+1],"no") != 0) error->all(FLERR,"Illegal energy keyword"); iarg += 2; @@ -139,7 +139,7 @@ void FixFlowGauss::setup(int vflag) { // need to compute work done if fix_modify energy yes is set - if (thermo_energy) workflag = 1; + if (thermo_energy) workflag = true; // get total mass of group diff --git a/src/EXTRA-FIX/fix_ttm_grid.cpp b/src/EXTRA-FIX/fix_ttm_grid.cpp index cbefc09aef..accc792b4a 100644 --- a/src/EXTRA-FIX/fix_ttm_grid.cpp +++ b/src/EXTRA-FIX/fix_ttm_grid.cpp @@ -366,7 +366,7 @@ void FixTTMGrid::write_electron_temperatures(const std::string &filename) update->unit_style, nxgrid, nygrid, nzgrid, update->ntimestep, style); } - gc->gather(GridComm::FIX, this, 1, sizeof(double), 1, NULL, MPI_DOUBLE); + gc->gather(GridComm::FIX, this, 1, sizeof(double), 1, nullptr, MPI_DOUBLE); if (comm->me == 0) fclose(FPout); } diff --git a/src/EXTRA-FIX/fix_ttm_mod.cpp b/src/EXTRA-FIX/fix_ttm_mod.cpp index 905232ff08..cec97bd280 100644 --- a/src/EXTRA-FIX/fix_ttm_mod.cpp +++ b/src/EXTRA-FIX/fix_ttm_mod.cpp @@ -101,7 +101,7 @@ FixTTMMod::FixTTMMod(LAMMPS *lmp, int narg, char **arg) : nzgrid = utils::inumeric(FLERR,arg[7],false,lmp); double tinit = 0.0; - infile = outfile = NULL; + infile = outfile = nullptr; int iarg = 8; while (iarg < narg) { diff --git a/src/EXTRA-PAIR/pair_lj96_cut.cpp b/src/EXTRA-PAIR/pair_lj96_cut.cpp index b20ebf2c88..a762e7de6b 100644 --- a/src/EXTRA-PAIR/pair_lj96_cut.cpp +++ b/src/EXTRA-PAIR/pair_lj96_cut.cpp @@ -376,8 +376,7 @@ void PairLJ96Cut::compute_outer(int eflag, int vflag) r2inv = 1.0/rsq; r6inv = r2inv*r2inv*r2inv; r3inv = sqrt(r6inv); - evdwl = r6inv*(lj3[itype][jtype]*r3inv-lj4[itype][jtype]) - - offset[itype][jtype]; + evdwl = r6inv*(lj3[itype][jtype]*r3inv-lj4[itype][jtype]) - offset[itype][jtype]; evdwl *= factor_lj; } @@ -392,8 +391,7 @@ void PairLJ96Cut::compute_outer(int eflag, int vflag) fpair = factor_lj*forcelj*r2inv; } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); } } } diff --git a/src/EXTRA-PAIR/pair_lj_expand_coul_long.cpp b/src/EXTRA-PAIR/pair_lj_expand_coul_long.cpp index 685871db3b..2791c28747 100644 --- a/src/EXTRA-PAIR/pair_lj_expand_coul_long.cpp +++ b/src/EXTRA-PAIR/pair_lj_expand_coul_long.cpp @@ -195,14 +195,12 @@ void PairLJExpandCoulLong::compute(int eflag, int vflag) } else ecoul = 0.0; if (rsq < cut_ljsq[itype][jtype]) { - evdwl = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - - offset[itype][jtype]; + evdwl = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - offset[itype][jtype]; evdwl *= factor_lj; } else evdwl = 0.0; } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,ecoul,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,ecoul,fpair,delx,dely,delz); } } } @@ -980,8 +978,7 @@ double PairLJExpandCoulLong::single(int i, int j, int itype, int jtype, } if (rsq < cut_ljsq[itype][jtype]) { - philj = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - - offset[itype][jtype]; + philj = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - offset[itype][jtype]; eng += factor_lj*philj; } diff --git a/src/EXTRA-PAIR/pair_lj_gromacs_coul_gromacs.cpp b/src/EXTRA-PAIR/pair_lj_gromacs_coul_gromacs.cpp index 9db42342d9..96b8985b6b 100644 --- a/src/EXTRA-PAIR/pair_lj_gromacs_coul_gromacs.cpp +++ b/src/EXTRA-PAIR/pair_lj_gromacs_coul_gromacs.cpp @@ -164,16 +164,14 @@ void PairLJGromacsCoulGromacs::compute(int eflag, int vflag) evdwl = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]); evdwl += ljsw5[itype][jtype]; if (rsq > cut_lj_innersq) { - eswitch = tlj*tlj*tlj * - (ljsw3[itype][jtype] + ljsw4[itype][jtype]*tlj); + eswitch = tlj*tlj*tlj * (ljsw3[itype][jtype] + ljsw4[itype][jtype]*tlj); evdwl += eswitch; } evdwl *= factor_lj; } else evdwl = 0.0; } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,ecoul,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,ecoul,fpair,delx,dely,delz); } } } @@ -487,8 +485,7 @@ double PairLJGromacsCoulGromacs::single(int i, int j, int itype, int jtype, if (rsq < cut_coulsq) { phicoul = force->qqrd2e * atom->q[i]*atom->q[j] * (sqrt(r2inv)-coulsw5); if (rsq > cut_coul_innersq) { - phiswitchcoul = force->qqrd2e * atom->q[i]*atom->q[j] * - tc*tc*tc * (coulsw3 + coulsw4*tc); + phiswitchcoul = force->qqrd2e * atom->q[i]*atom->q[j] * tc*tc*tc * (coulsw3 + coulsw4*tc); phicoul += phiswitchcoul; } eng += factor_coul*phicoul; @@ -498,8 +495,7 @@ double PairLJGromacsCoulGromacs::single(int i, int j, int itype, int jtype, philj = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]); philj += ljsw5[itype][jtype]; if (rsq > cut_lj_innersq) { - phiswitch = tlj*tlj*tlj * - (ljsw3[itype][jtype] + ljsw4[itype][jtype]*tlj); + phiswitch = tlj*tlj*tlj * (ljsw3[itype][jtype] + ljsw4[itype][jtype]*tlj); philj += phiswitch; } eng += factor_lj*philj; diff --git a/src/EXTRA-PAIR/pair_lj_relres.cpp b/src/EXTRA-PAIR/pair_lj_relres.cpp index 1ea3684171..5d1ed4fdf0 100644 --- a/src/EXTRA-PAIR/pair_lj_relres.cpp +++ b/src/EXTRA-PAIR/pair_lj_relres.cpp @@ -183,15 +183,13 @@ void PairLJRelRes::compute(int eflag, int vflag) if (eflag) { if (rsq < cutf_inner_sq[itype][jtype]) { - evdwl = r6inv*(ljf3[itype][jtype]*r6inv- - ljf4[itype][jtype])-offsetsm[itype][jtype]; + evdwl = r6inv*(ljf3[itype][jtype]*r6inv-ljf4[itype][jtype])-offsetsm[itype][jtype]; } else if (rsq < cutfsq[itype][jtype]) { evdwl = ljswf0[itype][jtype]-ljswf1[itype][jtype]*t- ljswf2[itype][jtype]*tsq/2.0-ljswf3[itype][jtype]*tsq*t/3.0- ljswf4[itype][jtype]*tsq*tsq/4.0-offsetsp[itype][jtype]; } else if (rsq < cut_inner_sq[itype][jtype]) { - evdwl = r6inv*(lj3[itype][jtype]*r6inv- - lj4[itype][jtype])-offset[itype][jtype]; + evdwl = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype])-offset[itype][jtype]; } else { evdwl = ljsw0[itype][jtype]-ljsw1[itype][jtype]*t- ljsw2[itype][jtype]*tsq/2.0-ljsw3[itype][jtype]*tsq*t/3.0- @@ -200,8 +198,7 @@ void PairLJRelRes::compute(int eflag, int vflag) evdwl *= factor_lj; } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); } } } @@ -726,15 +723,13 @@ double PairLJRelRes::single(int /*i*/, int /*j*/, int itype, int jtype, fforce = factor_lj*forcelj*r2inv; if (rsq < cutf_inner_sq[itype][jtype]) { - philj = r6inv*(ljf3[itype][jtype]*r6inv- - ljf4[itype][jtype])-offsetsm[itype][jtype]; + philj = r6inv*(ljf3[itype][jtype]*r6inv-ljf4[itype][jtype])-offsetsm[itype][jtype]; } else if (rsq < cutfsq[itype][jtype]) { philj = ljswf0[itype][jtype]-ljswf1[itype][jtype]*t- ljswf2[itype][jtype]*tsq/2.0-ljswf3[itype][jtype]*tsq*t/3.0- ljswf4[itype][jtype]*tsq*tsq/4.0-offsetsp[itype][jtype]; } else if (rsq < cut_inner_sq[itype][jtype]) { - philj = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]) - - offset[itype][jtype]; + philj = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]) - offset[itype][jtype]; } else { philj = ljsw0[itype][jtype] - ljsw1[itype][jtype]*t - ljsw2[itype][jtype]*tsq/2.0 - ljsw3[itype][jtype]*tsq*t/3.0 - diff --git a/src/EXTRA-PAIR/pair_lj_smooth.cpp b/src/EXTRA-PAIR/pair_lj_smooth.cpp index f1aba212a3..5346a39e62 100644 --- a/src/EXTRA-PAIR/pair_lj_smooth.cpp +++ b/src/EXTRA-PAIR/pair_lj_smooth.cpp @@ -136,8 +136,7 @@ void PairLJSmooth::compute(int eflag, int vflag) if (eflag) { if (rsq < cut_inner_sq[itype][jtype]) - evdwl = r6inv * (lj3[itype][jtype]*r6inv - - lj4[itype][jtype]) - offset[itype][jtype]; + evdwl = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]) - offset[itype][jtype]; else evdwl = ljsw0[itype][jtype] - ljsw1[itype][jtype]*t - ljsw2[itype][jtype]*tsq/2.0 - ljsw3[itype][jtype]*tsq*t/3.0 - @@ -145,8 +144,7 @@ void PairLJSmooth::compute(int eflag, int vflag) evdwl *= factor_lj; } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); } } } @@ -446,8 +444,7 @@ double PairLJSmooth::single(int /*i*/, int /*j*/, int itype, int jtype, double r fforce = factor_lj*forcelj*r2inv; if (rsq < cut_inner_sq[itype][jtype]) - philj = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]) - - offset[itype][jtype]; + philj = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]) - offset[itype][jtype]; else philj = ljsw0[itype][jtype] - ljsw1[itype][jtype]*t - ljsw2[itype][jtype]*tsq/2.0 - ljsw3[itype][jtype]*tsq*t/3.0 - diff --git a/src/EXTRA-PAIR/pair_nm_cut_coul_cut.cpp b/src/EXTRA-PAIR/pair_nm_cut_coul_cut.cpp index 6c2dd433de..a0e31d3070 100644 --- a/src/EXTRA-PAIR/pair_nm_cut_coul_cut.cpp +++ b/src/EXTRA-PAIR/pair_nm_cut_coul_cut.cpp @@ -147,17 +147,13 @@ void PairNMCutCoulCut::compute(int eflag, int vflag) ecoul = factor_coul * qqrd2e * qtmp*q[j]*sqrt(r2inv); else ecoul = 0.0; if (rsq < cut_ljsq[itype][jtype]) { - evdwl = e0nm[itype][jtype]*(mm[itype][jtype] * - r0n[itype][jtype]*rninv - - nn[itype][jtype] * - r0m[itype][jtype]*rminv) - - offset[itype][jtype]; + evdwl = e0nm[itype][jtype]*(mm[itype][jtype] * r0n[itype][jtype]*rninv - + nn[itype][jtype] * r0m[itype][jtype]*rminv) - offset[itype][jtype]; evdwl *= factor_lj; } else evdwl = 0.0; } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,ecoul,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,ecoul,fpair,delx,dely,delz); } } } diff --git a/src/FEP/pair_lj_cut_coul_long_soft.cpp b/src/FEP/pair_lj_cut_coul_long_soft.cpp index 0d81fb17cd..0e43e72a17 100644 --- a/src/FEP/pair_lj_cut_coul_long_soft.cpp +++ b/src/FEP/pair_lj_cut_coul_long_soft.cpp @@ -178,8 +178,7 @@ void PairLJCutCoulLongSoft::compute(int eflag, int vflag) } else evdwl = 0.0; } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,ecoul,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,ecoul,fpair,delx,dely,delz); } } } diff --git a/src/FEP/pair_lj_cut_soft.cpp b/src/FEP/pair_lj_cut_soft.cpp index 0934a91255..e4c2d19e95 100644 --- a/src/FEP/pair_lj_cut_soft.cpp +++ b/src/FEP/pair_lj_cut_soft.cpp @@ -410,8 +410,7 @@ void PairLJCutSoft::compute_outer(int eflag, int vflag) fpair = factor_lj*forcelj; } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); } } } diff --git a/src/KSPACE/fft3d.cpp b/src/KSPACE/fft3d.cpp index 130aaebf21..d35028f280 100644 --- a/src/KSPACE/fft3d.cpp +++ b/src/KSPACE/fft3d.cpp @@ -308,10 +308,9 @@ struct fft_plan_3d *fft_3d_create_plan( first_jhi = (ip1+1)*nmid/np1 - 1; first_klo = ip2*nslow/np2; first_khi = (ip2+1)*nslow/np2 - 1; - plan->pre_plan = - remap_3d_create_plan(comm,in_ilo,in_ihi,in_jlo,in_jhi,in_klo,in_khi, - first_ilo,first_ihi,first_jlo,first_jhi, - first_klo,first_khi,2,0,0,FFT_PRECISION,0); + plan->pre_plan = remap_3d_create_plan(comm,in_ilo,in_ihi,in_jlo,in_jhi,in_klo,in_khi, + first_ilo,first_ihi,first_jlo,first_jhi, + first_klo,first_khi,2,0,0,FFT_PRECISION,0); if (plan->pre_plan == nullptr) return nullptr; } @@ -330,13 +329,10 @@ struct fft_plan_3d *fft_3d_create_plan( second_jhi = nmid - 1; second_klo = ip2*nslow/np2; second_khi = (ip2+1)*nslow/np2 - 1; - plan->mid1_plan = - remap_3d_create_plan(comm, - first_ilo,first_ihi,first_jlo,first_jhi, - first_klo,first_khi, - second_ilo,second_ihi,second_jlo,second_jhi, - second_klo,second_khi,2,1,0,FFT_PRECISION, - usecollective); + plan->mid1_plan = remap_3d_create_plan(comm, first_ilo,first_ihi,first_jlo,first_jhi, + first_klo,first_khi,second_ilo,second_ihi, + second_jlo,second_jhi,second_klo,second_khi, + 2,1,0,FFT_PRECISION,usecollective); if (plan->mid1_plan == nullptr) return nullptr; // 1d FFTs along mid axis diff --git a/src/MANYBODY/pair_eam_fs.cpp b/src/MANYBODY/pair_eam_fs.cpp index b4596a297b..cf552995d0 100644 --- a/src/MANYBODY/pair_eam_fs.cpp +++ b/src/MANYBODY/pair_eam_fs.cpp @@ -125,8 +125,6 @@ void PairEAMFS::read_file(char *filename) // transparently convert units for supported conversions - // transparently convert units for supported conversions - int unit_convert = reader.get_unit_convert(); double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); diff --git a/src/MDI/fix_mdi_engine.cpp b/src/MDI/fix_mdi_engine.cpp index a898647563..4c8e9cccf4 100644 --- a/src/MDI/fix_mdi_engine.cpp +++ b/src/MDI/fix_mdi_engine.cpp @@ -32,8 +32,8 @@ #include "update.h" #include "verlet.h" +#include #include -#include enum { NONE, REAL, METAL }; // LAMMPS units which MDI supports diff --git a/src/MDI/mdi_engine.cpp b/src/MDI/mdi_engine.cpp index 9bd9258dfc..f1143fbe28 100644 --- a/src/MDI/mdi_engine.cpp +++ b/src/MDI/mdi_engine.cpp @@ -31,8 +31,8 @@ #include "update.h" #include "verlet.h" +#include #include -#include using namespace LAMMPS_NS; diff --git a/src/fix_box_relax.cpp b/src/fix_box_relax.cpp index 8783e12b75..e80a4db593 100644 --- a/src/fix_box_relax.cpp +++ b/src/fix_box_relax.cpp @@ -329,13 +329,12 @@ FixBoxRelax::FixBoxRelax(LAMMPS *lmp, int narg, char **arg) : // pass id_temp as 4th arg to pressure constructor id_press = utils::strdup(std::string(id) + "_press"); - modify->add_compute(fmt::format("{} all pressure {} virial", - id_press, id_temp)); + modify->add_compute(fmt::format("{} all pressure {} virial",id_press, id_temp)); pflag = 1; dimension = domain->dimension; nrigid = 0; - rfix = 0; + rfix = nullptr; current_lifo = 0; } diff --git a/src/fix_efield.cpp b/src/fix_efield.cpp index 98cecd8a01..f752585206 100644 --- a/src/fix_efield.cpp +++ b/src/fix_efield.cpp @@ -428,7 +428,7 @@ double FixEfield::memory_usage() return energy added by fix ------------------------------------------------------------------------- */ -double FixEfield::compute_scalar(void) +double FixEfield::compute_scalar() { if (force_flag == 0) { MPI_Allreduce(fsum,fsum_all,4,MPI_DOUBLE,MPI_SUM,world); diff --git a/src/imbalance.cpp b/src/imbalance.cpp index 80cbd8654a..e6ecacbfa0 100644 --- a/src/imbalance.cpp +++ b/src/imbalance.cpp @@ -1,4 +1,3 @@ -// clang-format off /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories diff --git a/src/imbalance_group.cpp b/src/imbalance_group.cpp index e674338e76..bbd6bc056a 100644 --- a/src/imbalance_group.cpp +++ b/src/imbalance_group.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -22,45 +21,43 @@ using namespace LAMMPS_NS; /* -------------------------------------------------------------------- */ -ImbalanceGroup::ImbalanceGroup(LAMMPS *lmp) : Imbalance(lmp), id(0), factor(0) -{} +ImbalanceGroup::ImbalanceGroup(LAMMPS *lmp) : Imbalance(lmp), id(nullptr), factor(nullptr) {} /* -------------------------------------------------------------------- */ ImbalanceGroup::~ImbalanceGroup() { - delete [] id; - delete [] factor; + delete[] id; + delete[] factor; } /* -------------------------------------------------------------------- */ int ImbalanceGroup::options(int narg, char **arg) { - if (narg < 3) error->all(FLERR,"Illegal balance weight command"); + if (narg < 3) error->all(FLERR, "Illegal balance weight command"); - num = utils::inumeric(FLERR,arg[0],false,lmp); - if (num < 1) error->all(FLERR,"Illegal balance weight command"); - if (2*num+1 > narg) error->all(FLERR,"Illegal balance weight command"); + num = utils::inumeric(FLERR, arg[0], false, lmp); + if (num < 1) error->all(FLERR, "Illegal balance weight command"); + if (2 * num + 1 > narg) error->all(FLERR, "Illegal balance weight command"); id = new int[num]; factor = new double[num]; for (int i = 0; i < num; ++i) { - id[i] = group->find(arg[2*i+1]); - if (id[i] < 0) - error->all(FLERR,"Unknown group in balance weight command: {}", arg[2*i+1]); - factor[i] = utils::numeric(FLERR,arg[2*i+2],false,lmp); - if (factor[i] <= 0.0) error->all(FLERR,"Illegal balance weight command"); + id[i] = group->find(arg[2 * i + 1]); + if (id[i] < 0) error->all(FLERR, "Unknown group in balance weight command: {}", arg[2 * i + 1]); + factor[i] = utils::numeric(FLERR, arg[2 * i + 2], false, lmp); + if (factor[i] <= 0.0) error->all(FLERR, "Illegal balance weight command"); } - return 2*num+1; + return 2 * num + 1; } /* -------------------------------------------------------------------- */ void ImbalanceGroup::compute(double *weight) { - const int * const mask = atom->mask; - const int * const bitmask = group->bitmask; + const int *const mask = atom->mask; + const int *const bitmask = group->bitmask; const int nlocal = atom->nlocal; if (num == 0) return; @@ -68,8 +65,7 @@ void ImbalanceGroup::compute(double *weight) for (int i = 0; i < nlocal; ++i) { const int imask = mask[i]; for (int j = 0; j < num; ++j) { - if (imask & bitmask[id[j]]) - weight[i] *= factor[j]; + if (imask & bitmask[id[j]]) weight[i] *= factor[j]; } } } @@ -81,11 +77,10 @@ std::string ImbalanceGroup::info() std::string mesg = ""; if (num > 0) { - const char * const * const names = group->names; + const char *const *const names = group->names; mesg += " group weights:"; - for (int i = 0; i < num; ++i) - mesg += fmt::format(" {}={}",names[id[i]],factor[i]); + for (int i = 0; i < num; ++i) mesg += fmt::format(" {}={}", names[id[i]], factor[i]); mesg += "\n"; } return mesg; diff --git a/src/imbalance_store.cpp b/src/imbalance_store.cpp index 2437395dda..598fb88bee 100644 --- a/src/imbalance_store.cpp +++ b/src/imbalance_store.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -21,20 +20,20 @@ using namespace LAMMPS_NS; /* -------------------------------------------------------------------- */ -ImbalanceStore::ImbalanceStore(LAMMPS *lmp) : Imbalance(lmp), name(0) {} +ImbalanceStore::ImbalanceStore(LAMMPS *lmp) : Imbalance(lmp), name(nullptr) {} /* -------------------------------------------------------------------- */ ImbalanceStore::~ImbalanceStore() { - delete [] name; + delete[] name; } /* -------------------------------------------------------------------- */ int ImbalanceStore::options(int narg, char **arg) { - if (narg < 1) error->all(FLERR,"Illegal balance weight command"); + if (narg < 1) error->all(FLERR, "Illegal balance weight command"); name = utils::strdup(arg[0]); return 1; @@ -44,13 +43,13 @@ int ImbalanceStore::options(int narg, char **arg) void ImbalanceStore::compute(double *weight) { - int flag,cols; - int index = atom->find_custom(name,flag,cols); + int flag, cols; + int index = atom->find_custom(name, flag, cols); // property does not exist if (index < 0 || flag != 1 || cols) - error->all(FLERR,"Balance weight store vector does not exist"); + error->all(FLERR, "Balance weight store vector does not exist"); double *prop = atom->dvector[index]; const int nlocal = atom->nlocal; @@ -61,5 +60,5 @@ void ImbalanceStore::compute(double *weight) std::string ImbalanceStore::info() { - return fmt::format(" storing weight in atom property d_{}\n",name); + return fmt::format(" storing weight in atom property d_{}\n", name); } diff --git a/src/imbalance_time.cpp b/src/imbalance_time.cpp index 8c5104381d..8f27938a68 100644 --- a/src/imbalance_time.cpp +++ b/src/imbalance_time.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -30,9 +29,9 @@ ImbalanceTime::ImbalanceTime(LAMMPS *lmp) : Imbalance(lmp) {} int ImbalanceTime::options(int narg, char **arg) { - if (narg < 1) error->all(FLERR,"Illegal balance weight command"); - factor = utils::numeric(FLERR,arg[0],false,lmp); - if (factor <= 0.0) error->all(FLERR,"Illegal balance weight command"); + if (narg < 1) error->all(FLERR, "Illegal balance weight command"); + factor = utils::numeric(FLERR, arg[0], false, lmp); + if (factor <= 0.0) error->all(FLERR, "Illegal balance weight command"); return 1; } @@ -71,14 +70,14 @@ void ImbalanceTime::compute(double *weight) cost += 0.1; double maxcost; - MPI_Allreduce(&cost,&maxcost,1,MPI_DOUBLE,MPI_MAX,world); + MPI_Allreduce(&cost, &maxcost, 1, MPI_DOUBLE, MPI_MAX, world); if (maxcost <= 0.1) return; int nlocal = atom->nlocal; double localwt = 0.0; - if (nlocal) localwt = cost/nlocal; + if (nlocal) localwt = cost / nlocal; - if (nlocal && localwt <= 0.0) error->one(FLERR,"Balance weight <= 0.0"); + if (nlocal && localwt <= 0.0) error->one(FLERR, "Balance weight <= 0.0"); // apply factor if specified != 1.0 // wtlo,wthi = lo/hi values excluding 0.0 due to no atoms on this proc @@ -87,15 +86,15 @@ void ImbalanceTime::compute(double *weight) // expand/contract all localwt values from lo->hi to lo->newhi if (factor != 1.0) { - double wtlo,wthi; + double wtlo, wthi; if (localwt == 0.0) localwt = BIG; - MPI_Allreduce(&localwt,&wtlo,1,MPI_DOUBLE,MPI_MIN,world); + MPI_Allreduce(&localwt, &wtlo, 1, MPI_DOUBLE, MPI_MIN, world); if (localwt == BIG) localwt = 0.0; - MPI_Allreduce(&localwt,&wthi,1,MPI_DOUBLE,MPI_MAX,world); + MPI_Allreduce(&localwt, &wthi, 1, MPI_DOUBLE, MPI_MAX, world); if (wtlo == wthi) return; - double newhi = wthi*factor; - localwt = wtlo + ((localwt-wtlo)/(wthi-wtlo)) * (newhi-wtlo); + double newhi = wthi * factor; + localwt = wtlo + ((localwt - wtlo) / (wthi - wtlo)) * (newhi - wtlo); } for (int i = 0; i < nlocal; i++) weight[i] *= localwt; @@ -109,5 +108,5 @@ void ImbalanceTime::compute(double *weight) std::string ImbalanceTime::info() { - return fmt::format(" time weight factor: {}\n",factor); + return fmt::format(" time weight factor: {}\n", factor); } diff --git a/src/imbalance_var.cpp b/src/imbalance_var.cpp index 8679216b94..4b1099c767 100644 --- a/src/imbalance_var.cpp +++ b/src/imbalance_var.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -25,20 +24,20 @@ using namespace LAMMPS_NS; /* -------------------------------------------------------------------- */ -ImbalanceVar::ImbalanceVar(LAMMPS *lmp) : Imbalance(lmp), name(0) {} +ImbalanceVar::ImbalanceVar(LAMMPS *lmp) : Imbalance(lmp), name(nullptr) {} /* -------------------------------------------------------------------- */ ImbalanceVar::~ImbalanceVar() { - delete [] name; + delete[] name; } /* -------------------------------------------------------------------- */ int ImbalanceVar::options(int narg, char **arg) { - if (narg < 1) error->all(FLERR,"Illegal balance weight command"); + if (narg < 1) error->all(FLERR, "Illegal balance weight command"); name = utils::strdup(arg[0]); init(0); @@ -51,10 +50,10 @@ void ImbalanceVar::init(int /*flag*/) { id = input->variable->find(name); if (id < 0) { - error->all(FLERR,"Variable name for balance weight does not exist"); + error->all(FLERR, "Variable name for balance weight does not exist"); } else { if (input->variable->atomstyle(id) == 0) - error->all(FLERR,"Variable for balance weight has invalid style"); + error->all(FLERR, "Variable for balance weight has invalid style"); } } @@ -67,16 +66,16 @@ void ImbalanceVar::compute(double *weight) double *values; const int nlocal = atom->nlocal; - memory->create(values,nlocal,"imbalance:values"); + memory->create(values, nlocal, "imbalance:values"); - input->variable->compute_atom(id,all,values,1,0); + input->variable->compute_atom(id, all, values, 1, 0); int flag = 0; for (int i = 0; i < nlocal; i++) if (values[i] <= 0.0) flag = 1; int flagall; - MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); - if (flagall) error->one(FLERR,"Balance weight <= 0.0"); + MPI_Allreduce(&flag, &flagall, 1, MPI_INT, MPI_SUM, world); + if (flagall) error->one(FLERR, "Balance weight <= 0.0"); for (int i = 0; i < nlocal; i++) weight[i] *= values[i]; @@ -87,5 +86,5 @@ void ImbalanceVar::compute(double *weight) std::string ImbalanceVar::info() { - return fmt::format(" weight variable: {}\n",name); + return fmt::format(" weight variable: {}\n", name); } diff --git a/src/min_hftn.cpp b/src/min_hftn.cpp index 1c9ff0b237..e743f1e1da 100644 --- a/src/min_hftn.cpp +++ b/src/min_hftn.cpp @@ -893,7 +893,7 @@ bool MinHFTN::compute_inner_cg_step_(const double dTrustRadius, Private method calc_xinf_using_mpi_ ------------------------------------------------------------------------- */ -double MinHFTN::calc_xinf_using_mpi_(void) const +double MinHFTN::calc_xinf_using_mpi_() const { double dXInfLocal = 0.0; for (int i = 0; i < nvec; i++) @@ -1162,7 +1162,7 @@ bool MinHFTN::step_exceeds_TR_(const double dTrustRadius, which calls fix_box_relax->max_alpha ------------------------------------------------------------------------- */ -bool MinHFTN::step_exceeds_DMAX_(void) const +bool MinHFTN::step_exceeds_DMAX_() const { double dAlpha = dmax * sqrt((double) _nNumUnknowns); @@ -1611,7 +1611,7 @@ void MinHFTN::evaluate_dir_der_(const bool bUseForwardDiffs, Private method open_hftn_print_file_ ------------------------------------------------------------------------- */ -void MinHFTN::open_hftn_print_file_(void) +void MinHFTN::open_hftn_print_file_() { int nMyRank; MPI_Comm_rank (world, &nMyRank); @@ -1700,7 +1700,7 @@ void MinHFTN::hftn_print_line_(const bool bIsStepAccepted, Private method close_hftn_print_file_ ------------------------------------------------------------------------- */ -void MinHFTN::close_hftn_print_file_(void) +void MinHFTN::close_hftn_print_file_() { if (_fpPrint != nullptr) fclose (_fpPrint); return; diff --git a/src/npair_half_size_multi_newtoff.cpp b/src/npair_half_size_multi_newtoff.cpp index cb06ddfb6f..4c9d9b3f62 100644 --- a/src/npair_half_size_multi_newtoff.cpp +++ b/src/npair_half_size_multi_newtoff.cpp @@ -12,7 +12,6 @@ es certain rights in this software. This software is distributed under See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include #include "npair_half_size_multi_newtoff.h" #include "atom.h" diff --git a/src/nstencil.cpp b/src/nstencil.cpp index fdd0ddfb1b..e79bd69d29 100644 --- a/src/nstencil.cpp +++ b/src/nstencil.cpp @@ -346,7 +346,7 @@ void NStencil::create_setup() // Skip all stencils by default, initialize smax for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { - flag_skip_multi[i][j] = 1; + flag_skip_multi[i][j] = true; } } diff --git a/src/nstencil_full_multi_2d.cpp b/src/nstencil_full_multi_2d.cpp index 308eab71ee..22912c5866 100644 --- a/src/nstencil_full_multi_2d.cpp +++ b/src/nstencil_full_multi_2d.cpp @@ -37,8 +37,8 @@ void NStencilFullMulti2d::set_stencil_properties() for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { - flag_half_multi[i][j] = 0; - flag_skip_multi[i][j] = 0; + flag_half_multi[i][j] = false; + flag_skip_multi[i][j] = false; bin_collection_multi[i][j] = j; } } diff --git a/src/nstencil_full_multi_3d.cpp b/src/nstencil_full_multi_3d.cpp index 22e5f8b4e3..f317253baa 100644 --- a/src/nstencil_full_multi_3d.cpp +++ b/src/nstencil_full_multi_3d.cpp @@ -38,8 +38,8 @@ void NStencilFullMulti3d::set_stencil_properties() for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { - flag_half_multi[i][j] = 0; - flag_skip_multi[i][j] = 0; + flag_half_multi[i][j] = true; + flag_skip_multi[i][j] = false; bin_collection_multi[i][j] = j; } } diff --git a/src/nstencil_half_multi_2d.cpp b/src/nstencil_half_multi_2d.cpp index 8bf6ce8404..08d3ed7d6d 100644 --- a/src/nstencil_half_multi_2d.cpp +++ b/src/nstencil_half_multi_2d.cpp @@ -43,13 +43,13 @@ void NStencilHalfMulti2d::set_stencil_properties() for (j = 0; j < n; j++) { if(cutcollectionsq[i][i] > cutcollectionsq[j][j]) continue; - flag_skip_multi[i][j] = 0; + flag_skip_multi[i][j] = false; if(cutcollectionsq[i][i] == cutcollectionsq[j][j]){ - flag_half_multi[i][j] = 1; + flag_half_multi[i][j] = true; bin_collection_multi[i][j] = i; } else { - flag_half_multi[i][j] = 0; + flag_half_multi[i][j] = false; bin_collection_multi[i][j] = j; } } diff --git a/src/nstencil_half_multi_2d_tri.cpp b/src/nstencil_half_multi_2d_tri.cpp index ffddb55061..4de841897e 100644 --- a/src/nstencil_half_multi_2d_tri.cpp +++ b/src/nstencil_half_multi_2d_tri.cpp @@ -43,13 +43,13 @@ void NStencilHalfMulti2dTri::set_stencil_properties() for (j = 0; j < n; j++) { if(cutcollectionsq[i][i] > cutcollectionsq[j][j]) continue; - flag_skip_multi[i][j] = 0; + flag_skip_multi[i][j] = false; if(cutcollectionsq[i][i] == cutcollectionsq[j][j]){ - flag_half_multi[i][j] = 1; + flag_half_multi[i][j] = true; bin_collection_multi[i][j] = i; } else { - flag_half_multi[i][j] = 0; + flag_half_multi[i][j] = false; bin_collection_multi[i][j] = j; } } diff --git a/src/nstencil_half_multi_3d.cpp b/src/nstencil_half_multi_3d.cpp index d6fae6ebec..3465663e47 100644 --- a/src/nstencil_half_multi_3d.cpp +++ b/src/nstencil_half_multi_3d.cpp @@ -43,13 +43,13 @@ void NStencilHalfMulti3d::set_stencil_properties() for (j = 0; j < n; j++) { if(cutcollectionsq[i][i] > cutcollectionsq[j][j]) continue; - flag_skip_multi[i][j] = 0; + flag_skip_multi[i][j] = false; if(cutcollectionsq[i][i] == cutcollectionsq[j][j]){ - flag_half_multi[i][j] = 1; + flag_half_multi[i][j] = true; bin_collection_multi[i][j] = i; } else { - flag_half_multi[i][j] = 0; + flag_half_multi[i][j] = false; bin_collection_multi[i][j] = j; } } diff --git a/src/nstencil_half_multi_3d_tri.cpp b/src/nstencil_half_multi_3d_tri.cpp index 7625a58cd7..d7f9a8e01a 100644 --- a/src/nstencil_half_multi_3d_tri.cpp +++ b/src/nstencil_half_multi_3d_tri.cpp @@ -43,13 +43,13 @@ void NStencilHalfMulti3dTri::set_stencil_properties() for (j = 0; j < n; j++) { if(cutcollectionsq[i][i] > cutcollectionsq[j][j]) continue; - flag_skip_multi[i][j] = 0; + flag_skip_multi[i][j] = false; if(cutcollectionsq[i][i] == cutcollectionsq[j][j]){ - flag_half_multi[i][j] = 1; + flag_half_multi[i][j] = true; bin_collection_multi[i][j] = i; } else { - flag_half_multi[i][j] = 0; + flag_half_multi[i][j] = false; bin_collection_multi[i][j] = j; } } diff --git a/src/output.cpp b/src/output.cpp index 90513619d3..9e29caf118 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -317,7 +317,7 @@ void Output::write(bigint ntimestep) if (next_restart_single == ntimestep) { std::string file = restart1; - std::size_t found = file.find("*"); + std::size_t found = file.find('*'); if (found != std::string::npos) file.replace(found,1,fmt::format("{}",update->ntimestep)); @@ -405,7 +405,7 @@ void Output::write_restart(bigint ntimestep) { if (restart_flag_single) { std::string file = restart1; - std::size_t found = file.find("*"); + std::size_t found = file.find('*'); if (found != std::string::npos) file.replace(found,1,fmt::format("{}",update->ntimestep)); restart->write(file); diff --git a/src/pair.cpp b/src/pair.cpp index 16979f8023..6edc8dc831 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -758,8 +758,7 @@ void Pair::add_tally_callback(Compute *ptr) if (found < 0) { found = num_tally_compute; ++num_tally_compute; - void *p = memory->srealloc((void *)list_tally_compute, - sizeof(Compute *) * num_tally_compute, + void *p = memory->srealloc((void *)list_tally_compute, sizeof(Compute *) * num_tally_compute, "pair:list_tally_compute"); list_tally_compute = (Compute **) p; list_tally_compute[num_tally_compute-1] = ptr; diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index 0ba16f29fa..67e0a70249 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -476,7 +476,7 @@ void PairHybrid::coeff(int narg, char **arg) // 4th arg = pair sub-style index if name used multiple times // allow for "none" as valid sub-style name - int multflag; + int multflag = 0; int m; for (m = 0; m < nstyles; m++) { diff --git a/src/pair_hybrid_overlay.cpp b/src/pair_hybrid_overlay.cpp index 09fd676dd3..db12750f40 100644 --- a/src/pair_hybrid_overlay.cpp +++ b/src/pair_hybrid_overlay.cpp @@ -42,7 +42,7 @@ void PairHybridOverlay::coeff(int narg, char **arg) // 4th arg = pair sub-style index if name used multiple times // allow for "none" as valid sub-style name - int multflag; + int multflag = 0; int m; for (m = 0; m < nstyles; m++) { @@ -128,7 +128,7 @@ void PairHybridOverlay::init_svector() void PairHybridOverlay::copy_svector(int itype, int jtype) { int n=0; - Pair *this_style; + Pair *this_style = nullptr; // fill svector array. // copy data from active styles and use 0.0 for inactive ones diff --git a/src/pair_hybrid_scaled.cpp b/src/pair_hybrid_scaled.cpp index 367afe7809..90e30dd9b2 100644 --- a/src/pair_hybrid_scaled.cpp +++ b/src/pair_hybrid_scaled.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -32,9 +31,8 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -PairHybridScaled::PairHybridScaled(LAMMPS *lmp) - : PairHybrid(lmp), fsum(nullptr), tsum(nullptr), - scaleval(nullptr), scaleidx(nullptr) +PairHybridScaled::PairHybridScaled(LAMMPS *lmp) : + PairHybrid(lmp), fsum(nullptr), tsum(nullptr), scaleval(nullptr), scaleidx(nullptr) { nmaxfsum = -1; } @@ -63,7 +61,7 @@ PairHybridScaled::~PairHybridScaled() void PairHybridScaled::compute(int eflag, int vflag) { - int i,j,m,n; + int i, j, m, n; // update scale values from variables where needed @@ -73,13 +71,11 @@ void PairHybridScaled::compute(int eflag, int vflag) for (i = 0; i < nvars; ++i) { j = input->variable->find(scalevars[i].c_str()); if (j < 0) - error->all(FLERR,"Variable '{}' not found when updating " - "scale factors",scalevars[i]); + error->all(FLERR, "Variable '{}' not found when updating scale factors", scalevars[i]); vals[i] = input->variable->compute_equal(j); } for (i = 0; i < nstyles; ++i) { - if (scaleidx[i] >= 0) - scaleval[i] = vals[scaleidx[i]]; + if (scaleidx[i] >= 0) scaleval[i] = vals[scaleidx[i]]; } delete[] vals; } @@ -92,7 +88,7 @@ void PairHybridScaled::compute(int eflag, int vflag) if (no_virial_fdotr_compute && (vflag & VIRIAL_FDOTR)) vflag = VIRIAL_PAIR | (vflag & ~VIRIAL_FDOTR); - ev_init(eflag,vflag); + ev_init(eflag, vflag); // grow fsum array if needed, and copy existing forces (usually 0.0) to it. @@ -100,8 +96,8 @@ void PairHybridScaled::compute(int eflag, int vflag) memory->destroy(fsum); if (atom->torque_flag) memory->destroy(tsum); nmaxfsum = atom->nmax; - memory->create(fsum,nmaxfsum,3,"pair:fsum"); - if (atom->torque_flag) memory->create(tsum,nmaxfsum,3,"pair:tsum"); + memory->create(fsum, nmaxfsum, 3, "pair:fsum"); + if (atom->torque_flag) memory->create(tsum, nmaxfsum, 3, "pair:tsum"); } const int nall = atom->nlocal + atom->nghost; auto f = atom->f; @@ -122,8 +118,10 @@ void PairHybridScaled::compute(int eflag, int vflag) // necessary so substyle will not invoke virial_fdotr_compute() int vflag_substyle; - if (vflag & VIRIAL_FDOTR) vflag_substyle = vflag & ~VIRIAL_FDOTR; - else vflag_substyle = vflag; + if (vflag & VIRIAL_FDOTR) + vflag_substyle = vflag & ~VIRIAL_FDOTR; + else + vflag_substyle = vflag; double *saved_special = save_special(); @@ -131,7 +129,7 @@ void PairHybridScaled::compute(int eflag, int vflag) Respa *respa = nullptr; respaflag = 0; - if (utils::strmatch(update->integrate_style,"^respa")) { + if (utils::strmatch(update->integrate_style, "^respa")) { respa = (Respa *) update->integrate; if (respa->nhybrid_styles > 0) respaflag = 1; } @@ -140,8 +138,8 @@ void PairHybridScaled::compute(int eflag, int vflag) // clear forces and torques - memset(&f[0][0],0,nall*3*sizeof(double)); - if (atom->torque_flag) memset(&t[0][0],0,nall*3*sizeof(double)); + memset(&f[0][0], 0, nall * 3 * sizeof(double)); + if (atom->torque_flag) memset(&t[0][0], 0, nall * 3 * sizeof(double)); set_special(m); @@ -152,20 +150,21 @@ void PairHybridScaled::compute(int eflag, int vflag) if (styles[m]->compute_flag == 0) continue; if (outerflag && styles[m]->respa_enable) - styles[m]->compute_outer(eflag,vflag_substyle); - else styles[m]->compute(eflag,vflag_substyle); + styles[m]->compute_outer(eflag, vflag_substyle); + else + styles[m]->compute(eflag, vflag_substyle); } // add scaled forces to global sum const double scale = scaleval[m]; for (i = 0; i < nall; ++i) { - fsum[i][0] += scale*f[i][0]; - fsum[i][1] += scale*f[i][1]; - fsum[i][2] += scale*f[i][2]; + fsum[i][0] += scale * f[i][0]; + fsum[i][1] += scale * f[i][1]; + fsum[i][2] += scale * f[i][2]; if (atom->torque_flag) { - tsum[i][0] += scale*t[i][0]; - tsum[i][1] += scale*t[i][1]; - tsum[i][2] += scale*t[i][2]; + tsum[i][0] += scale * t[i][0]; + tsum[i][1] += scale * t[i][1]; + tsum[i][2] += scale * t[i][2]; } } @@ -176,25 +175,24 @@ void PairHybridScaled::compute(int eflag, int vflag) if (respaflag && !respa->tally_global) continue; if (eflag_global) { - eng_vdwl += scale*styles[m]->eng_vdwl; - eng_coul += scale*styles[m]->eng_coul; + eng_vdwl += scale * styles[m]->eng_vdwl; + eng_coul += scale * styles[m]->eng_coul; } if (vflag_global) { - for (n = 0; n < 6; n++) virial[n] += scale*styles[m]->virial[n]; + for (n = 0; n < 6; n++) virial[n] += scale * styles[m]->virial[n]; } if (eflag_atom) { n = atom->nlocal; if (force->newton_pair) n += atom->nghost; double *eatom_substyle = styles[m]->eatom; - for (i = 0; i < n; i++) eatom[i] += scale*eatom_substyle[i]; + for (i = 0; i < n; i++) eatom[i] += scale * eatom_substyle[i]; } if (vflag_atom) { n = atom->nlocal; if (force->newton_pair) n += atom->nghost; double **vatom_substyle = styles[m]->vatom; for (i = 0; i < n; i++) - for (j = 0; j < 6; j++) - vatom[i][j] += scale*vatom_substyle[i][j]; + for (j = 0; j < 6; j++) vatom[i][j] += scale * vatom_substyle[i][j]; } // substyles may be CENTROID_SAME or CENTROID_AVAIL @@ -205,17 +203,12 @@ void PairHybridScaled::compute(int eflag, int vflag) if (styles[m]->centroidstressflag == CENTROID_AVAIL) { double **cvatom_substyle = styles[m]->cvatom; for (i = 0; i < n; i++) - for (j = 0; j < 9; j++) - cvatom[i][j] += scale*cvatom_substyle[i][j]; + for (j = 0; j < 9; j++) cvatom[i][j] += scale * cvatom_substyle[i][j]; } else { double **vatom_substyle = styles[m]->vatom; for (i = 0; i < n; i++) { - for (j = 0; j < 6; j++) { - cvatom[i][j] += scale*vatom_substyle[i][j]; - } - for (j = 6; j < 9; j++) { - cvatom[i][j] += scale*vatom_substyle[i][j-3]; - } + for (j = 0; j < 6; j++) { cvatom[i][j] += scale * vatom_substyle[i][j]; } + for (j = 6; j < 9; j++) { cvatom[i][j] += scale * vatom_substyle[i][j - 3]; } } } } @@ -233,7 +226,7 @@ void PairHybridScaled::compute(int eflag, int vflag) t[i][2] = tsum[i][2]; } } - delete [] saved_special; + delete[] saved_special; if (vflag_fdotr) virial_fdotr_compute(); } @@ -244,22 +237,21 @@ void PairHybridScaled::compute(int eflag, int vflag) void PairHybridScaled::settings(int narg, char **arg) { - if (narg < 1) error->all(FLERR,"Illegal pair_style command"); - if (lmp->kokkos && !utils::strmatch(force->pair_style,"^hybrid.*/kk$")) - error->all(FLERR,"Must use pair_style {}/kk with Kokkos", - force->pair_style); + if (narg < 1) error->all(FLERR, "Illegal pair_style command"); + if (lmp->kokkos && !utils::strmatch(force->pair_style, "^hybrid.*/kk$")) + error->all(FLERR, "Must use pair_style {}/kk with Kokkos", force->pair_style); if (atom->avec->forceclearflag) - error->all(FLERR,"Atom style is not compatible with pair_style hybrid/scaled"); + error->all(FLERR, "Atom style is not compatible with pair_style hybrid/scaled"); // delete old lists, since cannot just change settings if (nstyles > 0) { for (int m = 0; m < nstyles; m++) { delete styles[m]; - delete [] keywords[m]; - if (special_lj[m]) delete [] special_lj[m]; - if (special_coul[m]) delete [] special_coul[m]; + delete[] keywords[m]; + if (special_lj[m]) delete[] special_lj[m]; + if (special_coul[m]) delete[] special_coul[m]; } delete[] styles; delete[] keywords; @@ -283,12 +275,12 @@ void PairHybridScaled::settings(int narg, char **arg) // allocate list of sub-styles as big as possibly needed if no extra args - styles = new Pair*[narg]; - keywords = new char*[narg]; + styles = new Pair *[narg]; + keywords = new char *[narg]; multiple = new int[narg]; - special_lj = new double*[narg]; - special_coul = new double*[narg]; + special_lj = new double *[narg]; + special_coul = new double *[narg]; compute_tally = new int[narg]; scaleval = new double[narg]; @@ -301,62 +293,63 @@ void PairHybridScaled::settings(int narg, char **arg) // call settings() with set of args that are not pair style names // use force->pair_map to determine which args these are - int iarg,jarg,dummy; + int iarg, jarg, dummy; iarg = 0; nstyles = 0; - while (iarg < narg-1) { + while (iarg < narg - 1) { // first process scale factor or variable // idx < 0 indicates constant value otherwise index in variable name list double val = 0.0; int idx = -1; - if (utils::strmatch(arg[iarg],"^v_")) { - for (std::size_t i=0; i < scalevars.size(); ++i) { - if (scalevars[i] == arg[iarg]+2) { + if (utils::strmatch(arg[iarg], "^v_")) { + for (std::size_t i = 0; i < scalevars.size(); ++i) { + if (scalevars[i] == arg[iarg] + 2) { idx = i; break; } } if (idx < 0) { idx = scalevars.size(); - scalevars.push_back(arg[iarg]+2); + scalevars.emplace_back(arg[iarg] + 2); } } else { - val = utils::numeric(FLERR,arg[iarg],false,lmp); + val = utils::numeric(FLERR, arg[iarg], false, lmp); } scaleval[nstyles] = val; scaleidx[nstyles] = idx; ++iarg; - if (utils::strmatch(arg[iarg],"^hybrid")) - error->all(FLERR,"Pair style hybrid/scaled cannot have hybrid as an argument"); - if (strcmp(arg[iarg],"none") == 0) - error->all(FLERR,"Pair style hybrid/scaled cannot have none as an argument"); + if (utils::strmatch(arg[iarg], "^hybrid")) + error->all(FLERR, "Pair style hybrid/scaled cannot have hybrid as an argument"); + if (strcmp(arg[iarg], "none") == 0) + error->all(FLERR, "Pair style hybrid/scaled cannot have none as an argument"); - styles[nstyles] = force->new_pair(arg[iarg],1,dummy); - force->store_style(keywords[nstyles],arg[iarg],0); + styles[nstyles] = force->new_pair(arg[iarg], 1, dummy); + force->store_style(keywords[nstyles], arg[iarg], 0); special_lj[nstyles] = special_coul[nstyles] = nullptr; compute_tally[nstyles] = 1; - if ((styles[nstyles]->suffix_flag & (Suffix::INTEL|Suffix::GPU|Suffix::OMP)) != 0) - error->all(FLERR,"Pair style hybrid/scaled does not support " + if ((styles[nstyles]->suffix_flag & (Suffix::INTEL | Suffix::GPU | Suffix::OMP)) != 0) + error->all(FLERR, + "Pair style hybrid/scaled does not support " "accelerator styles"); // determine list of arguments for pair style settings // by looking for the next known pair style name. jarg = iarg + 1; - while ((jarg < narg) - && !force->pair_map->count(arg[jarg]) - && !lmp->match_style("pair",arg[jarg])) jarg++; + while ((jarg < narg) && !force->pair_map->count(arg[jarg]) && + !lmp->match_style("pair", arg[jarg])) + jarg++; // decrement to account for scale factor except when last argument if (jarg < narg) --jarg; - styles[nstyles]->settings(jarg-iarg-1,arg+iarg+1); + styles[nstyles]->settings(jarg - iarg - 1, arg + iarg + 1); iarg = jarg; nstyles++; } @@ -366,7 +359,7 @@ void PairHybridScaled::settings(int narg, char **arg) for (int i = 0; i < nstyles; i++) { int count = 0; for (int j = 0; j < nstyles; j++) { - if (strcmp(keywords[j],keywords[i]) == 0) count++; + if (strcmp(keywords[j], keywords[i]) == 0) count++; if (j == i) multiple[i] = count; } if (count == 1) multiple[i] = 0; @@ -383,11 +376,10 @@ void PairHybridScaled::settings(int narg, char **arg) since overlay could have multiple sub-styles, sum results explicitly ------------------------------------------------------------------------- */ -double PairHybridScaled::single(int i, int j, int itype, int jtype, double rsq, - double factor_coul, double factor_lj, double &fforce) +double PairHybridScaled::single(int i, int j, int itype, int jtype, double rsq, double factor_coul, + double factor_lj, double &fforce) { - if (nmap[itype][jtype] == 0) - error->one(FLERR,"Invoked pair single on pair style none"); + if (nmap[itype][jtype] == 0) error->one(FLERR, "Invoked pair single on pair style none"); // update scale values from variables where needed @@ -397,13 +389,11 @@ double PairHybridScaled::single(int i, int j, int itype, int jtype, double rsq, for (i = 0; i < nvars; ++i) { j = input->variable->find(scalevars[i].c_str()); if (j < 0) - error->all(FLERR,"Variable '{}' not found when updating " - "scale factors",scalevars[i]); + error->all(FLERR, "Variable '{}' not found when updating scale factors", scalevars[i]); vals[i] = input->variable->compute_equal(j); } for (i = 0; i < nstyles; ++i) { - if (scaleidx[i] >= 0) - scaleval[i] = vals[scaleidx[i]]; + if (scaleidx[i] >= 0) scaleval[i] = vals[scaleidx[i]]; } delete[] vals; } @@ -414,23 +404,22 @@ double PairHybridScaled::single(int i, int j, int itype, int jtype, double rsq, double scale; for (int m = 0; m < nmap[itype][jtype]; m++) { - if (rsq < styles[map[itype][jtype][m]]->cutsq[itype][jtype]) { - if (styles[map[itype][jtype][m]]->single_enable == 0) - error->one(FLERR,"Pair hybrid sub-style does not support single call"); + auto pstyle = styles[map[itype][jtype][m]]; + if (rsq < pstyle->cutsq[itype][jtype]) { + if (pstyle->single_enable == 0) + error->one(FLERR, "Pair hybrid sub-style does not support single call"); if ((special_lj[map[itype][jtype][m]] != nullptr) || (special_coul[map[itype][jtype][m]] != nullptr)) - error->one(FLERR,"Pair hybrid single calls do not support" - " per sub-style special bond values"); + error->one(FLERR, "Pair hybrid single() does not support per sub-style special_bond"); scale = scaleval[map[itype][jtype][m]]; - esum += scale * styles[map[itype][jtype][m]]->single(i,j,itype,jtype,rsq, - factor_coul,factor_lj,fone); + esum += scale * pstyle->single(i, j, itype, jtype, rsq, factor_coul, factor_lj, fone); fforce += scale * fone; } } - if (single_extra) copy_svector(itype,jtype); + if (single_extra) copy_svector(itype, jtype); return esum; } @@ -440,49 +429,54 @@ double PairHybridScaled::single(int i, int j, int itype, int jtype, double rsq, void PairHybridScaled::coeff(int narg, char **arg) { - if (narg < 3) error->all(FLERR,"Incorrect args for pair coefficients"); + if (narg < 3) error->all(FLERR, "Incorrect args for pair coefficients"); if (!allocated) allocate(); - int ilo,ihi,jlo,jhi; - utils::bounds(FLERR,arg[0],1,atom->ntypes,ilo,ihi,error); - utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error); + int ilo, ihi, jlo, jhi; + utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi, error); + utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi, error); // 3rd arg = pair sub-style name // 4th arg = pair sub-style index if name used multiple times // allow for "none" as valid sub-style name - int multflag; + int multflag = 0; int m; for (m = 0; m < nstyles; m++) { multflag = 0; - if (strcmp(arg[2],keywords[m]) == 0) { + if (strcmp(arg[2], keywords[m]) == 0) { if (multiple[m]) { multflag = 1; - if (narg < 4) error->all(FLERR,"Incorrect args for pair coefficients"); - int index = utils::inumeric(FLERR,arg[3],false,lmp); - if (index == multiple[m]) break; - else continue; - } else break; + if (narg < 4) error->all(FLERR, "Incorrect args for pair coefficients"); + int index = utils::inumeric(FLERR, arg[3], false, lmp); + if (index == multiple[m]) + break; + else + continue; + } else + break; } } int none = 0; if (m == nstyles) { - if (strcmp(arg[2],"none") == 0) none = 1; - else error->all(FLERR,"Pair coeff for hybrid has invalid style"); + if (strcmp(arg[2], "none") == 0) + none = 1; + else + error->all(FLERR, "Pair coeff for hybrid has invalid style"); } // move 1st/2nd args to 2nd/3rd args // if multflag: move 1st/2nd args to 3rd/4th args // just copy ptrs, since arg[] points into original input line - arg[2+multflag] = arg[1]; - arg[1+multflag] = arg[0]; + arg[2 + multflag] = arg[1]; + arg[1 + multflag] = arg[0]; // invoke sub-style coeff() starting with 1st remaining arg - if (!none) styles[m]->coeff(narg-1-multflag,&arg[1+multflag]); + if (!none) styles[m]->coeff(narg - 1 - multflag, &arg[1 + multflag]); // set setflag and which type pairs map to which sub-style // if sub-style is none: set hybrid subflag, wipe out map @@ -492,7 +486,7 @@ void PairHybridScaled::coeff(int narg, char **arg) int count = 0; for (int i = ilo; i <= ihi; i++) { - for (int j = MAX(jlo,i); j <= jhi; j++) { + for (int j = MAX(jlo, i); j <= jhi; j++) { if (none) { setflag[i][j] = 1; nmap[i][j] = 0; @@ -508,7 +502,7 @@ void PairHybridScaled::coeff(int narg, char **arg) } } - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); + if (count == 0) error->all(FLERR, "Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- @@ -519,15 +513,15 @@ void PairHybridScaled::write_restart(FILE *fp) { PairHybrid::write_restart(fp); - fwrite(scaleval,sizeof(double),nstyles,fp); - fwrite(scaleidx,sizeof(int),nstyles,fp); + fwrite(scaleval, sizeof(double), nstyles, fp); + fwrite(scaleidx, sizeof(int), nstyles, fp); int n = scalevars.size(); - fwrite(&n,sizeof(int),1,fp); + fwrite(&n, sizeof(int), 1, fp); for (auto var : scalevars) { n = var.size() + 1; - fwrite(&n,sizeof(int),1,fp); - fwrite(var.c_str(),sizeof(char),n,fp); + fwrite(&n, sizeof(int), 1, fp); + fwrite(var.c_str(), sizeof(char), n, fp); } } @@ -547,23 +541,23 @@ void PairHybridScaled::read_restart(FILE *fp) int n, me = comm->me; if (me == 0) { - utils::sfread(FLERR,scaleval,sizeof(double),nstyles,fp,nullptr,error); - utils::sfread(FLERR,scaleidx,sizeof(int),nstyles,fp,nullptr,error); + utils::sfread(FLERR, scaleval, sizeof(double), nstyles, fp, nullptr, error); + utils::sfread(FLERR, scaleidx, sizeof(int), nstyles, fp, nullptr, error); } - MPI_Bcast(scaleval,nstyles,MPI_DOUBLE,0,world); - MPI_Bcast(scaleidx,nstyles,MPI_INT,0,world); + MPI_Bcast(scaleval, nstyles, MPI_DOUBLE, 0, world); + MPI_Bcast(scaleidx, nstyles, MPI_INT, 0, world); char *tmp; - if (me == 0) utils::sfread(FLERR,&n,sizeof(int),1,fp,nullptr,error); - MPI_Bcast(&n,1,MPI_INT,0,world); + if (me == 0) utils::sfread(FLERR, &n, sizeof(int), 1, fp, nullptr, error); + MPI_Bcast(&n, 1, MPI_INT, 0, world); scalevars.resize(n); - for (size_t j=0; j < scalevars.size(); ++j) { - if (me == 0) utils::sfread(FLERR,&n,sizeof(int),1,fp,nullptr,error); - MPI_Bcast(&n,1,MPI_INT,0,world); + for (auto &scale : scalevars) { + if (me == 0) utils::sfread(FLERR, &n, sizeof(int), 1, fp, nullptr, error); + MPI_Bcast(&n, 1, MPI_INT, 0, world); tmp = new char[n]; - if (me == 0) utils::sfread(FLERR,tmp,sizeof(char),n,fp,nullptr,error); - MPI_Bcast(tmp,n,MPI_CHAR,0,world); - scalevars[j] = tmp; + if (me == 0) utils::sfread(FLERR, tmp, sizeof(char), n, fp, nullptr, error); + MPI_Bcast(tmp, n, MPI_CHAR, 0, world); + scale = tmp; delete[] tmp; } } @@ -578,11 +572,10 @@ void PairHybridScaled::init_svector() // allocate svector single_extra = 0; - for (int m = 0; m < nstyles; m++) - single_extra += styles[m]->single_extra; + for (int m = 0; m < nstyles; m++) single_extra += styles[m]->single_extra; if (single_extra) { - delete [] svector; + delete[] svector; svector = new double[single_extra]; } } @@ -593,7 +586,7 @@ void PairHybridScaled::init_svector() void PairHybridScaled::copy_svector(int itype, int jtype) { - int n=0; + int n = 0; Pair *this_style; // fill svector array. diff --git a/src/read_dump.cpp b/src/read_dump.cpp index 82f5c969df..4a7a483cb0 100644 --- a/src/read_dump.cpp +++ b/src/read_dump.cpp @@ -285,7 +285,7 @@ bigint ReadDump::seek(bigint nrequest, int exact) ntimestep = -1; if (multiproc) { std::string multiname = files[ifile]; - multiname.replace(multiname.find("%"),1,"0"); + multiname.replace(multiname.find('%'),1,"0"); readers[0]->open_file(multiname.c_str()); } else readers[0]->open_file(files[ifile]); @@ -329,7 +329,7 @@ bigint ReadDump::seek(bigint nrequest, int exact) for (int i = 0; i < nreader; i++) { 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)); + multiname.replace(multiname.find('%'),1,fmt::format("{}",firstfile+i)); readers[i]->open_file(multiname.c_str()); bigint step; @@ -377,7 +377,7 @@ bigint ReadDump::next(bigint ncurrent, bigint nlast, int nevery, int nskip) if (ifile != currentfile) { if (multiproc) { std::string multiname = files[ifile]; - multiname.replace(multiname.find("%"),1,"0"); + multiname.replace(multiname.find('%'),1,"0"); readers[0]->open_file(multiname.c_str()); } else readers[0]->open_file(files[ifile]); } @@ -431,7 +431,7 @@ bigint ReadDump::next(bigint ncurrent, bigint nlast, int nevery, int nskip) for (int i = 0; i < nreader; i++) { if (me == 0 && i == 0) continue; std::string multiname = files[currentfile]; - multiname.replace(multiname.find("%"),1,fmt::format("{}",firstfile+i)); + multiname.replace(multiname.find('%'),1,fmt::format("{}",firstfile+i)); readers[i]->open_file(multiname.c_str()); bigint step; diff --git a/src/read_restart.cpp b/src/read_restart.cpp index e42bb59272..5fc95b78b9 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -106,7 +106,7 @@ void ReadRestart::command(int narg, char **arg) utils::logmesg(lmp,"Reading restart file ...\n"); std::string hfile = file; if (multiproc) { - hfile.replace(hfile.find("%"),1,"base"); + hfile.replace(hfile.find('%'),1,"base"); } fp = fopen(hfile.c_str(),"rb"); if (fp == nullptr) @@ -268,7 +268,7 @@ void ReadRestart::command(int narg, char **arg) for (int iproc = me; iproc < multiproc_file; iproc += nprocs) { std::string procfile = file; - procfile.replace(procfile.find("%"),1,fmt::format("{}",iproc)); + procfile.replace(procfile.find('%'),1,fmt::format("{}",iproc)); fp = fopen(procfile.c_str(),"rb"); if (fp == nullptr) error->one(FLERR,"Cannot open restart file {}: {}", @@ -332,7 +332,7 @@ void ReadRestart::command(int narg, char **arg) if (filereader) { std::string procfile = file; - procfile.replace(procfile.find("%"),1,fmt::format("{}",icluster)); + procfile.replace(procfile.find('%'),1,fmt::format("{}",icluster)); fp = fopen(procfile.c_str(),"rb"); if (fp == nullptr) error->one(FLERR,"Cannot open restart file {}: {}", procfile, utils::getsyserror()); diff --git a/src/reset_mol_ids.cpp b/src/reset_mol_ids.cpp index cf5bcdec6e..3ddef738d2 100644 --- a/src/reset_mol_ids.cpp +++ b/src/reset_mol_ids.cpp @@ -89,7 +89,7 @@ void ResetMolIDs::command(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"offset") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal reset_mol_ids command"); - offset = utils::tnumeric(FLERR,arg[iarg+1],1,lmp); + offset = utils::tnumeric(FLERR,arg[iarg+1],true,lmp); if (offset < -1) error->all(FLERR,"Illegal reset_mol_ids command"); iarg += 2; } else error->all(FLERR,"Illegal reset_mol_ids command"); diff --git a/src/write_data.cpp b/src/write_data.cpp index 9016528049..82c237a07e 100644 --- a/src/write_data.cpp +++ b/src/write_data.cpp @@ -61,7 +61,7 @@ void WriteData::command(int narg, char **arg) // if filename contains a "*", replace with current timestep std::string file = arg[0]; - std::size_t found = file.find("*"); + std::size_t found = file.find('*'); if (found != std::string::npos) file.replace(found,1,fmt::format("{}",update->ntimestep)); diff --git a/src/write_restart.cpp b/src/write_restart.cpp index ddae269933..7f73d868ff 100644 --- a/src/write_restart.cpp +++ b/src/write_restart.cpp @@ -65,7 +65,7 @@ void WriteRestart::command(int narg, char **arg) // if filename contains a "*", replace with current timestep std::string file = arg[0]; - std::size_t found = file.find("*"); + std::size_t found = file.find('*'); if (found != std::string::npos) file.replace(found,1,fmt::format("{}",update->ntimestep)); @@ -205,7 +205,7 @@ void WriteRestart::multiproc_options(int multiproc_caller, int mpiioflag_caller, file = final file name to write, except may contain a "%" ------------------------------------------------------------------------- */ -void WriteRestart::write(std::string file) +void WriteRestart::write(const std::string &file) { // special case where reneighboring is not done in integrator // on timestep restart file is written (due to build_once being set) @@ -228,7 +228,7 @@ void WriteRestart::write(std::string file) if (me == 0) { std::string base = file; - if (multiproc) base.replace(base.find("%"),1,"base"); + if (multiproc) base.replace(base.find('%'),1,"base"); fp = fopen(base.c_str(),"wb"); if (fp == nullptr) @@ -290,7 +290,7 @@ void WriteRestart::write(std::string file) } std::string multiname = file; - multiname.replace(multiname.find("%"),1,fmt::format("{}",icluster)); + multiname.replace(multiname.find('%'),1,fmt::format("{}",icluster)); if (filewriter) { fp = fopen(multiname.c_str(),"wb"); diff --git a/src/write_restart.h b/src/write_restart.h index 2e018e1036..54d90405b2 100644 --- a/src/write_restart.h +++ b/src/write_restart.h @@ -29,7 +29,7 @@ class WriteRestart : public Command { WriteRestart(class LAMMPS *); void command(int, char **); void multiproc_options(int, int, int, char **); - void write(std::string); + void write(const std::string &); private: int me, nprocs; diff --git a/tools/binary2txt.cpp b/tools/binary2txt.cpp index 8abaafd093..a7724ffbd2 100644 --- a/tools/binary2txt.cpp +++ b/tools/binary2txt.cpp @@ -29,9 +29,9 @@ // g++ -g -DLAMMPS_BIGBIG binarytxt.o -o binary2txt // again -DLAMMPS_SMALLBIG is the default -#include "stdint.h" +#include #define __STDC_FORMAT_MACROS -#include "inttypes.h" +#include #ifndef PRId64 #define PRId64 "ld" @@ -65,7 +65,7 @@ int main(int narg, char **arg) char boundstr[9]; int maxbuf = 0; - double *buf = NULL; + double *buf = nullptr; if (narg == 1) { printf("Syntax: binary2txt file1 file2 ...\n");