apply clang-format

This commit is contained in:
Axel Kohlmeyer
2022-10-14 09:22:54 -04:00
parent 9a52019b69
commit aa0bd180d1
23 changed files with 77 additions and 72 deletions

View File

@ -319,8 +319,7 @@ void BondBPM::write_restart(FILE *fp)
void BondBPM::read_restart(FILE *fp) void BondBPM::read_restart(FILE *fp)
{ {
if (comm->me == 0) if (comm->me == 0) utils::sfread(FLERR, &overlay_flag, sizeof(int), 1, fp, nullptr, error);
utils::sfread(FLERR, &overlay_flag, sizeof(int), 1, fp, nullptr, error);
MPI_Bcast(&overlay_flag, 1, MPI_INT, 0, world); MPI_Bcast(&overlay_flag, 1, MPI_INT, 0, world);
} }

View File

@ -43,8 +43,8 @@ class BondBPMRotational : public BondBPM {
double *Fcr, *Fcs, *Tct, *Tcb; double *Fcr, *Fcs, *Tct, *Tcb;
int smooth_flag; int smooth_flag;
double elastic_forces(int, int, int, double, double, double, double *, double *, double elastic_forces(int, int, int, double, double, double, double *, double *, double *,
double *, double *, double *, double *); double *, double *, double *);
void damping_forces(int, int, int, double *, double *, double *, double *, double *); void damping_forces(int, int, int, double *, double *, double *, double *, double *);
void allocate(); void allocate();

View File

@ -356,8 +356,7 @@ void BondBPMSpring::write_restart_settings(FILE *fp)
void BondBPMSpring::read_restart_settings(FILE *fp) void BondBPMSpring::read_restart_settings(FILE *fp)
{ {
if (comm->me == 0) if (comm->me == 0) utils::sfread(FLERR, &smooth_flag, sizeof(int), 1, fp, nullptr, error);
utils::sfread(FLERR, &smooth_flag, sizeof(int), 1, fp, nullptr, error);
MPI_Bcast(&smooth_flag, 1, MPI_INT, 0, world); MPI_Bcast(&smooth_flag, 1, MPI_INT, 0, world);
} }

View File

@ -37,13 +37,13 @@ using namespace MathConst;
*/ */
SlabDipole::SlabDipole(LAMMPS *lmp) : BoundaryCorrection(lmp){}; SlabDipole::SlabDipole(LAMMPS *lmp) : BoundaryCorrection(lmp){};
void SlabDipole::compute_corr(double qsum, double slab_volfactor, int eflag_atom, void SlabDipole::compute_corr(double qsum, double slab_volfactor, int eflag_atom, int eflag_global,
int eflag_global, double &energy, double *eatom) double &energy, double *eatom)
{ {
// compute local contribution to global dipole moment // compute local contribution to global dipole moment
double *q = atom->q; double *q = atom->q;
double **x = atom->x; double **x = atom->x;
double zprd_slab = domain->zprd*slab_volfactor; double zprd_slab = domain->zprd * slab_volfactor;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
double dipole = 0.0; double dipole = 0.0;
for (int i = 0; i < nlocal; i++) dipole += q[i] * x[i][2]; for (int i = 0; i < nlocal; i++) dipole += q[i] * x[i][2];
@ -65,7 +65,8 @@ void SlabDipole::compute_corr(double qsum, double slab_volfactor, int eflag_atom
// compute corrections // compute corrections
double const e_slabcorr = MY_2PI * double const e_slabcorr = MY_2PI *
(dipole_all * dipole_all - qsum * dipole_r2 - qsum * qsum * zprd_slab * zprd_slab / 12.0) / volume; (dipole_all * dipole_all - qsum * dipole_r2 - qsum * qsum * zprd_slab * zprd_slab / 12.0) /
volume;
double const qscale = qqrd2e * scale; double const qscale = qqrd2e * scale;
if (eflag_global) energy += qscale * e_slabcorr; if (eflag_global) energy += qscale * e_slabcorr;

View File

@ -15,7 +15,6 @@
Contributing author: Rodrigo Canales (RWTH Aachen University) Contributing author: Rodrigo Canales (RWTH Aachen University)
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#ifdef PAIR_CLASS #ifdef PAIR_CLASS
// clang-format off // clang-format off
PairStyle(buck/coul/cut/intel,PairBuckCoulCutIntel); PairStyle(buck/coul/cut/intel,PairBuckCoulCutIntel);

View File

@ -47,7 +47,7 @@ class FixLatte : public Fix {
int coulomb, pbcflag, pe_peratom, virial_global, virial_peratom, neighflag; int coulomb, pbcflag, pe_peratom, virial_global, virial_peratom, neighflag;
int exclude, excludebit; int exclude, excludebit;
int eflag_caller; int eflag_caller;
char *id_pe,*id_exclude; char *id_pe, *id_exclude;
int *exclusion_group_ptr; int *exclusion_group_ptr;
int setupflag, newsystem; int setupflag, newsystem;
bigint natoms_last; bigint natoms_last;

View File

@ -172,7 +172,8 @@ void PairList::compute(int eflag, int vflag)
const double dexp = exp(-par.param.morse.alpha * dr); const double dexp = exp(-par.param.morse.alpha * dr);
fpair = 2.0 * par.param.morse.d0 * par.param.morse.alpha * (dexp * dexp - dexp) / r; fpair = 2.0 * par.param.morse.d0 * par.param.morse.alpha * (dexp * dexp - dexp) / r;
if (eflag_either) epair = par.param.morse.d0 * (dexp * dexp - 2.0 * dexp + 1.0) - par.offset; if (eflag_either)
epair = par.param.morse.d0 * (dexp * dexp - 2.0 * dexp + 1.0) - par.offset;
} else if (par.style == LJ126) { } else if (par.style == LJ126) {

View File

@ -53,7 +53,6 @@ class PairList : public Pair {
double k, b1, b2; double k, b1, b2;
}; };
union param_u { union param_u {
harm_p harm; harm_p harm;
morse_p morse; morse_p morse;

View File

@ -382,10 +382,10 @@ void PairPACEExtrapolation::coeff(int narg, char **arg)
aceimpl->ace->load_active_set(active_set_inv_filename); aceimpl->ace->load_active_set(active_set_inv_filename);
bool is_linear_extrapolation_grade = aceimpl->ace->get_is_linear_extrapolation_grade(); bool is_linear_extrapolation_grade = aceimpl->ace->get_is_linear_extrapolation_grade();
if (comm->me == 0) { if (comm->me == 0) {
if (is_linear_extrapolation_grade) if (is_linear_extrapolation_grade)
utils::logmesg(lmp, "LINEAR ASI is loaded\n"); utils::logmesg(lmp, "LINEAR ASI is loaded\n");
else else
utils::logmesg(lmp, "FULL ASI is loaded\n"); utils::logmesg(lmp, "FULL ASI is loaded\n");
} }
// clear setflag since coeff() called once with I,J = * * // clear setflag since coeff() called once with I,J = * *

View File

@ -32,8 +32,7 @@ class PairLJCutCoulCutDielectricOMP : public PairLJCutCoulCutDielectric, public
void compute(int, int) override; void compute(int, int) override;
protected: protected:
template <int EVFLAG, int EFLAG> template <int EVFLAG, int EFLAG> void eval(int ifrom, int ito, ThrData *const thr);
void eval(int ifrom, int ito, ThrData *const thr);
}; };
} // namespace LAMMPS_NS } // namespace LAMMPS_NS

View File

@ -32,8 +32,7 @@ class PairLJCutCoulDebyeDielectricOMP : public PairLJCutCoulDebyeDielectric, pub
void compute(int, int) override; void compute(int, int) override;
protected: protected:
template <int EVFLAG, int EFLAG> template <int EVFLAG, int EFLAG> void eval(int ifrom, int ito, ThrData *const thr);
void eval(int ifrom, int ito, ThrData *const thr);
}; };
} // namespace LAMMPS_NS } // namespace LAMMPS_NS

