format changes

This commit is contained in:
Axel Kohlmeyer
2021-09-17 22:49:57 -04:00
parent cd3efc3fa8
commit 385220fd4b
62 changed files with 322 additions and 386 deletions

View File

@ -301,8 +301,7 @@ void PairLineLJ::compute(int eflag, int vflag)
} }
} }
if (evflag) ev_tally(i,j,nlocal,newton_pair, if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz);
evdwl,0.0,fpair,delx,dely,delz);
} }
} }

View File

@ -375,8 +375,7 @@ void PairTriLJ::compute(int eflag, int vflag)
} }
} }
if (evflag) ev_tally(i,j,nlocal,newton_pair, if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz);
evdwl,0.0,fpair,delx,dely,delz);
} }
} }

View File

@ -337,8 +337,7 @@ void FixWallBodyPolygon::post_force(int /*vflag*/)
num_contacts = 0; num_contacts = 0;
facc[0] = facc[1] = facc[2] = 0; facc[0] = facc[1] = facc[2] = 0;
vertex_against_wall(i, wall_pos, x, f, torque, side, vertex_against_wall(i, wall_pos, x, f, torque, side, contact_list, num_contacts, facc);
contact_list, num_contacts, facc);
if (num_contacts >= 2) { if (num_contacts >= 2) {

View File

@ -324,8 +324,7 @@ void PairBodyNparticle::compute(int eflag, int vflag)
} }
} }
if (evflag) ev_tally(i,j,nlocal,newton_pair, if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz);
evdwl,0.0,fpair,delx,dely,delz);
} }
} }

View File

@ -207,8 +207,7 @@ void PairBodyRoundedPolygon::compute(int eflag, int vflag)
if (r > radi + radj + cut_inner) continue; if (r > radi + radj + cut_inner) continue;
if (npi == 1 && npj == 1) { if (npi == 1 && npj == 1) {
sphere_against_sphere(i, j, delx, dely, delz, rsq, sphere_against_sphere(i, j, delx, dely, delz, rsq, k_nij, k_naij, x, v, f, evflag);
k_nij, k_naij, x, v, f, evflag);
continue; continue;
} }

View File

@ -397,8 +397,7 @@ void PairLJClass2::compute_outer(int eflag, int vflag)
fpair = factor_lj*forcelj*r2inv; fpair = factor_lj*forcelj*r2inv;
} }
if (evflag) ev_tally(i,j,nlocal,newton_pair, if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz);
evdwl,0.0,fpair,delx,dely,delz);
} }
} }
} }

View File

