add OPENMP version and apply clang-format
This commit is contained in:
@ -11,6 +11,10 @@
|
|||||||
See the README file in the top-level LAMMPS directory.
|
See the README file in the top-level LAMMPS directory.
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
Contributing author: Axel Kohlmeyer (Temple U)
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include "pair_pedone.h"
|
#include "pair_pedone.h"
|
||||||
|
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
@ -107,7 +111,8 @@ void PairPedone::compute(int eflag, int vflag)
|
|||||||
r = sqrt(rsq);
|
r = sqrt(rsq);
|
||||||
dr = r - r0[itype][jtype];
|
dr = r - r0[itype][jtype];
|
||||||
dexp = exp(-alpha[itype][jtype] * dr);
|
dexp = exp(-alpha[itype][jtype] * dr);
|
||||||
fpair = pedone1[itype][jtype] * (dexp * dexp - dexp) / r + pedone2[itype][jtype] * r6inv * r6inv * r2inv;
|
fpair = pedone1[itype][jtype] * (dexp * dexp - dexp) / r +
|
||||||
|
pedone2[itype][jtype] * r6inv * r6inv * r2inv;
|
||||||
fpair *= factor_lj;
|
fpair *= factor_lj;
|
||||||
|
|
||||||
f[i][0] += delx * fpair;
|
f[i][0] += delx * fpair;
|
||||||
@ -362,7 +367,8 @@ double PairPedone::single(int /*i*/, int /*j*/, int itype, int jtype, double rsq
|
|||||||
dexp = exp(-alpha[itype][jtype] * dr);
|
dexp = exp(-alpha[itype][jtype] * dr);
|
||||||
r2inv = 1.0 / rsq;
|
r2inv = 1.0 / rsq;
|
||||||
r6inv = r2inv * r2inv * r2inv;
|
r6inv = r2inv * r2inv * r2inv;
|
||||||
fforce = pedone1[itype][jtype] * (dexp * dexp - dexp) / r + pedone2[itype][jtype] * r6inv * r6inv * r2inv;
|
fforce = pedone1[itype][jtype] * (dexp * dexp - dexp) / r +
|
||||||
|
pedone2[itype][jtype] * r6inv * r6inv * r2inv;
|
||||||
fforce *= factor_lj;
|
fforce *= factor_lj;
|
||||||
|
|
||||||
phi = d0[itype][jtype] * (dexp * dexp - 2.0 * dexp) + c0[itype][jtype] * r6inv * r6inv -
|
phi = d0[itype][jtype] * (dexp * dexp - 2.0 * dexp) + c0[itype][jtype] * r6inv * r6inv -
|
||||||
|
|||||||
169
src/OPENMP/pair_pedone_omp.cpp
Normal file
169
src/OPENMP/pair_pedone_omp.cpp
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
|
LAMMPS development team: developers@lammps.org
|
||||||
|
|
||||||
|
This software is distributed under the GNU General Public License.
|
||||||
|
|
||||||
|
See the README file in the top-level LAMMPS directory.
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
Contributing author: Axel Kohlmeyer (Temple U)
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "pair_pedone_omp.h"
|
||||||
|
|
||||||
|
#include "atom.h"
|
||||||
|
#include "comm.h"
|
||||||
|
#include "force.h"
|
||||||
|
#include "neigh_list.h"
|
||||||
|
#include "suffix.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
#include "omp_compat.h"
|
||||||
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
PairPedoneOMP::PairPedoneOMP(LAMMPS *lmp) : PairPedone(lmp), ThrOMP(lmp, THR_PAIR)
|
||||||
|
{
|
||||||
|
suffix_flag |= Suffix::OMP;
|
||||||
|
respa_enable = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void PairPedoneOMP::compute(int eflag, int vflag)
|
||||||
|
{
|
||||||
|
ev_init(eflag, vflag);
|
||||||
|
|
||||||
|
const int nall = atom->nlocal + atom->nghost;
|
||||||
|
const int nthreads = comm->nthreads;
|
||||||
|
const int inum = list->inum;
|
||||||
|
|
||||||
|
#if defined(_OPENMP)
|
||||||
|
#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(eflag, vflag)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
int ifrom, ito, tid;
|
||||||
|
|
||||||
|
loop_setup_thr(ifrom, ito, tid, inum, nthreads);
|
||||||
|
ThrData *thr = fix->get_thr(tid);
|
||||||
|
thr->timer(Timer::START);
|
||||||
|
ev_setup_thr(eflag, vflag, nall, eatom, vatom, nullptr, thr);
|
||||||
|
|
||||||
|
if (evflag) {
|
||||||
|
if (eflag) {
|
||||||
|
if (force->newton_pair)
|
||||||
|
eval<1, 1, 1>(ifrom, ito, thr);
|
||||||
|
else
|
||||||
|
eval<1, 1, 0>(ifrom, ito, thr);
|
||||||
|
} else {
|
||||||
|
if (force->newton_pair)
|
||||||
|
eval<1, 0, 1>(ifrom, ito, thr);
|
||||||
|
else
|
||||||
|
eval<1, 0, 0>(ifrom, ito, thr);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (force->newton_pair)
|
||||||
|
eval<0, 0, 1>(ifrom, ito, thr);
|
||||||
|
else
|
||||||
|
eval<0, 0, 0>(ifrom, ito, thr);
|
||||||
|
}
|
||||||
|
|
||||||
|
thr->timer(Timer::PAIR);
|
||||||
|
reduce_thr(this, eflag, vflag, thr);
|
||||||
|
} // end of omp parallel region
|
||||||
|
}
|
||||||
|
|
||||||
|
template <int EVFLAG, int EFLAG, int NEWTON_PAIR>
|
||||||
|
void PairPedoneOMP::eval(int iifrom, int iito, ThrData *const thr)
|
||||||
|
{
|
||||||
|
int i, j, ii, jj, jnum, itype, jtype;
|
||||||
|
double xtmp, ytmp, ztmp, delx, dely, delz, evdwl, fpair;
|
||||||
|
double rsq, r, r2inv, r6inv, dr, dexp, factor_lj;
|
||||||
|
int *ilist, *jlist, *numneigh, **firstneigh;
|
||||||
|
|
||||||
|
evdwl = 0.0;
|
||||||
|
|
||||||
|
const auto *_noalias const x = (dbl3_t *) atom->x[0];
|
||||||
|
auto *_noalias const f = (dbl3_t *) thr->get_f()[0];
|
||||||
|
const int *_noalias const type = atom->type;
|
||||||
|
const int nlocal = atom->nlocal;
|
||||||
|
const double *_noalias const special_lj = force->special_lj;
|
||||||
|
double fxtmp, fytmp, fztmp;
|
||||||
|
|
||||||
|
ilist = list->ilist;
|
||||||
|
numneigh = list->numneigh;
|
||||||
|
firstneigh = list->firstneigh;
|
||||||
|
|
||||||
|
// loop over neighbors of my atoms
|
||||||
|
|
||||||
|
for (ii = iifrom; ii < iito; ++ii) {
|
||||||
|
|
||||||
|
i = ilist[ii];
|
||||||
|
xtmp = x[i].x;
|
||||||
|
ytmp = x[i].y;
|
||||||
|
ztmp = x[i].z;
|
||||||
|
itype = type[i];
|
||||||
|
jlist = firstneigh[i];
|
||||||
|
jnum = numneigh[i];
|
||||||
|
fxtmp = fytmp = fztmp = 0.0;
|
||||||
|
|
||||||
|
for (jj = 0; jj < jnum; jj++) {
|
||||||
|
j = jlist[jj];
|
||||||
|
factor_lj = special_lj[sbmask(j)];
|
||||||
|
j &= NEIGHMASK;
|
||||||
|
|
||||||
|
delx = xtmp - x[j].x;
|
||||||
|
dely = ytmp - x[j].y;
|
||||||
|
delz = ztmp - x[j].z;
|
||||||
|
rsq = delx * delx + dely * dely + delz * delz;
|
||||||
|
jtype = type[j];
|
||||||
|
|
||||||
|
if (rsq < cutsq[itype][jtype]) {
|
||||||
|
r2inv = 1.0 / rsq;
|
||||||
|
r6inv = r2inv * r2inv * r2inv;
|
||||||
|
r = sqrt(rsq);
|
||||||
|
dr = r - r0[itype][jtype];
|
||||||
|
dexp = exp(-alpha[itype][jtype] * dr);
|
||||||
|
fpair = pedone1[itype][jtype] * (dexp * dexp - dexp) / r +
|
||||||
|
pedone2[itype][jtype] * r6inv * r6inv * r2inv;
|
||||||
|
fpair *= factor_lj;
|
||||||
|
|
||||||
|
fxtmp += delx * fpair;
|
||||||
|
fytmp += dely * fpair;
|
||||||
|
fztmp += delz * fpair;
|
||||||
|
if (NEWTON_PAIR || j < nlocal) {
|
||||||
|
f[j].x -= delx * fpair;
|
||||||
|
f[j].y -= dely * fpair;
|
||||||
|
f[j].z -= delz * fpair;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EFLAG) {
|
||||||
|
evdwl = d0[itype][jtype] * (dexp * dexp - 2.0 * dexp) + c0[itype][jtype] * r6inv * r6inv -
|
||||||
|
offset[itype][jtype];
|
||||||
|
evdwl *= factor_lj;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EVFLAG)
|
||||||
|
ev_tally_thr(this, i, j, nlocal, NEWTON_PAIR, evdwl, 0.0, fpair, delx, dely, delz, thr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f[i].x += fxtmp;
|
||||||
|
f[i].y += fytmp;
|
||||||
|
f[i].z += fztmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
double PairPedoneOMP::memory_usage()
|
||||||
|
{
|
||||||
|
double bytes = memory_usage_thr();
|
||||||
|
bytes += PairPedone::memory_usage();
|
||||||
|
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
48
src/OPENMP/pair_pedone_omp.h
Normal file
48
src/OPENMP/pair_pedone_omp.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/* -*- c++ -*- ----------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
https://www.lammps.org/, Sandia National Laboratories
|
||||||
|
LAMMPS development team: developers@lammps.org
|
||||||
|
|
||||||
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
|
certain rights in this software. This software is distributed under
|
||||||
|
the GNU General Public License.
|
||||||
|
|
||||||
|
See the README file in the top-level LAMMPS directory.
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
Contributing author: Axel Kohlmeyer (Temple U)
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifdef PAIR_CLASS
|
||||||
|
// clang-format off
|
||||||
|
PairStyle(pedone/omp,PairPedoneOMP);
|
||||||
|
// clang-format on
|
||||||
|
#else
|
||||||
|
|
||||||
|
#ifndef LMP_PAIR_PEDONE_OMP_H
|
||||||
|
#define LMP_PAIR_PEDONE_OMP_H
|
||||||
|
|
||||||
|
#include "pair_pedone.h"
|
||||||
|
#include "thr_omp.h"
|
||||||
|
|
||||||
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
|
class PairPedoneOMP : public PairPedone, public ThrOMP {
|
||||||
|
|
||||||
|
public:
|
||||||
|
PairPedoneOMP(class LAMMPS *);
|
||||||
|
|
||||||
|
void compute(int, int) override;
|
||||||
|
double memory_usage() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
template <int EVFLAG, int EFLAG, int NEWTON_PAIR>
|
||||||
|
void eval(int ifrom, int ito, ThrData *const thr);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace LAMMPS_NS
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@ -29,7 +29,11 @@ pair_style: hybrid/overlay pedone 8.0 coul/dsf 0.05 8.0
|
|||||||
pair_coeff: ! |
|
pair_coeff: ! |
|
||||||
* * coul/dsf
|
* * coul/dsf
|
||||||
1 2 pedone 0.030211 2.241334 2.923245 5.0
|
1 2 pedone 0.030211 2.241334 2.923245 5.0
|
||||||
extract: ! ""
|
extract: ! |
|
||||||
|
c0 2
|
||||||
|
d0 2
|
||||||
|
r0 2
|
||||||
|
alpha 2
|
||||||
natoms: 32
|
natoms: 32
|
||||||
init_vdwl: -0.05846735245123568
|
init_vdwl: -0.05846735245123568
|
||||||
init_coul: -127.6163776098739
|
init_coul: -127.6163776098739
|
||||||
|
|||||||
Reference in New Issue
Block a user