format changes
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* -*- c++ -*- ----------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -17,22 +16,18 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "gz_file_writer.h"
|
||||
#include <stdio.h>
|
||||
#include "fmt/format.h"
|
||||
#include <cstdio>
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -50,13 +45,12 @@ void GzFileWriter::open(const std::string &path, bool append)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -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 <stdio.h>
|
||||
#include "fmt/format.h"
|
||||
#include <cstdio>
|
||||
|
||||
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;
|
||||
}
|
||||
@ -57,9 +53,7 @@ void ZstdFileWriter::open(const std::string &path, bool append)
|
||||
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();
|
||||
|
||||
@ -75,15 +69,15 @@ void ZstdFileWriter::open(const std::string &path, bool append)
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -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");
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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()
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -40,8 +40,8 @@ using namespace MathConst;
|
||||
|
||||
PairLJCutCoulDebyeDielectric::PairLJCutCoulDebyeDielectric(LAMMPS *lmp) : PairLJCutCoulDebye(lmp)
|
||||
{
|
||||
efield = NULL;
|
||||
epot = NULL;
|
||||
efield = nullptr;
|
||||
epot = nullptr;
|
||||
nmax = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 -
|
||||
|
||||
@ -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 -
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,8 +308,7 @@ 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,
|
||||
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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -32,8 +32,8 @@
|
||||
#include "update.h"
|
||||
#include "verlet.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <string.h>
|
||||
|
||||
enum { NONE, REAL, METAL }; // LAMMPS units which MDI supports
|
||||
|
||||
|
||||
@ -31,8 +31,8 @@
|
||||
#include "update.h"
|
||||
#include "verlet.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <string.h>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* -*- c++ -*- ----------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 <string.h>
|
||||
#include "npair_half_size_multi_newtoff.h"
|
||||
|
||||
#include "atom.h"
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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++) {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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));
|
||||
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -29,9 +29,9 @@
|
||||
// g++ -g -DLAMMPS_BIGBIG binarytxt.o -o binary2txt
|
||||
// again -DLAMMPS_SMALLBIG is the default
|
||||
|
||||
#include "stdint.h"
|
||||
#include <cstdint>
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#include "inttypes.h"
|
||||
#include <cinttypes>
|
||||
|
||||
#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");
|
||||
|
||||
Reference in New Issue
Block a user