@ -1000,7 +1000,7 @@ double FixColvars::compute_scalar()
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
/* local memory usage. approximately. */ /* local memory usage. approximately. */
double FixColvars::memory_usage(void) double FixColvars::memory_usage()
{ {
double bytes = (double) (num_coords * (2*sizeof(int)+3*sizeof(double))); double bytes = (double) (num_coords * (2*sizeof(int)+3*sizeof(double)));
bytes += (double)(double) (nmax*size_one) + sizeof(this); bytes += (double)(double) (nmax*size_one) + sizeof(this);

View File

@ -1,4 +1,3 @@
// clang-format off
/* -*- c++ -*- ---------------------------------------------------------- /* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -17,22 +16,18 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "gz_file_writer.h" #include "gz_file_writer.h"
#include <stdio.h>
#include "fmt/format.h" #include "fmt/format.h"
#include <cstdio>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
GzFileWriter::GzFileWriter() : FileWriter(), GzFileWriter::GzFileWriter() : FileWriter(), compression_level(Z_BEST_COMPRESSION), gzFp(nullptr) {}
compression_level(Z_BEST_COMPRESSION),
gzFp(nullptr)
{
}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
GzFileWriter::~GzFileWriter() GzFileWriter::~GzFileWriter()
{ {
close(); GzFileWriter::close();
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -50,8 +45,7 @@ void GzFileWriter::open(const std::string &path, bool append)
gzFp = gzopen(path.c_str(), mode.c_str()); gzFp = gzopen(path.c_str(), mode.c_str());
if (gzFp == nullptr) if (gzFp == nullptr) throw FileWriterException(fmt::format("Could not open file '{}'", path));
throw FileWriterException(fmt::format("Could not open file '{}'", path));
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -76,7 +70,7 @@ void GzFileWriter::flush()
void GzFileWriter::close() void GzFileWriter::close()
{ {
if (!isopen()) return; if (!GzFileWriter::isopen()) return;
gzclose(gzFp); gzclose(gzFp);
gzFp = nullptr; gzFp = nullptr;
@ -100,7 +94,8 @@ void GzFileWriter::setCompressionLevel(int level)
const int max_level = Z_BEST_COMPRESSION; const int max_level = Z_BEST_COMPRESSION;
if (level < min_level || level > max_level) 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; compression_level = level;
} }

View File

@ -1,4 +1,3 @@
// clang-format off
/* -*- c++ -*- ---------------------------------------------------------- /* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -19,16 +18,13 @@
#ifdef LAMMPS_ZSTD #ifdef LAMMPS_ZSTD
#include "zstd_file_writer.h" #include "zstd_file_writer.h"
#include <stdio.h>
#include "fmt/format.h" #include "fmt/format.h"
#include <cstdio>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
ZstdFileWriter::ZstdFileWriter() : FileWriter(), ZstdFileWriter::ZstdFileWriter() :
compression_level(0), FileWriter(), compression_level(0), checksum_flag(1), cctx(nullptr), fp(nullptr)
checksum_flag(1),
cctx(nullptr),
fp(nullptr)
{ {
out_buffer_size = ZSTD_CStreamOutSize(); out_buffer_size = ZSTD_CStreamOutSize();
out_buffer = new char[out_buffer_size]; out_buffer = new char[out_buffer_size];
@ -38,7 +34,7 @@ ZstdFileWriter::ZstdFileWriter() : FileWriter(),
ZstdFileWriter::~ZstdFileWriter() ZstdFileWriter::~ZstdFileWriter()
{ {
close(); ZstdFileWriter::close();
delete[] out_buffer; delete[] out_buffer;
out_buffer = nullptr; out_buffer = nullptr;
@ -57,9 +53,7 @@ void ZstdFileWriter::open(const std::string &path, bool append)
fp = fopen(path.c_str(), "wb"); fp = fopen(path.c_str(), "wb");
} }
if (!fp) { if (!fp) { throw FileWriterException(fmt::format("Could not open file '{}'", path)); }
throw FileWriterException(fmt::format("Could not open file '{}'", path));
}
cctx = ZSTD_createCCtx(); cctx = ZSTD_createCCtx();
@ -114,7 +108,7 @@ void ZstdFileWriter::flush()
void ZstdFileWriter::close() void ZstdFileWriter::close()
{ {
if (!isopen()) return; if (!ZstdFileWriter::isopen()) return;
size_t remaining; size_t remaining;
ZSTD_inBuffer input = {nullptr, 0, 0}; ZSTD_inBuffer input = {nullptr, 0, 0};
@ -150,7 +144,8 @@ void ZstdFileWriter::setCompressionLevel(int level)
const int max_level = ZSTD_maxCLevel(); const int max_level = ZSTD_maxCLevel();
if (level < min_level || level > max_level) 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; compression_level = level;
} }
@ -159,8 +154,7 @@ void ZstdFileWriter::setCompressionLevel(int level)
void ZstdFileWriter::setChecksum(bool enabled) void ZstdFileWriter::setChecksum(bool enabled)
{ {
if (isopen()) if (isopen()) throw FileWriterException("Checksum flag can not be changed while file is open");
throw FileWriterException("Checksum flag can not be changed while file is open");
checksum_flag = enabled ? 1 : 0; checksum_flag = enabled ? 1 : 0;
} }

View File

@ -38,7 +38,7 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
ComputeEfieldAtom::ComputeEfieldAtom(LAMMPS *lmp, int narg, char **arg) : 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"); if (narg < 3) error->all(FLERR,"Illegal compute efield/atom command");

View File

@ -69,8 +69,8 @@ using namespace MathConst;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
FixPolarizeBEMGMRES::FixPolarizeBEMGMRES(LAMMPS *lmp, int narg, char **arg) : 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), Fix(lmp, narg, arg), q_backup(nullptr), c(nullptr), g(nullptr), h(nullptr), r(nullptr), s(nullptr), v(nullptr),
y(NULL) y(nullptr)
{ {
if (narg < 5) error->all(FLERR, "Illegal fix polarize/bem/gmres command"); 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->torque_flag) torqueflag = 1;
if (atom->avec->forceclearflag) extraflag = 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() atom->add_callback(0); // to ensure to work with atom->sort()
// output the residual and actual number of iterations // output the residual and actual number of iterations
@ -133,7 +133,7 @@ FixPolarizeBEMGMRES::~FixPolarizeBEMGMRES()
memory->destroy(mat2tag); memory->destroy(mat2tag);
memory->destroy(tag2mat); memory->destroy(tag2mat);
if (allocated) deallocate(); if (allocated) FixPolarizeBEMGMRES::deallocate();
atom->delete_callback(id, 0); atom->delete_callback(id, 0);
} }

View File

@ -131,7 +131,7 @@ FixPolarizeFunctional::FixPolarizeFunctional(LAMMPS *lmp, int narg, char **arg)
cg_r = cg_p = cg_Ap = nullptr; cg_r = cg_p = cg_Ap = nullptr;
cg_A = nullptr; cg_A = nullptr;
grow_arrays(atom->nmax); FixPolarizeFunctional::grow_arrays(atom->nmax);
atom->add_callback(0); // to ensure to work with atom->sort() atom->add_callback(0); // to ensure to work with atom->sort()
} }

View File

@ -221,10 +221,10 @@ void PairCoulLongDielectric::init_style()
// insure use of KSpace long-range solver, set g_ewald // 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; g_ewald = force->kspace->g_ewald;
// setup force tables // setup force tables
if (ncoultablebits) init_tables(cut_coul, NULL); if (ncoultablebits) init_tables(cut_coul, nullptr);
} }

View File

@ -40,8 +40,8 @@ using namespace MathConst;
PairLJCutCoulDebyeDielectric::PairLJCutCoulDebyeDielectric(LAMMPS *lmp) : PairLJCutCoulDebye(lmp) PairLJCutCoulDebyeDielectric::PairLJCutCoulDebyeDielectric(LAMMPS *lmp) : PairLJCutCoulDebye(lmp)
{ {
efield = NULL; efield = nullptr;
epot = NULL; epot = nullptr;
nmax = 0; nmax = 0;
} }

View File

@ -257,7 +257,7 @@ void PairLJCutCoulLongDielectric::init_style()
// insure use of KSpace long-range solver, set g_ewald // 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; g_ewald = force->kspace->g_ewald;
// setup force tables // setup force tables

View File

@ -365,7 +365,7 @@ void PairLJCutCoulMSMDielectric::init_style()
// insure use of KSpace long-range solver, set g_ewald // 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; g_ewald = force->kspace->g_ewald;
// setup force tables // setup force tables
@ -382,5 +382,5 @@ void *PairLJCutCoulMSMDielectric::extract(const char *str, int &dim)
dim = 2; dim = 2;
if (strcmp(str, "epsilon") == 0) return (void *) epsilon; if (strcmp(str, "epsilon") == 0) return (void *) epsilon;
if (strcmp(str, "sigma") == 0) return (void *) sigma; if (strcmp(str, "sigma") == 0) return (void *) sigma;
return NULL; return nullptr;
} }

View File

@ -59,7 +59,7 @@ namespace /* anonymous */
{ {
typedef double TimerType; 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; } double getElapsedTime( const TimerType &t0, const TimerType &t1) { return t1-t0; }
} // end namespace } // end namespace
@ -1246,7 +1246,7 @@ int FixRX::rkf45_h0 (const int neq, const double t, const double /*t_stop*/,
return (iter + 1); return (iter + 1);
} }
void FixRX::odeDiagnostics(void) void FixRX::odeDiagnostics()
{ {
TimerType timer_start = getTimeStamp(); TimerType timer_start = getTimeStamp();

View File

@ -224,7 +224,7 @@ FixMesoMove::FixMesoMove (LAMMPS *lmp, int narg, char **arg) :
// perform initial allocation of atom-based array // perform initial allocation of atom-based array
// register with Atom class // register with Atom class
grow_arrays(atom->nmax); FixMesoMove::grow_arrays(atom->nmax);
atom->add_callback(Atom::GROW); atom->add_callback(Atom::GROW);
atom->add_callback(Atom::RESTART); atom->add_callback(Atom::RESTART);

View File

@ -55,7 +55,7 @@ FixDrude::FixDrude(LAMMPS *lmp, int narg, char **arg) :
} }
drudeid = nullptr; drudeid = nullptr;
grow_arrays(atom->nmax); FixDrude::grow_arrays(atom->nmax);
atom->add_callback(Atom::GROW); atom->add_callback(Atom::GROW);
atom->add_callback(Atom::RESTART); atom->add_callback(Atom::RESTART);
atom->add_callback(Atom::BORDER); 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) { void FixDrude::set_arrays(int i) {
if (drudetype[atom->type[i]] != NOPOL_TYPE) { 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 drudeid[i] = atom->special[i][0]; // Drude partner should be at first place in the special list
} else { } else {
drudeid[i] = 0; drudeid[i] = 0;

View File

@ -84,14 +84,14 @@ FixFlowGauss::FixFlowGauss(LAMMPS *lmp, int narg, char **arg) :
// by default, do not compute work done // by default, do not compute work done
workflag=0; workflag=false;
// process optional keyword // process optional keyword
int iarg = 6; int iarg = 6;
while (iarg < narg) { while (iarg < narg) {
if (strcmp(arg[iarg],"energy") == 0) { if (strcmp(arg[iarg],"energy") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal energy keyword"); 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) else if (strcmp(arg[iarg+1],"no") != 0)
error->all(FLERR,"Illegal energy keyword"); error->all(FLERR,"Illegal energy keyword");
iarg += 2; iarg += 2;
@ -139,7 +139,7 @@ void FixFlowGauss::setup(int vflag)
{ {
// need to compute work done if fix_modify energy yes is set // 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 // get total mass of group

View File

@ -366,7 +366,7 @@ void FixTTMGrid::write_electron_temperatures(const std::string &filename)
update->unit_style, nxgrid, nygrid, nzgrid, update->ntimestep, style); 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); if (comm->me == 0) fclose(FPout);
} }

View File

@ -101,7 +101,7 @@ FixTTMMod::FixTTMMod(LAMMPS *lmp, int narg, char **arg) :
nzgrid = utils::inumeric(FLERR,arg[7],false,lmp); nzgrid = utils::inumeric(FLERR,arg[7],false,lmp);
double tinit = 0.0; double tinit = 0.0;
infile = outfile = NULL; infile = outfile = nullptr;
int iarg = 8; int iarg = 8;
while (iarg < narg) { while (iarg < narg) {

View File

@ -376,8 +376,7 @@ void PairLJ96Cut::compute_outer(int eflag, int vflag)
r2inv = 1.0/rsq; r2inv = 1.0/rsq;
r6inv = r2inv*r2inv*r2inv; r6inv = r2inv*r2inv*r2inv;
r3inv = sqrt(r6inv); r3inv = sqrt(r6inv);
evdwl = r6inv*(lj3[itype][jtype]*r3inv-lj4[itype][jtype]) - evdwl = r6inv*(lj3[itype][jtype]*r3inv-lj4[itype][jtype]) - offset[itype][jtype];
offset[itype][jtype];
evdwl *= factor_lj; evdwl *= factor_lj;
} }
@ -392,8 +391,7 @@ void PairLJ96Cut::compute_outer(int eflag, int vflag)
fpair = factor_lj*forcelj*r2inv; fpair = factor_lj*forcelj*r2inv;
} }
if (evflag) ev_tally(i,j,nlocal,newton_pair, if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz);
evdwl,0.0,fpair,delx,dely,delz);
} }
} }
} }

