Commit e37d2b5c authored by Anders Hafreager's avatar Anders Hafreager
Browse files

Calculating short neighbor lists

parent 38707808
Loading
Loading
Loading
Loading
+58 −1
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ void PairVashishtaKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
  newton_pair = force->newton_pair;
  nall = atom->nlocal + atom->nghost;

  const int inum = list->inum;
  inum = list->inum;
  const int ignum = inum + list->gnum;
  NeighListKokkos<DeviceType>* k_list = static_cast<NeighListKokkos<DeviceType>*>(list);
  d_ilist = k_list->d_ilist;
@@ -121,6 +121,29 @@ void PairVashishtaKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
  EV_FLOAT ev;
  EV_FLOAT ev_all;

  int max_neighs = d_neighbors.dimension_1();

  if ((d_neighbors_short_2body.dimension_1() != max_neighs) ||
     (d_neighbors_short_2body.dimension_0() != ignum)) {
    d_neighbors_short_2body = Kokkos::View<int**,DeviceType>("Vashishta::neighbors_short_2body",ignum,max_neighs);
  }
  if (d_numneigh_short_2body.dimension_0()!=ignum) {
    d_numneigh_short_2body = Kokkos::View<int*,DeviceType>("Vashishta::numneighs_short_2body",ignum);
  }
  
  if ((d_neighbors_short_3body.dimension_1() != max_neighs) ||
     (d_neighbors_short_3body.dimension_0() != ignum)) {
    d_neighbors_short_3body = Kokkos::View<int**,DeviceType>("Vashishta::neighbors_short_3body",ignum,max_neighs);
  }

  if (d_numneigh_short_3body.dimension_0()!=ignum) {
    d_numneigh_short_3body = Kokkos::View<int*,DeviceType>("Vashishta::numneighs_short_3body",ignum);
  }

  Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType,TagPairVashishtaComputeShortNeigh>(0,neighflag==FULL?ignum:inum), *this);



  // loop over neighbor list of my atoms

  if (neighflag == HALF) {
@@ -174,6 +197,40 @@ void PairVashishtaKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
  copymode = 0;
}

template<class DeviceType>
KOKKOS_INLINE_FUNCTION
void PairVashishtaKokkos<DeviceType>::operator()(TagPairVashishtaComputeShortNeigh, const int& ii) const {
    const int i = d_ilist[ii];
    const X_FLOAT xtmp = x(i,0);
    const X_FLOAT ytmp = x(i,1);
    const X_FLOAT ztmp = x(i,2);

    const int jnum = d_numneigh[i];
    int inside_2body = 0;
    int inside_3body = 0;
    for (int jj = 0; jj < jnum; jj++) {
      int j = d_neighbors(i,jj);
      j &= NEIGHMASK;

      const X_FLOAT delx = xtmp - x(j,0);
      const X_FLOAT dely = ytmp - x(j,1);
      const X_FLOAT delz = ztmp - x(j,2);
      const F_FLOAT rsq = delx*delx + dely*dely + delz*delz;

      if (rsq < cutmax*cutmax) {
        d_neighbors_short_2body(i,inside_2body) = j;
        inside_2body++;
      }

      if (rsq < cutmax_3body*cutmax_3body) {
        d_neighbors_short_3body(i,inside_3body) = j;
        inside_3body++;
      }
    }
    d_numneigh_short_2body(i) = inside_2body;
    d_numneigh_short_3body(i) = inside_3body;
}

template<class DeviceType>
template<int NEIGHFLAG, int EVFLAG>
KOKKOS_INLINE_FUNCTION
+9 −1
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ struct TagPairVashishtaComputeFullA{};
template<int NEIGHFLAG, int EVFLAG>
struct TagPairVashishtaComputeFullB{};

struct TagPairVashishtaComputeShortNeigh{};

namespace LAMMPS_NS {

template<class DeviceType>
@@ -75,6 +77,9 @@ class PairVashishtaKokkos : public PairVashishta {
  KOKKOS_INLINE_FUNCTION
  void operator()(TagPairVashishtaComputeFullB<NEIGHFLAG,EVFLAG>, const int&) const;

  KOKKOS_INLINE_FUNCTION
  void operator()(TagPairVashishtaComputeShortNeigh, const int&) const;

  template<int NEIGHFLAG>
  KOKKOS_INLINE_FUNCTION
  void ev_tally(EV_FLOAT &ev, const int &i, const int &j,
@@ -136,7 +141,10 @@ class PairVashishtaKokkos : public PairVashishta {
  int nlocal,nall,eflag,vflag;

  int inum;

  Kokkos::View<int**,DeviceType> d_neighbors_short_2body;
  Kokkos::View<int*,DeviceType> d_numneigh_short_2body;
  Kokkos::View<int**,DeviceType> d_neighbors_short_3body;
  Kokkos::View<int*,DeviceType> d_numneigh_short_3body;
  friend void pair_virial_fdotr_compute<PairVashishtaKokkos>(PairVashishtaKokkos*);
};

+2 −1
Original line number Diff line number Diff line
@@ -532,11 +532,12 @@ void PairVashishta::setup_params()
  }

  // set cutmax to max of all params

  cutmax_3body = 0.0;
  cutmax = 0.0;
  for (m = 0; m < nparams; m++) {
    if (params[m].cut > cutmax) cutmax = params[m].cut;
    if (params[m].r0 > cutmax) cutmax = params[m].r0;
    if (params[m].r0 > cutmax_3body) cutmax_3body = params[m].r0;
  }
}

+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ class PairVashishta : public Pair {
  };
 protected:
  double cutmax;                // max cutoff for all elements
  double cutmax_3body;                // max cutoff for all elements
  int nelements;                // # of unique elements
  char **elements;              // names of unique elements
  int ***elem2param;            // mapping from element triplets to parameters