enable and apply clang-format

This commit is contained in:
Axel Kohlmeyer
2022-03-17 12:20:17 -04:00
parent 982a5719c4
commit 8ffacb55ca

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -14,15 +13,15 @@
#include "bond_harmonic.h" #include "bond_harmonic.h"
#include <cmath>
#include <cstring>
#include "atom.h" #include "atom.h"
#include "neighbor.h"
#include "comm.h" #include "comm.h"
#include "error.h"
#include "force.h" #include "force.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "neighbor.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -78,8 +77,10 @@ void BondHarmonic::compute(int eflag, int vflag)
// force & energy // force & energy
if (r > 0.0) fbond = -2.0*rk/r; if (r > 0.0)
else fbond = 0.0; fbond = -2.0 * rk / r;
else
fbond = 0.0;
if (eflag) ebond = rk * dr; if (eflag) ebond = rk * dr;
@ -106,13 +107,13 @@ void BondHarmonic::compute(int eflag, int vflag)
void BondHarmonic::allocate() void BondHarmonic::allocate()
{ {
allocated = 1; allocated = 1;
int n = atom->nbondtypes; int np1 = atom->nbondtypes + 1;
memory->create(k,n+1,"bond:k"); memory->create(k, np1, "bond:k");
memory->create(r0,n+1,"bond:r0"); memory->create(r0, np1, "bond:r0");
memory->create(setflag,n+1,"bond:setflag"); memory->create(setflag, np1, "bond:setflag");
for (int i = 1; i <= n; i++) setflag[i] = 0; for (int i = 1; i < np1; i++) setflag[i] = 0;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -184,14 +185,12 @@ void BondHarmonic::read_restart(FILE *fp)
void BondHarmonic::write_data(FILE *fp) void BondHarmonic::write_data(FILE *fp)
{ {
for (int i = 1; i <= atom->nbondtypes; i++) for (int i = 1; i <= atom->nbondtypes; i++) fprintf(fp, "%d %g %g\n", i, k[i], r0[i]);
fprintf(fp,"%d %g %g\n",i,k[i],r0[i]);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
double BondHarmonic::single(int type, double rsq, int /*i*/, int /*j*/, double BondHarmonic::single(int type, double rsq, int /*i*/, int /*j*/, double &fforce)
double &fforce)
{ {
double r = sqrt(rsq); double r = sqrt(rsq);
double dr = r - r0[type]; double dr = r - r0[type];
@ -211,5 +210,3 @@ void *BondHarmonic::extract(const char *str, int &dim)
if (strcmp(str, "r0") == 0) return (void *) r0; if (strcmp(str, "r0") == 0) return (void *) r0;
return nullptr; return nullptr;
} }