View File

@ -195,14 +195,12 @@ void PairLJExpandCoulLong::compute(int eflag, int vflag)
} else ecoul = 0.0; } else ecoul = 0.0;
if (rsq < cut_ljsq[itype][jtype]) { if (rsq < cut_ljsq[itype][jtype]) {
evdwl = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - evdwl = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - offset[itype][jtype];
offset[itype][jtype];
evdwl *= factor_lj; evdwl *= factor_lj;
} else evdwl = 0.0; } else evdwl = 0.0;
} }
if (evflag) ev_tally(i,j,nlocal,newton_pair, if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,ecoul,fpair,delx,dely,delz);
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]) { if (rsq < cut_ljsq[itype][jtype]) {
philj = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - philj = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - offset[itype][jtype];
offset[itype][jtype];
eng += factor_lj*philj; eng += factor_lj*philj;
} }

View File

@ -164,16 +164,14 @@ void PairLJGromacsCoulGromacs::compute(int eflag, int vflag)
evdwl = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]); evdwl = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]);
evdwl += ljsw5[itype][jtype]; evdwl += ljsw5[itype][jtype];
if (rsq > cut_lj_innersq) { if (rsq > cut_lj_innersq) {
eswitch = tlj*tlj*tlj * eswitch = tlj*tlj*tlj * (ljsw3[itype][jtype] + ljsw4[itype][jtype]*tlj);
(ljsw3[itype][jtype] + ljsw4[itype][jtype]*tlj);
evdwl += eswitch; evdwl += eswitch;
} }
evdwl *= factor_lj; evdwl *= factor_lj;
} else evdwl = 0.0; } else evdwl = 0.0;
} }
if (evflag) ev_tally(i,j,nlocal,newton_pair, if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,ecoul,fpair,delx,dely,delz);
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) { if (rsq < cut_coulsq) {
phicoul = force->qqrd2e * atom->q[i]*atom->q[j] * (sqrt(r2inv)-coulsw5); phicoul = force->qqrd2e * atom->q[i]*atom->q[j] * (sqrt(r2inv)-coulsw5);
if (rsq > cut_coul_innersq) { if (rsq > cut_coul_innersq) {
phiswitchcoul = force->qqrd2e * atom->q[i]*atom->q[j] * phiswitchcoul = force->qqrd2e * atom->q[i]*atom->q[j] * tc*tc*tc * (coulsw3 + coulsw4*tc);
tc*tc*tc * (coulsw3 + coulsw4*tc);
phicoul += phiswitchcoul; phicoul += phiswitchcoul;
} }
eng += factor_coul*phicoul; 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 = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]);
philj += ljsw5[itype][jtype]; philj += ljsw5[itype][jtype];
if (rsq > cut_lj_innersq) { if (rsq > cut_lj_innersq) {
phiswitch = tlj*tlj*tlj * phiswitch = tlj*tlj*tlj * (ljsw3[itype][jtype] + ljsw4[itype][jtype]*tlj);
(ljsw3[itype][jtype] + ljsw4[itype][jtype]*tlj);
philj += phiswitch; philj += phiswitch;
} }
eng += factor_lj*philj; eng += factor_lj*philj;

View File

@ -183,15 +183,13 @@ void PairLJRelRes::compute(int eflag, int vflag)
if (eflag) { if (eflag) {
if (rsq < cutf_inner_sq[itype][jtype]) { if (rsq < cutf_inner_sq[itype][jtype]) {
evdwl = r6inv*(ljf3[itype][jtype]*r6inv- evdwl = r6inv*(ljf3[itype][jtype]*r6inv-ljf4[itype][jtype])-offsetsm[itype][jtype];
ljf4[itype][jtype])-offsetsm[itype][jtype];
} else if (rsq < cutfsq[itype][jtype]) { } else if (rsq < cutfsq[itype][jtype]) {
evdwl = ljswf0[itype][jtype]-ljswf1[itype][jtype]*t- evdwl = ljswf0[itype][jtype]-ljswf1[itype][jtype]*t-
ljswf2[itype][jtype]*tsq/2.0-ljswf3[itype][jtype]*tsq*t/3.0- ljswf2[itype][jtype]*tsq/2.0-ljswf3[itype][jtype]*tsq*t/3.0-
ljswf4[itype][jtype]*tsq*tsq/4.0-offsetsp[itype][jtype]; ljswf4[itype][jtype]*tsq*tsq/4.0-offsetsp[itype][jtype];
} else if (rsq < cut_inner_sq[itype][jtype]) { } else if (rsq < cut_inner_sq[itype][jtype]) {
evdwl = r6inv*(lj3[itype][jtype]*r6inv- evdwl = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype])-offset[itype][jtype];
lj4[itype][jtype])-offset[itype][jtype];
} else { } else {
evdwl = ljsw0[itype][jtype]-ljsw1[itype][jtype]*t- evdwl = ljsw0[itype][jtype]-ljsw1[itype][jtype]*t-
ljsw2[itype][jtype]*tsq/2.0-ljsw3[itype][jtype]*tsq*t/3.0- 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; evdwl *= factor_lj;
} }
if (evflag) ev_tally(i,j,nlocal,newton_pair, if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz);
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; fforce = factor_lj*forcelj*r2inv;
if (rsq < cutf_inner_sq[itype][jtype]) { if (rsq < cutf_inner_sq[itype][jtype]) {
philj = r6inv*(ljf3[itype][jtype]*r6inv- philj = r6inv*(ljf3[itype][jtype]*r6inv-ljf4[itype][jtype])-offsetsm[itype][jtype];
ljf4[itype][jtype])-offsetsm[itype][jtype];
} else if (rsq < cutfsq[itype][jtype]) { } else if (rsq < cutfsq[itype][jtype]) {
philj = ljswf0[itype][jtype]-ljswf1[itype][jtype]*t- philj = ljswf0[itype][jtype]-ljswf1[itype][jtype]*t-
ljswf2[itype][jtype]*tsq/2.0-ljswf3[itype][jtype]*tsq*t/3.0- ljswf2[itype][jtype]*tsq/2.0-ljswf3[itype][jtype]*tsq*t/3.0-
ljswf4[itype][jtype]*tsq*tsq/4.0-offsetsp[itype][jtype]; ljswf4[itype][jtype]*tsq*tsq/4.0-offsetsp[itype][jtype];
} else if (rsq < cut_inner_sq[itype][jtype]) { } else if (rsq < cut_inner_sq[itype][jtype]) {
philj = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]) - philj = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]) - offset[itype][jtype];
offset[itype][jtype];
} else { } else {
philj = ljsw0[itype][jtype] - ljsw1[itype][jtype]*t - philj = ljsw0[itype][jtype] - ljsw1[itype][jtype]*t -
ljsw2[itype][jtype]*tsq/2.0 - ljsw3[itype][jtype]*tsq*t/3.0 - ljsw2[itype][jtype]*tsq/2.0 - ljsw3[itype][jtype]*tsq*t/3.0 -

View File

@ -136,8 +136,7 @@ void PairLJSmooth::compute(int eflag, int vflag)
if (eflag) { if (eflag) {
if (rsq < cut_inner_sq[itype][jtype]) if (rsq < cut_inner_sq[itype][jtype])
evdwl = r6inv * (lj3[itype][jtype]*r6inv - evdwl = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]) - offset[itype][jtype];
lj4[itype][jtype]) - offset[itype][jtype];
else else
evdwl = ljsw0[itype][jtype] - ljsw1[itype][jtype]*t - evdwl = ljsw0[itype][jtype] - ljsw1[itype][jtype]*t -
ljsw2[itype][jtype]*tsq/2.0 - ljsw3[itype][jtype]*tsq*t/3.0 - 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; evdwl *= factor_lj;
} }
if (evflag) ev_tally(i,j,nlocal,newton_pair, if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz);
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; fforce = factor_lj*forcelj*r2inv;
if (rsq < cut_inner_sq[itype][jtype]) if (rsq < cut_inner_sq[itype][jtype])
philj = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]) - philj = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]) - offset[itype][jtype];
offset[itype][jtype];
else else
philj = ljsw0[itype][jtype] - ljsw1[itype][jtype]*t - philj = ljsw0[itype][jtype] - ljsw1[itype][jtype]*t -
ljsw2[itype][jtype]*tsq/2.0 - ljsw3[itype][jtype]*tsq*t/3.0 - ljsw2[itype][jtype]*tsq/2.0 - ljsw3[itype][jtype]*tsq*t/3.0 -