View File

@ -33,8 +33,7 @@ class PairLJCutCoulLongDielectricOMP : public PairLJCutCoulLongDielectric, publi
void compute(int, int) override; void compute(int, int) override;
protected: protected:
template <int EVFLAG, int EFLAG> template <int EVFLAG, int EFLAG> void eval(int ifrom, int ito, ThrData *const thr);
void eval(int ifrom, int ito, ThrData *const thr);
}; };
} // namespace LAMMPS_NS } // namespace LAMMPS_NS

View File

@ -255,11 +255,10 @@ void Bond::ev_tally(int i, int j, int nlocal, int newton_bond, double ebond, dou
for virial, have delx,dely,delz and fx,fy,fz for virial, have delx,dely,delz and fx,fy,fz
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Bond::ev_tally_xyz(int i, int j, int nlocal, int newton_bond, void Bond::ev_tally_xyz(int i, int j, int nlocal, int newton_bond, double ebond, double fx,
double ebond, double fx, double fy, double fz, double fy, double fz, double delx, double dely, double delz)
double delx, double dely, double delz)
{ {
double ebondhalf,v[6]; double ebondhalf, v[6];
if (eflag_either) { if (eflag_either) {
if (eflag_global) { if (eflag_global) {

View File

@ -257,10 +257,9 @@ void BondHybrid::flags()
// set comm_forward, comm_reverse, comm_reverse_off to max of any sub-style // set comm_forward, comm_reverse, comm_reverse_off to max of any sub-style
for (m = 0; m < nstyles; m++) { for (m = 0; m < nstyles; m++) {
if (styles[m]) comm_forward = MAX(comm_forward,styles[m]->comm_forward); if (styles[m]) comm_forward = MAX(comm_forward, styles[m]->comm_forward);
if (styles[m]) comm_reverse = MAX(comm_reverse,styles[m]->comm_reverse); if (styles[m]) comm_reverse = MAX(comm_reverse, styles[m]->comm_reverse);
if (styles[m]) comm_reverse_off = MAX(comm_reverse_off, if (styles[m]) comm_reverse_off = MAX(comm_reverse_off, styles[m]->comm_reverse_off);
styles[m]->comm_reverse_off);
} }
init_svector(); init_svector();
@ -276,8 +275,7 @@ void BondHybrid::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 = MAX(single_extra, styles[m]->single_extra);
single_extra = MAX(single_extra,styles[m]->single_extra);
if (single_extra) { if (single_extra) {
delete[] svector; delete[] svector;
@ -415,14 +413,12 @@ double BondHybrid::single(int type, double rsq, int i, int j, double &fforce)
void BondHybrid::copy_svector(int type) void BondHybrid::copy_svector(int type)
{ {
memset(svector,0,single_extra*sizeof(double)); memset(svector, 0, single_extra * sizeof(double));
// there is only one style in bond style hybrid for a bond type // there is only one style in bond style hybrid for a bond type
Bond *this_style = styles[map[type]]; Bond *this_style = styles[map[type]];
for (int l = 0; this_style->single_extra; ++l) { for (int l = 0; this_style->single_extra; ++l) { svector[l] = this_style->svector[l]; }
svector[l] = this_style->svector[l];
}
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -45,9 +45,15 @@ class Dump : protected Pointers {
void init(); void init();
virtual void write(); virtual void write();
virtual int pack_forward_comm(int, int *, double *, int, int *) { return 0; } virtual int pack_forward_comm(int, int *, double *, int, int *)
{
return 0;
}
virtual void unpack_forward_comm(int, int, double *) {} virtual void unpack_forward_comm(int, int, double *) {}
virtual int pack_reverse_comm(int, int, double *) { return 0; } virtual int pack_reverse_comm(int, int, double *)
{
return 0;
}
virtual void unpack_reverse_comm(int, int *, double *) {} virtual void unpack_reverse_comm(int, int *, double *) {}
void modify_params(int, char **); void modify_params(int, char **);
@ -91,9 +97,9 @@ class Dump : protected Pointers {
char *refresh; // compute ID to invoke refresh() on char *refresh; // compute ID to invoke refresh() on
int irefresh; // index of compute int irefresh; // index of compute
int skipflag; // 1 if skip condition defined int skipflag; // 1 if skip condition defined
char *skipvar; // name of variable to check for skip condition char *skipvar; // name of variable to check for skip condition
int skipindex; // index of skip variable int skipindex; // index of skip variable
char boundstr[9]; // encoding of boundary flags char boundstr[9]; // encoding of boundary flags
@ -151,11 +157,17 @@ class Dump : protected Pointers {
virtual void init_style() = 0; virtual void init_style() = 0;
virtual void openfile(); virtual void openfile();
virtual int modify_param(int, char **) { return 0; } virtual int modify_param(int, char **)
{
return 0;
}
virtual void write_header(bigint) = 0; virtual void write_header(bigint) = 0;
virtual int count(); virtual int count();
virtual void pack(tagint *) = 0; virtual void pack(tagint *) = 0;
virtual int convert_string(int, double *) { return 0; } virtual int convert_string(int, double *)
{
return 0;
}
virtual void write_data(int, double *) = 0; virtual void write_data(int, double *) = 0;
virtual void write_footer() {} virtual void write_footer() {}

View File

@ -87,8 +87,8 @@ void FixBondHistory::post_constructor()
id_fix = utils::strdup(id + std::string("_FIX_PROP_ATOM")); id_fix = utils::strdup(id + std::string("_FIX_PROP_ATOM"));
id_array = utils::strdup(std::string("d2_") + id); id_array = utils::strdup(std::string("d2_") + id);
modify->add_fix(fmt::format("{} {} property/atom {} {} writedata no", id_fix, group->names[igroup], id_array, modify->add_fix(fmt::format("{} {} property/atom {} {} writedata no", id_fix,
nbond * ndata)); group->names[igroup], id_array, nbond * ndata));
int tmp1, tmp2; int tmp1, tmp2;
index = atom->find_custom(&id_array[3], tmp1, tmp2); index = atom->find_custom(&id_array[3], tmp1, tmp2);
} }

View File

@ -46,10 +46,10 @@ class FixPair : public Fix {
double memory_usage() override; double memory_usage() override;
private: private:
int nevery,nfield,ncols; int nevery, nfield, ncols;
bigint lasttime; bigint lasttime;
char *pairname; char *pairname;
char **fieldname,**triggername; char **fieldname, **triggername;
int *trigger; int *trigger;
int **triggerptr; int **triggerptr;

View File

@ -154,8 +154,8 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) :
border = utils::logical(FLERR, arg[iarg + 1], false, lmp); border = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg], "writedata") == 0) { } else if (strcmp(arg[iarg], "writedata") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix property/atom command"); if (iarg + 2 > narg) error->all(FLERR, "Illegal fix property/atom command");
wd_section = utils::logical(FLERR,arg[iarg+1],false,lmp); wd_section = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2; iarg += 2;
} else } else
error->all(FLERR, "Illegal fix property/atom command"); error->all(FLERR, "Illegal fix property/atom command");

View File

@ -54,7 +54,7 @@ void FixUpdateSpecialBonds::setup(int /*vflag*/)
// error if more than one fix update/special/bonds // error if more than one fix update/special/bonds
if (modify->get_fix_by_style("UPDATE_SPECIAL_BONDS").size() > 1) if (modify->get_fix_by_style("UPDATE_SPECIAL_BONDS").size() > 1)
error->all(FLERR,"More than one fix update/special/bonds"); error->all(FLERR, "More than one fix update/special/bonds");
// Require atoms know about all of their bonds and if they break // Require atoms know about all of their bonds and if they break
if (force->newton_bond) error->all(FLERR, "Fix update/special/bonds requires Newton bond off"); if (force->newton_bond) error->all(FLERR, "Fix update/special/bonds requires Newton bond off");
@ -131,14 +131,14 @@ void FixUpdateSpecialBonds::pre_exchange()
// ignore n2, n3 since 1-3, 1-4 special factors required to be 1.0 // ignore n2, n3 since 1-3, 1-4 special factors required to be 1.0
n1 = nspecial[i][0]; n1 = nspecial[i][0];
if (n1 >= atom->maxspecial) if (n1 >= atom->maxspecial)
error->one(FLERR,"Special list size exceeded in fix update/special/bond"); error->one(FLERR, "Special list size exceeded in fix update/special/bond");
special[i][n1] = tagj; special[i][n1] = tagj;
nspecial[i][0] += 1; nspecial[i][0] += 1;
nspecial[i][1] = nspecial[i][2] = nspecial[i][0]; nspecial[i][1] = nspecial[i][2] = nspecial[i][0];
n1 = nspecial[j][0]; n1 = nspecial[j][0];
if (n1 >= atom->maxspecial) if (n1 >= atom->maxspecial)
error->one(FLERR,"Special list size exceeded in fix update/special/bond"); error->one(FLERR, "Special list size exceeded in fix update/special/bond");
special[j][n1] = tagi; special[j][n1] = tagi;
nspecial[j][0] += 1; nspecial[j][0] += 1;
nspecial[j][1] = nspecial[j][2] = nspecial[j][0]; nspecial[j][1] = nspecial[j][2] = nspecial[j][0];
@ -210,8 +210,8 @@ void FixUpdateSpecialBonds::pre_force(int /*vflag*/)
jnum = numneigh[i1]; jnum = numneigh[i1];
for (jj = 0; jj < jnum; jj++) { for (jj = 0; jj < jnum; jj++) {
j = jlist[jj]; j = jlist[jj];
if (((j >> SBBITS) & 3) != 0) continue; // Skip bonded pairs if (((j >> SBBITS) & 3) != 0) continue; // Skip bonded pairs
if (tag[j] == tag2) jlist[jj] = j ^ (1 << SBBITS); // Add 1-2 special bond bits if (tag[j] == tag2) jlist[jj] = j ^ (1 << SBBITS); // Add 1-2 special bond bits
} }
} }
@ -220,8 +220,8 @@ void FixUpdateSpecialBonds::pre_force(int /*vflag*/)
jnum = numneigh[i2]; jnum = numneigh[i2];
for (jj = 0; jj < jnum; jj++) { for (jj = 0; jj < jnum; jj++) {
j = jlist[jj]; j = jlist[jj];
if (((j >> SBBITS) & 3) != 0) continue; // Skip bonded pairs if (((j >> SBBITS) & 3) != 0) continue; // Skip bonded pairs
if (tag[j] == tag1) jlist[jj] = j ^ (1 << SBBITS); // Add 1-2 special bond bits if (tag[j] == tag1) jlist[jj] = j ^ (1 << SBBITS); // Add 1-2 special bond bits
} }
} }
} }

View File

@ -47,8 +47,7 @@ FixVector::FixVector(LAMMPS *lmp, int narg, char **arg) :
val.id = argi.get_name(); val.id = argi.get_name();
val.val.c = nullptr; val.val.c = nullptr;
if ((val.which == ArgInfo::UNKNOWN) || (val.which == ArgInfo::NONE) || if ((val.which == ArgInfo::UNKNOWN) || (val.which == ArgInfo::NONE) || (argi.get_dim() > 1))
(argi.get_dim() > 1))
error->all(FLERR, "Invalid fix vector argument: {}", arg[iarg]); error->all(FLERR, "Invalid fix vector argument: {}", arg[iarg]);
values.push_back(val); values.push_back(val);

View File

@ -3020,10 +3020,11 @@ Below is a brief C code demonstrating accessing this collected bond information.
.. code-block:: c .. code-block:: c
#include "library.h"
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include "library.h"
int main(int argc, char **argv) int main(int argc, char **argv)
{ {

View File

@ -1,3 +1,4 @@
// 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
@ -647,16 +648,15 @@ class Memory : protected Pointers {
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
template <typename TYPE> template <typename TYPE>
TYPE ****create4d_offset_last(TYPE ****&array, int n1lo, int n1hi, TYPE ****create4d_offset_last(TYPE ****&array, int n1lo, int n1hi, int n2lo, int n2hi, int n3lo,
int n2lo, int n2hi, int n3lo, int n3hi, int n4, int n3hi, int n4, const char *name)
const char *name)
{ {
if (n1lo > n1hi || n2lo > n2hi || n3lo > n3hi || n4 <= 0) return nullptr; if (n1lo > n1hi || n2lo > n2hi || n3lo > n3hi || n4 <= 0) return nullptr;
int n1 = n1hi - n1lo + 1; int n1 = n1hi - n1lo + 1;
int n2 = n2hi - n2lo + 1; int n2 = n2hi - n2lo + 1;
int n3 = n3hi - n3lo + 1; int n3 = n3hi - n3lo + 1;
create(array,n1,n2,n3,n4,name); create(array, n1, n2, n3, n4, name);
bigint m = ((bigint) n1) * n2; bigint m = ((bigint) n1) * n2;
for (bigint i = 0; i < m; i++) array[0][i] -= n3lo; for (bigint i = 0; i < m; i++) array[0][i] -= n3lo;
@ -666,19 +666,20 @@ class Memory : protected Pointers {
} }
template <typename TYPE> template <typename TYPE>
TYPE ****create4d_offset_last(TYPE *****& /*array*/, int /*n1lo*/, int /*n1hi*/, TYPE ****create4d_offset_last(TYPE *****& /*array*/, int /*n1lo*/, int /*n1hi*/, int /*n2lo*/,
int /*n2lo*/, int /*n2hi*/, int /*n2hi*/, int /*n3lo*/, int /*n3hi*/, int /*n4*/,
int /*n3lo*/, int /*n3hi*/, int /*n4*/,
const char *name) const char *name)
{fail(name); return nullptr;} {
fail(name);
return nullptr;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
free a 4d array with indices 1,2,3 offset free a 4d array with indices 1,2,3 offset
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
template <typename TYPE> template <typename TYPE>
void destroy4d_offset_last(TYPE ****&array, void destroy4d_offset_last(TYPE ****&array, int n1_offset, int n2_offset, int n3_offset)
int n1_offset, int n2_offset, int n3_offset)
{ {
if (array == nullptr) return; if (array == nullptr) return;
sfree(&array[n1_offset][n2_offset][n3_offset][0]); sfree(&array[n1_offset][n2_offset][n3_offset][0]);

View File

@ -806,10 +806,12 @@ Fix *Modify::add_fix(int narg, char **arg, int trysuffix)
// since some fixes access domain settings in their constructor // since some fixes access domain settings in their constructor
// nullptr must be last entry in this list // nullptr must be last entry in this list
// clang-format off
const char *exceptions[] = const char *exceptions[] =
{"GPU", "OMP", "INTEL", "property/atom", "cmap", "cmap3", "rx", {"GPU", "OMP", "INTEL", "property/atom", "cmap", "cmap3", "rx",
"deprecated", "STORE/KIM", "amoeba/pitorsion", "amoeba/bitorsion", "deprecated", "STORE/KIM", "amoeba/pitorsion", "amoeba/bitorsion",
nullptr}; nullptr};
// clang-format on
if (domain->box_exist == 0) { if (domain->box_exist == 0) {
int m; int m;