add clang-format support to plugin examples

This commit is contained in:
Axel Kohlmeyer
2021-05-05 23:51:12 -04:00
parent 5fcd0d8b79
commit 49a7bb57de
21 changed files with 376 additions and 326 deletions

View File

@ -44,7 +44,7 @@ BondZero2::~BondZero2()
void BondZero2::compute(int eflag, int vflag)
{
ev_init(eflag,vflag);
ev_init(eflag, vflag);
}
/* ---------------------------------------------------------------------- */
@ -52,11 +52,13 @@ void BondZero2::compute(int eflag, int vflag)
void BondZero2::settings(int narg, char **arg)
{
if ((narg != 0) && (narg != 1))
error->all(FLERR,"Illegal bond_style command");
error->all(FLERR, "Illegal bond_style command");
if (narg == 1) {
if (strcmp("nocoeff",arg[0]) == 0) coeffflag=0;
else error->all(FLERR,"Illegal bond_style command");
if (strcmp("nocoeff", arg[0]) == 0)
coeffflag = 0;
else
error->all(FLERR, "Illegal bond_style command");
}
}
@ -67,8 +69,8 @@ void BondZero2::allocate()
allocated = 1;
int n = atom->nbondtypes;
memory->create(r0,n+1,"bond:r0");
memory->create(setflag,n+1,"bond:setflag");
memory->create(r0, n + 1, "bond:r0");
memory->create(setflag, n + 1, "bond:setflag");
for (int i = 1; i <= n; i++) setflag[i] = 0;
}
@ -79,16 +81,16 @@ void BondZero2::allocate()
void BondZero2::coeff(int narg, char **arg)
{
if ((narg < 1) || (coeffflag && narg > 2))
error->all(FLERR,"Incorrect args for bond coefficients");
error->all(FLERR, "Incorrect args for bond coefficients");
if (!allocated) allocate();
int ilo,ihi;
utils::bounds(FLERR,arg[0],1,atom->nbondtypes,ilo,ihi,error);
int ilo, ihi;
utils::bounds(FLERR, arg[0], 1, atom->nbondtypes, ilo, ihi, error);
double r0_one = 0.0;
if (coeffflag && (narg == 2))
r0_one = utils::numeric(FLERR,arg[1],false,lmp);
r0_one = utils::numeric(FLERR, arg[1], false, lmp);
int count = 0;
for (int i = ilo; i <= ihi; i++) {
@ -97,7 +99,7 @@ void BondZero2::coeff(int narg, char **arg)
count++;
}
if (count == 0) error->all(FLERR,"Incorrect args for bond coefficients");
if (count == 0) error->all(FLERR, "Incorrect args for bond coefficients");
}
/* ----------------------------------------------------------------------
@ -113,8 +115,9 @@ double BondZero2::equilibrium_distance(int i)
proc 0 writes out coeffs to restart file
------------------------------------------------------------------------- */
void BondZero2::write_restart(FILE *fp) {
fwrite(&r0[1],sizeof(double),atom->nbondtypes,fp);
void BondZero2::write_restart(FILE *fp)
{
fwrite(&r0[1], sizeof(double), atom->nbondtypes, fp);
}
/* ----------------------------------------------------------------------
@ -126,9 +129,10 @@ void BondZero2::read_restart(FILE *fp)
allocate();
if (comm->me == 0) {
utils::sfread(FLERR,&r0[1],sizeof(double),atom->nbondtypes,fp,nullptr,error);
utils::sfread(FLERR, &r0[1], sizeof(double), atom->nbondtypes, fp, nullptr,
error);
}
MPI_Bcast(&r0[1],atom->nbondtypes,MPI_DOUBLE,0,world);
MPI_Bcast(&r0[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
for (int i = 1; i <= atom->nbondtypes; i++) setflag[i] = 1;
}
@ -139,14 +143,13 @@ void BondZero2::read_restart(FILE *fp)
void BondZero2::write_data(FILE *fp)
{
for (int i = 1; i <= atom->nbondtypes; i++)
fprintf(fp,"%d %g\n",i,r0[i]);
for (int i = 1; i <= atom->nbondtypes; i++) fprintf(fp, "%d %g\n", i, r0[i]);
}
/* ---------------------------------------------------------------------- */
double BondZero2::single(int /*type*/, double /*rsq*/, int /*i*/, int /*j*/,
double & /*fforce*/)
double & /*fforce*/)
{
return 0.0;
}
@ -156,6 +159,6 @@ double BondZero2::single(int /*type*/, double /*rsq*/, int /*i*/, int /*j*/,
void *BondZero2::extract(const char *str, int &dim)
{
dim = 1;
if (strcmp(str,"r0")==0) return (void*) r0;
if (strcmp(str, "r0") == 0) return (void *) r0;
return nullptr;
}