View File

@ -147,17 +147,13 @@ void PairNMCutCoulCut::compute(int eflag, int vflag)
ecoul = factor_coul * qqrd2e * qtmp*q[j]*sqrt(r2inv); ecoul = factor_coul * qqrd2e * qtmp*q[j]*sqrt(r2inv);
else ecoul = 0.0; else ecoul = 0.0;
if (rsq < cut_ljsq[itype][jtype]) { if (rsq < cut_ljsq[itype][jtype]) {
evdwl = e0nm[itype][jtype]*(mm[itype][jtype] * evdwl = e0nm[itype][jtype]*(mm[itype][jtype] * r0n[itype][jtype]*rninv -
r0n[itype][jtype]*rninv - nn[itype][jtype] * r0m[itype][jtype]*rminv) - offset[itype][jtype];
nn[itype][jtype] *
r0m[itype][jtype]*rminv) -
offset[itype][jtype];
evdwl *= factor_lj; evdwl *= factor_lj;
} else evdwl = 0.0; } else evdwl = 0.0;
} }
if (evflag) ev_tally(i,j,nlocal,newton_pair, if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,ecoul,fpair,delx,dely,delz);
evdwl,ecoul,fpair,delx,dely,delz);
} }
} }
} }

View File

@ -178,8 +178,7 @@ void PairLJCutCoulLongSoft::compute(int eflag, int vflag)
} else evdwl = 0.0; } else evdwl = 0.0;
} }
if (evflag) ev_tally(i,j,nlocal,newton_pair, if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,ecoul,fpair,delx,dely,delz);
evdwl,ecoul,fpair,delx,dely,delz);
} }
} }
} }

View File

@ -410,8 +410,7 @@ void PairLJCutSoft::compute_outer(int eflag, int vflag)
fpair = factor_lj*forcelj; fpair = factor_lj*forcelj;
} }
if (evflag) ev_tally(i,j,nlocal,newton_pair, if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz);
evdwl,0.0,fpair,delx,dely,delz);
} }
} }
} }

View File

@ -308,8 +308,7 @@ struct fft_plan_3d *fft_3d_create_plan(
first_jhi = (ip1+1)*nmid/np1 - 1; first_jhi = (ip1+1)*nmid/np1 - 1;
first_klo = ip2*nslow/np2; first_klo = ip2*nslow/np2;
first_khi = (ip2+1)*nslow/np2 - 1; first_khi = (ip2+1)*nslow/np2 - 1;
plan->pre_plan = plan->pre_plan = remap_3d_create_plan(comm,in_ilo,in_ihi,in_jlo,in_jhi,in_klo,in_khi,
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_ilo,first_ihi,first_jlo,first_jhi,
first_klo,first_khi,2,0,0,FFT_PRECISION,0); first_klo,first_khi,2,0,0,FFT_PRECISION,0);
if (plan->pre_plan == nullptr) return nullptr; if (plan->pre_plan == nullptr) return nullptr;
@ -330,13 +329,10 @@ struct fft_plan_3d *fft_3d_create_plan(
second_jhi = nmid - 1; second_jhi = nmid - 1;
second_klo = ip2*nslow/np2; second_klo = ip2*nslow/np2;
second_khi = (ip2+1)*nslow/np2 - 1; second_khi = (ip2+1)*nslow/np2 - 1;
plan->mid1_plan = plan->mid1_plan = remap_3d_create_plan(comm, first_ilo,first_ihi,first_jlo,first_jhi,
remap_3d_create_plan(comm, first_klo,first_khi,second_ilo,second_ihi,
first_ilo,first_ihi,first_jlo,first_jhi, second_jlo,second_jhi,second_klo,second_khi,
first_klo,first_khi, 2,1,0,FFT_PRECISION,usecollective);
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; if (plan->mid1_plan == nullptr) return nullptr;
// 1d FFTs along mid axis // 1d FFTs along mid axis

View File

@ -125,8 +125,6 @@ void PairEAMFS::read_file(char *filename)
// transparently convert units for supported conversions // transparently convert units for supported conversions
// transparently convert units for supported conversions
int unit_convert = reader.get_unit_convert(); int unit_convert = reader.get_unit_convert();
double conversion_factor = utils::get_conversion_factor(utils::ENERGY, double conversion_factor = utils::get_conversion_factor(utils::ENERGY,
unit_convert); unit_convert);

View File

@ -32,8 +32,8 @@
#include "update.h" #include "update.h"
#include "verlet.h" #include "verlet.h"
#include <cstring>
#include <limits> #include <limits>
#include <string.h>
enum { NONE, REAL, METAL }; // LAMMPS units which MDI supports enum { NONE, REAL, METAL }; // LAMMPS units which MDI supports

View File

@ -31,8 +31,8 @@
#include "update.h" #include "update.h"
#include "verlet.h" #include "verlet.h"
#include <cstring>
#include <limits> #include <limits>
#include <string.h>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;

View File

@ -329,13 +329,12 @@ FixBoxRelax::FixBoxRelax(LAMMPS *lmp, int narg, char **arg) :
// pass id_temp as 4th arg to pressure constructor // pass id_temp as 4th arg to pressure constructor
id_press = utils::strdup(std::string(id) + "_press"); id_press = utils::strdup(std::string(id) + "_press");
modify->add_compute(fmt::format("{} all pressure {} virial", modify->add_compute(fmt::format("{} all pressure {} virial",id_press, id_temp));
id_press, id_temp));
pflag = 1; pflag = 1;
dimension = domain->dimension; dimension = domain->dimension;
nrigid = 0; nrigid = 0;
rfix = 0; rfix = nullptr;
current_lifo = 0; current_lifo = 0;
} }

View File

