1
/* ----------------------------------------------------------------------
2
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
3
http://lammps.sandia.gov, Sandia National Laboratories
4
Steve Plimpton, sjplimp@sandia.gov
6
This software is distributed under the GNU General Public License.
8
See the README file in the top-level LAMMPS directory.
9
------------------------------------------------------------------------- */
11
/* ----------------------------------------------------------------------
12
Contributing author: Axel Kohlmeyer (Temple U)
13
------------------------------------------------------------------------- */
16
#include "pair_nm_cut_omp.h"
21
#include "neigh_list.h"
24
using namespace LAMMPS_NS;
26
/* ---------------------------------------------------------------------- */
28
PairNMCutOMP::PairNMCutOMP(LAMMPS *lmp) :
29
PairNMCut(lmp), ThrOMP(lmp, THR_PAIR)
31
suffix_flag |= Suffix::OMP;
35
/* ---------------------------------------------------------------------- */
37
void PairNMCutOMP::compute(int eflag, int vflag)
40
ev_setup(eflag,vflag);
41
} else evflag = vflag_fdotr = 0;
43
const int nall = atom->nlocal + atom->nghost;
44
const int nthreads = comm->nthreads;
45
const int inum = list->inum;
48
#pragma omp parallel default(none) shared(eflag,vflag)
53
loop_setup_thr(ifrom, ito, tid, inum, nthreads);
54
ThrData *thr = fix->get_thr(tid);
55
ev_setup_thr(eflag, vflag, nall, eatom, vatom, thr);
59
if (force->newton_pair) eval<1,1,1>(ifrom, ito, thr);
60
else eval<1,1,0>(ifrom, ito, thr);
62
if (force->newton_pair) eval<1,0,1>(ifrom, ito, thr);
63
else eval<1,0,0>(ifrom, ito, thr);
66
if (force->newton_pair) eval<0,0,1>(ifrom, ito, thr);
67
else eval<0,0,0>(ifrom, ito, thr);
69
reduce_thr(this, eflag, vflag, thr);
70
} // end of omp parallel region
73
template <int EVFLAG, int EFLAG, int NEWTON_PAIR>
74
void PairNMCutOMP::eval(int iifrom, int iito, ThrData * const thr)
76
const dbl3_t * _noalias const x = (dbl3_t *) atom->x[0];
77
dbl3_t * _noalias const f = (dbl3_t *) thr->get_f()[0];
78
const int * _noalias const type = atom->type;
79
const double * _noalias const special_lj = force->special_lj;
80
const int * _noalias const ilist = list->ilist;
81
const int * _noalias const numneigh = list->numneigh;
82
const int * const * const firstneigh = list->firstneigh;
84
double xtmp,ytmp,ztmp,delx,dely,delz,fxtmp,fytmp,fztmp;
85
double r,rsq,r2inv,rminv,rninv,forcenm,factor_lj,evdwl,fpair;
87
const int nlocal = atom->nlocal;
92
// loop over neighbors of my atoms
94
for (int ii = iifrom; ii < iito; ++ii) {
95
const int i = ilist[ii];
96
const int itype = type[i];
97
const int * _noalias const jlist = firstneigh[i];
98
const double * _noalias const cutsqi = cutsq[itype];
99
const double * _noalias const offseti = offset[itype];
100
const double * _noalias const mmi = mm[itype];
101
const double * _noalias const nni = nn[itype];
102
const double * _noalias const nmi = nm[itype];
103
const double * _noalias const e0nmi = e0nm[itype];
104
const double * _noalias const r0mi = r0m[itype];
105
const double * _noalias const r0ni = r0n[itype];
111
fxtmp=fytmp=fztmp=0.0;
113
for (jj = 0; jj < jnum; jj++) {
115
factor_lj = special_lj[sbmask(j)];
118
delx = xtmp - x[j].x;
119
dely = ytmp - x[j].y;
120
delz = ztmp - x[j].z;
121
rsq = delx*delx + dely*dely + delz*delz;
124
if (rsq < cutsqi[jtype]) {
128
rminv = pow(r2inv,mmi[jtype]*0.5);
129
rninv = pow(r2inv,nni[jtype]*0.5);
131
forcenm = e0nmi[jtype]*nmi[jtype] *
132
(r0ni[jtype]/pow(r,nni[jtype]) -
133
r0mi[jtype]/pow(r,mmi[jtype]));
134
fpair = factor_lj*forcenm*r2inv;
139
if (NEWTON_PAIR || j < nlocal) {
140
f[j].x -= delx*fpair;
141
f[j].y -= dely*fpair;
142
f[j].z -= delz*fpair;
146
evdwl = e0nmi[jtype] *
147
(mmi[jtype]*r0ni[jtype]*rninv -
148
nni[jtype]*r0mi[jtype]*rminv) - offseti[jtype];
151
if (EVFLAG) ev_tally_thr(this,i,j,nlocal,NEWTON_PAIR,
152
evdwl,0.0,fpair,delx,dely,delz,thr);
161
/* ---------------------------------------------------------------------- */
163
double PairNMCutOMP::memory_usage()
165
double bytes = memory_usage_thr();
166
bytes += PairNMCut::memory_usage();