@ -428,7 +428,7 @@ double FixEfield::memory_usage()
return energy added by fix return energy added by fix
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
double FixEfield::compute_scalar(void) double FixEfield::compute_scalar()
{ {
if (force_flag == 0) { if (force_flag == 0) {
MPI_Allreduce(fsum,fsum_all,4,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(fsum,fsum_all,4,MPI_DOUBLE,MPI_SUM,world);

View File

@ -1,4 +1,3 @@
// clang-format off
/* -*- c++ -*- ---------------------------------------------------------- /* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -22,8 +21,7 @@ using namespace LAMMPS_NS;
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
ImbalanceGroup::ImbalanceGroup(LAMMPS *lmp) : Imbalance(lmp), id(0), factor(0) ImbalanceGroup::ImbalanceGroup(LAMMPS *lmp) : Imbalance(lmp), id(nullptr), factor(nullptr) {}
{}
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
@ -47,8 +45,7 @@ int ImbalanceGroup::options(int narg, char **arg)
factor = new double[num]; factor = new double[num];
for (int i = 0; i < num; ++i) { for (int i = 0; i < num; ++i) {
id[i] = group->find(arg[2 * i + 1]); id[i] = group->find(arg[2 * i + 1]);
if (id[i] < 0) if (id[i] < 0) error->all(FLERR, "Unknown group in balance weight command: {}", arg[2 * i + 1]);
error->all(FLERR,"Unknown group in balance weight command: {}", arg[2*i+1]);
factor[i] = utils::numeric(FLERR, arg[2 * i + 2], false, lmp); factor[i] = utils::numeric(FLERR, arg[2 * i + 2], false, lmp);
if (factor[i] <= 0.0) error->all(FLERR, "Illegal balance weight command"); if (factor[i] <= 0.0) error->all(FLERR, "Illegal balance weight command");
} }
@ -68,8 +65,7 @@ void ImbalanceGroup::compute(double *weight)
for (int i = 0; i < nlocal; ++i) { for (int i = 0; i < nlocal; ++i) {
const int imask = mask[i]; const int imask = mask[i];
for (int j = 0; j < num; ++j) { for (int j = 0; j < num; ++j) {
if (imask & bitmask[id[j]]) if (imask & bitmask[id[j]]) weight[i] *= factor[j];
weight[i] *= factor[j];
} }
} }
} }
@ -84,8 +80,7 @@ std::string ImbalanceGroup::info()
const char *const *const names = group->names; const char *const *const names = group->names;
mesg += " group weights:"; mesg += " group weights:";
for (int i = 0; i < num; ++i) for (int i = 0; i < num; ++i) mesg += fmt::format(" {}={}", names[id[i]], factor[i]);
mesg += fmt::format(" {}={}",names[id[i]],factor[i]);
mesg += "\n"; mesg += "\n";
} }
return mesg; return mesg;

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -21,7 +20,7 @@ using namespace LAMMPS_NS;
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
ImbalanceStore::ImbalanceStore(LAMMPS *lmp) : Imbalance(lmp), name(0) {} ImbalanceStore::ImbalanceStore(LAMMPS *lmp) : Imbalance(lmp), name(nullptr) {}
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -25,7 +24,7 @@ using namespace LAMMPS_NS;
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
ImbalanceVar::ImbalanceVar(LAMMPS *lmp) : Imbalance(lmp), name(0) {} ImbalanceVar::ImbalanceVar(LAMMPS *lmp) : Imbalance(lmp), name(nullptr) {}
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */

View File

@ -893,7 +893,7 @@ bool MinHFTN::compute_inner_cg_step_(const double dTrustRadius,
Private method calc_xinf_using_mpi_ 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; double dXInfLocal = 0.0;
for (int i = 0; i < nvec; i++) 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 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); double dAlpha = dmax * sqrt((double) _nNumUnknowns);
@ -1611,7 +1611,7 @@ void MinHFTN::evaluate_dir_der_(const bool bUseForwardDiffs,
Private method open_hftn_print_file_ Private method open_hftn_print_file_
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void MinHFTN::open_hftn_print_file_(void) void MinHFTN::open_hftn_print_file_()
{ {
int nMyRank; int nMyRank;
MPI_Comm_rank (world, &nMyRank); MPI_Comm_rank (world, &nMyRank);
@ -1700,7 +1700,7 @@ void MinHFTN::hftn_print_line_(const bool bIsStepAccepted,
Private method close_hftn_print_file_ Private method close_hftn_print_file_
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void MinHFTN::close_hftn_print_file_(void) void MinHFTN::close_hftn_print_file_()
{ {
if (_fpPrint != nullptr) fclose (_fpPrint); if (_fpPrint != nullptr) fclose (_fpPrint);
return; return;

View File

@ -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. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include <string.h>
#include "npair_half_size_multi_newtoff.h" #include "npair_half_size_multi_newtoff.h"
#include "atom.h" #include "atom.h"

View File

@ -346,7 +346,7 @@ void NStencil::create_setup()
// Skip all stencils by default, initialize smax // Skip all stencils by default, initialize smax
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) { for (j = 0; j < n; j++) {
flag_skip_multi[i][j] = 1; flag_skip_multi[i][j] = true;
} }
} }

View File

@ -37,8 +37,8 @@ void NStencilFullMulti2d::set_stencil_properties()
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) { for (j = 0; j < n; j++) {
flag_half_multi[i][j] = 0; flag_half_multi[i][j] = false;
flag_skip_multi[i][j] = 0; flag_skip_multi[i][j] = false;
bin_collection_multi[i][j] = j; bin_collection_multi[i][j] = j;
} }
} }

View File

@ -38,8 +38,8 @@ void NStencilFullMulti3d::set_stencil_properties()
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) { for (j = 0; j < n; j++) {
flag_half_multi[i][j] = 0; flag_half_multi[i][j] = true;
flag_skip_multi[i][j] = 0; flag_skip_multi[i][j] = false;
bin_collection_multi[i][j] = j; bin_collection_multi[i][j] = j;
} }
} }

View File

@ -43,13 +43,13 @@ void NStencilHalfMulti2d::set_stencil_properties()
for (j = 0; j < n; j++) { for (j = 0; j < n; j++) {
if(cutcollectionsq[i][i] > cutcollectionsq[j][j]) continue; 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]){ 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; bin_collection_multi[i][j] = i;
} else { } else {
flag_half_multi[i][j] = 0; flag_half_multi[i][j] = false;
bin_collection_multi[i][j] = j; bin_collection_multi[i][j] = j;
} }
} }

View File

@ -43,13 +43,13 @@ void NStencilHalfMulti2dTri::set_stencil_properties()
for (j = 0; j < n; j++) { for (j = 0; j < n; j++) {
if(cutcollectionsq[i][i] > cutcollectionsq[j][j]) continue; 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]){ 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; bin_collection_multi[i][j] = i;
} else { } else {
flag_half_multi[i][j] = 0; flag_half_multi[i][j] = false;
bin_collection_multi[i][j] = j; bin_collection_multi[i][j] = j;
} }
} }

View File

@ -43,13 +43,13 @@ void NStencilHalfMulti3d::set_stencil_properties()
for (j = 0; j < n; j++) { for (j = 0; j < n; j++) {
if(cutcollectionsq[i][i] > cutcollectionsq[j][j]) continue; 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]){ 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; bin_collection_multi[i][j] = i;
} else { } else {
flag_half_multi[i][j] = 0; flag_half_multi[i][j] = false;
bin_collection_multi[i][j] = j; bin_collection_multi[i][j] = j;
} }
} }

View File

@ -43,13 +43,13 @@ void NStencilHalfMulti3dTri::set_stencil_properties()
for (j = 0; j < n; j++) { for (j = 0; j < n; j++) {
if(cutcollectionsq[i][i] > cutcollectionsq[j][j]) continue; 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]){ 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; bin_collection_multi[i][j] = i;
} else { } else {
flag_half_multi[i][j] = 0; flag_half_multi[i][j] = false;
bin_collection_multi[i][j] = j; bin_collection_multi[i][j] = j;
} }
} }

View File

@ -317,7 +317,7 @@ void Output::write(bigint ntimestep)
if (next_restart_single == ntimestep) { if (next_restart_single == ntimestep) {
std::string file = restart1; std::string file = restart1;
std::size_t found = file.find("*"); std::size_t found = file.find('*');
if (found != std::string::npos) if (found != std::string::npos)
file.replace(found,1,fmt::format("{}",update->ntimestep)); file.replace(found,1,fmt::format("{}",update->ntimestep));
@ -405,7 +405,7 @@ void Output::write_restart(bigint ntimestep)
{ {
if (restart_flag_single) { if (restart_flag_single) {
std::string file = restart1; std::string file = restart1;
std::size_t found = file.find("*"); std::size_t found = file.find('*');
if (found != std::string::npos) if (found != std::string::npos)
file.replace(found,1,fmt::format("{}",update->ntimestep)); file.replace(found,1,fmt::format("{}",update->ntimestep));
restart->write(file); restart->write(file);

View File

@ -758,8 +758,7 @@ void Pair::add_tally_callback(Compute *ptr)
if (found < 0) { if (found < 0) {
found = num_tally_compute; found = num_tally_compute;
++num_tally_compute; ++num_tally_compute;
void *p = memory->srealloc((void *)list_tally_compute, void *p = memory->srealloc((void *)list_tally_compute, sizeof(Compute *) * num_tally_compute,
sizeof(Compute *) * num_tally_compute,
"pair:list_tally_compute"); "pair:list_tally_compute");
list_tally_compute = (Compute **) p; list_tally_compute = (Compute **) p;
list_tally_compute[num_tally_compute-1] = ptr; list_tally_compute[num_tally_compute-1] = ptr;

View File

@ -476,7 +476,7 @@ void PairHybrid::coeff(int narg, char **arg)
// 4th arg = pair sub-style index if name used multiple times // 4th arg = pair sub-style index if name used multiple times
// allow for "none" as valid sub-style name // allow for "none" as valid sub-style name
int multflag; int multflag = 0;
int m; int m;
for (m = 0; m < nstyles; m++) { for (m = 0; m < nstyles; m++) {

View File

@ -42,7 +42,7 @@ void PairHybridOverlay::coeff(int narg, char **arg)
// 4th arg = pair sub-style index if name used multiple times // 4th arg = pair sub-style index if name used multiple times
// allow for "none" as valid sub-style name // allow for "none" as valid sub-style name
int multflag; int multflag = 0;
int m; int m;
for (m = 0; m < nstyles; m++) { for (m = 0; m < nstyles; m++) {
@ -128,7 +128,7 @@ void PairHybridOverlay::init_svector()
void PairHybridOverlay::copy_svector(int itype, int jtype) void PairHybridOverlay::copy_svector(int itype, int jtype)
{ {
int n=0; int n=0;
Pair *this_style; Pair *this_style = nullptr;
// fill svector array. // fill svector array.
// copy data from active styles and use 0.0 for inactive ones // copy data from active styles and use 0.0 for inactive ones

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -32,9 +31,8 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
PairHybridScaled::PairHybridScaled(LAMMPS *lmp) PairHybridScaled::PairHybridScaled(LAMMPS *lmp) :
: PairHybrid(lmp), fsum(nullptr), tsum(nullptr), PairHybrid(lmp), fsum(nullptr), tsum(nullptr), scaleval(nullptr), scaleidx(nullptr)
scaleval(nullptr), scaleidx(nullptr)
{ {
nmaxfsum = -1; nmaxfsum = -1;
} }
@ -73,13 +71,11 @@ void PairHybridScaled::compute(int eflag, int vflag)
for (i = 0; i < nvars; ++i) { for (i = 0; i < nvars; ++i) {
j = input->variable->find(scalevars[i].c_str()); j = input->variable->find(scalevars[i].c_str());
if (j < 0) if (j < 0)
error->all(FLERR,"Variable '{}' not found when updating " error->all(FLERR, "Variable '{}' not found when updating scale factors", scalevars[i]);
"scale factors",scalevars[i]);
vals[i] = input->variable->compute_equal(j); vals[i] = input->variable->compute_equal(j);
} }
for (i = 0; i < nstyles; ++i) { for (i = 0; i < nstyles; ++i) {
if (scaleidx[i] >= 0) if (scaleidx[i] >= 0) scaleval[i] = vals[scaleidx[i]];
scaleval[i] = vals[scaleidx[i]];
} }
delete[] vals; delete[] vals;
} }
@ -122,8 +118,10 @@ void PairHybridScaled::compute(int eflag, int vflag)
// necessary so substyle will not invoke virial_fdotr_compute() // necessary so substyle will not invoke virial_fdotr_compute()
int vflag_substyle; int vflag_substyle;
if (vflag & VIRIAL_FDOTR) vflag_substyle = vflag & ~VIRIAL_FDOTR; if (vflag & VIRIAL_FDOTR)
else vflag_substyle = vflag; vflag_substyle = vflag & ~VIRIAL_FDOTR;
else
vflag_substyle = vflag;
double *saved_special = save_special(); double *saved_special = save_special();
@ -153,7 +151,8 @@ void PairHybridScaled::compute(int eflag, int vflag)
if (styles[m]->compute_flag == 0) continue; if (styles[m]->compute_flag == 0) continue;
if (outerflag && styles[m]->respa_enable) if (outerflag && styles[m]->respa_enable)
styles[m]->compute_outer(eflag, vflag_substyle); styles[m]->compute_outer(eflag, vflag_substyle);
else styles[m]->compute(eflag,vflag_substyle); else
styles[m]->compute(eflag, vflag_substyle);
} }
// add scaled forces to global sum // add scaled forces to global sum
@ -193,8 +192,7 @@ void PairHybridScaled::compute(int eflag, int vflag)
if (force->newton_pair) n += atom->nghost; if (force->newton_pair) n += atom->nghost;
double **vatom_substyle = styles[m]->vatom; double **vatom_substyle = styles[m]->vatom;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
for (j = 0; j < 6; j++) for (j = 0; j < 6; j++) vatom[i][j] += scale * vatom_substyle[i][j];
vatom[i][j] += scale*vatom_substyle[i][j];
} }
// substyles may be CENTROID_SAME or CENTROID_AVAIL // 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) { if (styles[m]->centroidstressflag == CENTROID_AVAIL) {
double **cvatom_substyle = styles[m]->cvatom; double **cvatom_substyle = styles[m]->cvatom;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
for (j = 0; j < 9; j++) for (j = 0; j < 9; j++) cvatom[i][j] += scale * cvatom_substyle[i][j];
cvatom[i][j] += scale*cvatom_substyle[i][j];
} else { } else {
double **vatom_substyle = styles[m]->vatom; double **vatom_substyle = styles[m]->vatom;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
for (j = 0; j < 6; j++) { for (j = 0; j < 6; j++) { cvatom[i][j] += scale * vatom_substyle[i][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 = 6; j < 9; j++) {
cvatom[i][j] += scale*vatom_substyle[i][j-3];
}
} }
} }
} }
@ -246,8 +239,7 @@ void PairHybridScaled::settings(int narg, char **arg)
{ {
if (narg < 1) error->all(FLERR, "Illegal pair_style command"); if (narg < 1) error->all(FLERR, "Illegal pair_style command");
if (lmp->kokkos && !utils::strmatch(force->pair_style, "^hybrid.*/kk$")) if (lmp->kokkos && !utils::strmatch(force->pair_style, "^hybrid.*/kk$"))
error->all(FLERR,"Must use pair_style {}/kk with Kokkos", error->all(FLERR, "Must use pair_style {}/kk with Kokkos", force->pair_style);
force->pair_style);
if (atom->avec->forceclearflag) 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");
@ -321,7 +313,7 @@ void PairHybridScaled::settings(int narg, char **arg)
} }
if (idx < 0) { if (idx < 0) {
idx = scalevars.size(); idx = scalevars.size();
scalevars.push_back(arg[iarg]+2); scalevars.emplace_back(arg[iarg] + 2);
} }
} else { } else {
val = utils::numeric(FLERR, arg[iarg], false, lmp); val = utils::numeric(FLERR, arg[iarg], false, lmp);
@ -341,16 +333,17 @@ void PairHybridScaled::settings(int narg, char **arg)
compute_tally[nstyles] = 1; compute_tally[nstyles] = 1;
if ((styles[nstyles]->suffix_flag & (Suffix::INTEL | Suffix::GPU | Suffix::OMP)) != 0) if ((styles[nstyles]->suffix_flag & (Suffix::INTEL | Suffix::GPU | Suffix::OMP)) != 0)
error->all(FLERR,"Pair style hybrid/scaled does not support " error->all(FLERR,
"Pair style hybrid/scaled does not support "
"accelerator styles"); "accelerator styles");
// determine list of arguments for pair style settings // determine list of arguments for pair style settings
// by looking for the next known pair style name. // by looking for the next known pair style name.
jarg = iarg + 1; jarg = iarg + 1;
while ((jarg < narg) while ((jarg < narg) && !force->pair_map->count(arg[jarg]) &&
&& !force->pair_map->count(arg[jarg]) !lmp->match_style("pair", arg[jarg]))
&& !lmp->match_style("pair",arg[jarg])) jarg++; jarg++;
// decrement to account for scale factor except when last argument // decrement to account for scale factor except when last argument
@ -383,11 +376,10 @@ void PairHybridScaled::settings(int narg, char **arg)
since overlay could have multiple sub-styles, sum results explicitly since overlay could have multiple sub-styles, sum results explicitly
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
double PairHybridScaled::single(int i, int j, int itype, int jtype, double rsq, double PairHybridScaled::single(int i, int j, int itype, int jtype, double rsq, double factor_coul,
double factor_coul, double factor_lj, double &fforce) double factor_lj, double &fforce)
{ {
if (nmap[itype][jtype] == 0) if (nmap[itype][jtype] == 0) error->one(FLERR, "Invoked pair single on pair style none");
error->one(FLERR,"Invoked pair single on pair style none");
// update scale values from variables where needed // 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) { for (i = 0; i < nvars; ++i) {
j = input->variable->find(scalevars[i].c_str()); j = input->variable->find(scalevars[i].c_str());
if (j < 0) if (j < 0)
error->all(FLERR,"Variable '{}' not found when updating " error->all(FLERR, "Variable '{}' not found when updating scale factors", scalevars[i]);
"scale factors",scalevars[i]);
vals[i] = input->variable->compute_equal(j); vals[i] = input->variable->compute_equal(j);
} }
for (i = 0; i < nstyles; ++i) { for (i = 0; i < nstyles; ++i) {
if (scaleidx[i] >= 0) if (scaleidx[i] >= 0) scaleval[i] = vals[scaleidx[i]];
scaleval[i] = vals[scaleidx[i]];
} }
delete[] vals; delete[] vals;
} }
@ -414,18 +404,17 @@ double PairHybridScaled::single(int i, int j, int itype, int jtype, double rsq,
double scale; double scale;
for (int m = 0; m < nmap[itype][jtype]; m++) { for (int m = 0; m < nmap[itype][jtype]; m++) {
if (rsq < styles[map[itype][jtype][m]]->cutsq[itype][jtype]) { auto pstyle = styles[map[itype][jtype][m]];
if (styles[map[itype][jtype][m]]->single_enable == 0) if (rsq < pstyle->cutsq[itype][jtype]) {
if (pstyle->single_enable == 0)
error->one(FLERR, "Pair hybrid sub-style does not support single call"); error->one(FLERR, "Pair hybrid sub-style does not support single call");
if ((special_lj[map[itype][jtype][m]] != nullptr) || if ((special_lj[map[itype][jtype][m]] != nullptr) ||
(special_coul[map[itype][jtype][m]] != nullptr)) (special_coul[map[itype][jtype][m]] != nullptr))
error->one(FLERR,"Pair hybrid single calls do not support" error->one(FLERR, "Pair hybrid single() does not support per sub-style special_bond");
" per sub-style special bond values");
scale = scaleval[map[itype][jtype][m]]; scale = scaleval[map[itype][jtype][m]];
esum += scale * styles[map[itype][jtype][m]]->single(i,j,itype,jtype,rsq, esum += scale * pstyle->single(i, j, itype, jtype, rsq, factor_coul, factor_lj, fone);
factor_coul,factor_lj,fone);
fforce += scale * fone; fforce += scale * fone;
} }
} }
@ -451,7 +440,7 @@ void PairHybridScaled::coeff(int narg, char **arg)
// 4th arg = pair sub-style index if name used multiple times // 4th arg = pair sub-style index if name used multiple times
// allow for "none" as valid sub-style name // allow for "none" as valid sub-style name
int multflag; int multflag = 0;
int m; int m;
for (m = 0; m < nstyles; m++) { for (m = 0; m < nstyles; m++) {
@ -461,16 +450,21 @@ void PairHybridScaled::coeff(int narg, char **arg)
multflag = 1; multflag = 1;
if (narg < 4) error->all(FLERR, "Incorrect args for pair coefficients"); if (narg < 4) error->all(FLERR, "Incorrect args for pair coefficients");
int index = utils::inumeric(FLERR, arg[3], false, lmp); int index = utils::inumeric(FLERR, arg[3], false, lmp);
if (index == multiple[m]) break; if (index == multiple[m])
else continue; break;
} else break; else
continue;
} else
break;
} }
} }
int none = 0; int none = 0;
if (m == nstyles) { if (m == nstyles) {
if (strcmp(arg[2],"none") == 0) none = 1; if (strcmp(arg[2], "none") == 0)
else error->all(FLERR,"Pair coeff for hybrid has invalid style"); none = 1;
else
error->all(FLERR, "Pair coeff for hybrid has invalid style");
} }
// move 1st/2nd args to 2nd/3rd args // move 1st/2nd args to 2nd/3rd args
@ -557,13 +551,13 @@ void PairHybridScaled::read_restart(FILE *fp)
if (me == 0) utils::sfread(FLERR, &n, sizeof(int), 1, fp, nullptr, error); if (me == 0) utils::sfread(FLERR, &n, sizeof(int), 1, fp, nullptr, error);
MPI_Bcast(&n, 1, MPI_INT, 0, world); MPI_Bcast(&n, 1, MPI_INT, 0, world);
scalevars.resize(n); scalevars.resize(n);
for (size_t j=0; j < scalevars.size(); ++j) { for (auto &scale : scalevars) {
if (me == 0) utils::sfread(FLERR, &n, sizeof(int), 1, fp, nullptr, error); if (me == 0) utils::sfread(FLERR, &n, sizeof(int), 1, fp, nullptr, error);
MPI_Bcast(&n, 1, MPI_INT, 0, world); MPI_Bcast(&n, 1, MPI_INT, 0, world);
tmp = new char[n]; tmp = new char[n];
if (me == 0) utils::sfread(FLERR, tmp, sizeof(char), n, fp, nullptr, error); if (me == 0) utils::sfread(FLERR, tmp, sizeof(char), n, fp, nullptr, error);
MPI_Bcast(tmp, n, MPI_CHAR, 0, world); MPI_Bcast(tmp, n, MPI_CHAR, 0, world);
scalevars[j] = tmp; scale = tmp;
delete[] tmp; delete[] tmp;
} }
} }
@ -578,8 +572,7 @@ void PairHybridScaled::init_svector()
// allocate svector // allocate svector
single_extra = 0; single_extra = 0;
for (int m = 0; m < nstyles; m++) for (int m = 0; m < nstyles; m++) single_extra += styles[m]->single_extra;
single_extra += styles[m]->single_extra;
if (single_extra) { if (single_extra) {
delete[] svector; delete[] svector;

View File

@ -285,7 +285,7 @@ bigint ReadDump::seek(bigint nrequest, int exact)
ntimestep = -1; ntimestep = -1;
if (multiproc) { if (multiproc) {
std::string multiname = files[ifile]; std::string multiname = files[ifile];
multiname.replace(multiname.find("%"),1,"0"); multiname.replace(multiname.find('%'),1,"0");
readers[0]->open_file(multiname.c_str()); readers[0]->open_file(multiname.c_str());
} else readers[0]->open_file(files[ifile]); } 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++) { for (int i = 0; i < nreader; i++) {
if (me == 0 && i == 0) continue; // proc 0, reader 0 already found it if (me == 0 && i == 0) continue; // proc 0, reader 0 already found it
std::string multiname = files[currentfile]; 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()); readers[i]->open_file(multiname.c_str());
bigint step; bigint step;
@ -377,7 +377,7 @@ bigint ReadDump::next(bigint ncurrent, bigint nlast, int nevery, int nskip)
if (ifile != currentfile) { if (ifile != currentfile) {
if (multiproc) { if (multiproc) {
std::string multiname = files[ifile]; std::string multiname = files[ifile];
multiname.replace(multiname.find("%"),1,"0"); multiname.replace(multiname.find('%'),1,"0");
readers[0]->open_file(multiname.c_str()); readers[0]->open_file(multiname.c_str());
} else readers[0]->open_file(files[ifile]); } 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++) { for (int i = 0; i < nreader; i++) {
if (me == 0 && i == 0) continue; if (me == 0 && i == 0) continue;
std::string multiname = files[currentfile]; 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()); readers[i]->open_file(multiname.c_str());
bigint step; bigint step;

View File

@ -106,7 +106,7 @@ void ReadRestart::command(int narg, char **arg)
utils::logmesg(lmp,"Reading restart file ...\n"); utils::logmesg(lmp,"Reading restart file ...\n");
std::string hfile = file; std::string hfile = file;
if (multiproc) { if (multiproc) {
hfile.replace(hfile.find("%"),1,"base"); hfile.replace(hfile.find('%'),1,"base");
} }
fp = fopen(hfile.c_str(),"rb"); fp = fopen(hfile.c_str(),"rb");
if (fp == nullptr) if (fp == nullptr)
@ -268,7 +268,7 @@ void ReadRestart::command(int narg, char **arg)
for (int iproc = me; iproc < multiproc_file; iproc += nprocs) { for (int iproc = me; iproc < multiproc_file; iproc += nprocs) {
std::string procfile = file; 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"); fp = fopen(procfile.c_str(),"rb");
if (fp == nullptr) if (fp == nullptr)
error->one(FLERR,"Cannot open restart file {}: {}", error->one(FLERR,"Cannot open restart file {}: {}",
@ -332,7 +332,7 @@ void ReadRestart::command(int narg, char **arg)
if (filereader) { if (filereader) {
std::string procfile = file; 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"); fp = fopen(procfile.c_str(),"rb");
if (fp == nullptr) if (fp == nullptr)
error->one(FLERR,"Cannot open restart file {}: {}", procfile, utils::getsyserror()); error->one(FLERR,"Cannot open restart file {}: {}", procfile, utils::getsyserror());

View File

@ -89,7 +89,7 @@ void ResetMolIDs::command(int narg, char **arg)
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg],"offset") == 0) { } else if (strcmp(arg[iarg],"offset") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal reset_mol_ids command"); 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"); if (offset < -1) error->all(FLERR,"Illegal reset_mol_ids command");
iarg += 2; iarg += 2;
} else error->all(FLERR,"Illegal reset_mol_ids command"); } else error->all(FLERR,"Illegal reset_mol_ids command");

View File

@ -61,7 +61,7 @@ void WriteData::command(int narg, char **arg)
// if filename contains a "*", replace with current timestep // if filename contains a "*", replace with current timestep
std::string file = arg[0]; std::string file = arg[0];
std::size_t found = file.find("*"); std::size_t found = file.find('*');
if (found != std::string::npos) if (found != std::string::npos)
file.replace(found,1,fmt::format("{}",update->ntimestep)); file.replace(found,1,fmt::format("{}",update->ntimestep));

View File

@ -65,7 +65,7 @@ void WriteRestart::command(int narg, char **arg)
// if filename contains a "*", replace with current timestep // if filename contains a "*", replace with current timestep
std::string file = arg[0]; std::string file = arg[0];
std::size_t found = file.find("*"); std::size_t found = file.find('*');
if (found != std::string::npos) if (found != std::string::npos)
file.replace(found,1,fmt::format("{}",update->ntimestep)); 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 "%" 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 // special case where reneighboring is not done in integrator
// on timestep restart file is written (due to build_once being set) // 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) { if (me == 0) {
std::string base = file; 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"); fp = fopen(base.c_str(),"wb");
if (fp == nullptr) if (fp == nullptr)
@ -290,7 +290,7 @@ void WriteRestart::write(std::string file)
} }
std::string multiname = file; std::string multiname = file;
multiname.replace(multiname.find("%"),1,fmt::format("{}",icluster)); multiname.replace(multiname.find('%'),1,fmt::format("{}",icluster));
if (filewriter) { if (filewriter) {
fp = fopen(multiname.c_str(),"wb"); fp = fopen(multiname.c_str(),"wb");

View File

@ -29,7 +29,7 @@ class WriteRestart : public Command {
WriteRestart(class LAMMPS *); WriteRestart(class LAMMPS *);
void command(int, char **); void command(int, char **);
void multiproc_options(int, int, int, char **); void multiproc_options(int, int, int, char **);
void write(std::string); void write(const std::string &);
private: private:
int me, nprocs; int me, nprocs;

View File

@ -29,9 +29,9 @@
// g++ -g -DLAMMPS_BIGBIG binarytxt.o -o binary2txt // g++ -g -DLAMMPS_BIGBIG binarytxt.o -o binary2txt
// again -DLAMMPS_SMALLBIG is the default // again -DLAMMPS_SMALLBIG is the default
#include "stdint.h" #include <cstdint>
#define __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS
#include "inttypes.h" #include <cinttypes>
#ifndef PRId64 #ifndef PRId64
#define PRId64 "ld" #define PRId64 "ld"
@ -65,7 +65,7 @@ int main(int narg, char **arg)
char boundstr[9]; char boundstr[9];
int maxbuf = 0; int maxbuf = 0;
double *buf = NULL; double *buf = nullptr;
if (narg == 1) { if (narg == 1) {
printf("Syntax: binary2txt file1 file2 ...\n"); printf("Syntax: binary2txt file1 file2 ...\n");