1 /* -*- c++ -*- ----------------------------------------------------------
2    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
3    https://www.lammps.org/, Sandia National Laboratories
4    Steve Plimpton, sjplimp@sandia.gov
5 
6    Copyright (2003) Sandia Corporation.  Under the terms of Contract
7    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
8    certain rights in this software.  This software is distributed under
9    the GNU General Public License.
10 
11    See the README file in the top-level LAMMPS directory.
12 ------------------------------------------------------------------------- */
13 
14 #ifdef PAIR_CLASS
15 // clang-format off
16 PairStyle(vashishta/kk,PairVashishtaKokkos<LMPDeviceType>);
17 PairStyle(vashishta/kk/device,PairVashishtaKokkos<LMPDeviceType>);
18 PairStyle(vashishta/kk/host,PairVashishtaKokkos<LMPHostType>);
19 // clang-format on
20 #else
21 
22 // clang-format off
23 #ifndef LMP_PAIR_VASHISHTA_KOKKOS_H
24 #define LMP_PAIR_VASHISHTA_KOKKOS_H
25 
26 #include "pair_vashishta.h"
27 #include "pair_kokkos.h"
28 
29 template<int NEIGHFLAG, int EVFLAG>
30 struct TagPairVashishtaComputeHalf{};
31 
32 template<int NEIGHFLAG, int EVFLAG>
33 struct TagPairVashishtaComputeFullA{};
34 
35 template<int NEIGHFLAG, int EVFLAG>
36 struct TagPairVashishtaComputeFullB{};
37 
38 struct TagPairVashishtaComputeShortNeigh{};
39 
40 namespace LAMMPS_NS {
41 
42 template<class DeviceType>
43 class PairVashishtaKokkos : public PairVashishta {
44  public:
45   enum {EnabledNeighFlags=FULL};
46   enum {COUL_FLAG=0};
47   typedef DeviceType device_type;
48   typedef ArrayTypes<DeviceType> AT;
49   typedef EV_FLOAT value_type;
50 
51   PairVashishtaKokkos(class LAMMPS *);
52   virtual ~PairVashishtaKokkos();
53   virtual void compute(int, int);
54   virtual void coeff(int, char **);
55   virtual void init_style();
56 
57   template<int NEIGHFLAG, int EVFLAG>
58   KOKKOS_INLINE_FUNCTION
59   void operator()(TagPairVashishtaComputeHalf<NEIGHFLAG,EVFLAG>, const int&, EV_FLOAT&) const;
60 
61   template<int NEIGHFLAG, int EVFLAG>
62   KOKKOS_INLINE_FUNCTION
63   void operator()(TagPairVashishtaComputeHalf<NEIGHFLAG,EVFLAG>, const int&) const;
64 
65   template<int NEIGHFLAG, int EVFLAG>
66   KOKKOS_INLINE_FUNCTION
67   void operator()(TagPairVashishtaComputeFullA<NEIGHFLAG,EVFLAG>, const int&, EV_FLOAT&) const;
68 
69   template<int NEIGHFLAG, int EVFLAG>
70   KOKKOS_INLINE_FUNCTION
71   void operator()(TagPairVashishtaComputeFullA<NEIGHFLAG,EVFLAG>, const int&) const;
72 
73   template<int NEIGHFLAG, int EVFLAG>
74   KOKKOS_INLINE_FUNCTION
75   void operator()(TagPairVashishtaComputeFullB<NEIGHFLAG,EVFLAG>, const int&, EV_FLOAT&) const;
76 
77   template<int NEIGHFLAG, int EVFLAG>
78   KOKKOS_INLINE_FUNCTION
79   void operator()(TagPairVashishtaComputeFullB<NEIGHFLAG,EVFLAG>, const int&) const;
80 
81   KOKKOS_INLINE_FUNCTION
82   void operator()(TagPairVashishtaComputeShortNeigh, const int&) const;
83 
84   template<int NEIGHFLAG>
85   KOKKOS_INLINE_FUNCTION
86   void ev_tally(EV_FLOAT &ev, const int &i, const int &j,
87       const F_FLOAT &epair, const F_FLOAT &fpair, const F_FLOAT &delx,
88                   const F_FLOAT &dely, const F_FLOAT &delz) const;
89 
90   template<int NEIGHFLAG>
91   KOKKOS_INLINE_FUNCTION
92   void ev_tally3(EV_FLOAT &ev, const int &i, const int &j, int &k,
93             const F_FLOAT &evdwl, const F_FLOAT &ecoul,
94                        F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drji, F_FLOAT *drki) const;
95 
96   KOKKOS_INLINE_FUNCTION
97   void ev_tally3_atom(EV_FLOAT &ev, const int &i,
98             const F_FLOAT &evdwl, const F_FLOAT &ecoul,
99                        F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drji, F_FLOAT *drki) const;
100 
101  protected:
102   typedef Kokkos::DualView<int***,DeviceType> tdual_int_3d;
103   typedef typename tdual_int_3d::t_dev_const_randomread t_int_3d_randomread;
104   typedef typename tdual_int_3d::t_host t_host_int_3d;
105 
106   t_int_3d_randomread d_elem3param;
107   typename AT::t_int_1d_randomread d_map;
108 
109   typedef Kokkos::DualView<Param*,DeviceType> tdual_param_1d;
110   typedef typename tdual_param_1d::t_dev t_param_1d;
111   typedef typename tdual_param_1d::t_host t_host_param_1d;
112 
113   t_param_1d d_params;
114 
115   virtual void setup_params();
116 
117   KOKKOS_INLINE_FUNCTION
118   void twobody(const Param&, const F_FLOAT&, F_FLOAT&, const int&, F_FLOAT&) const;
119 
120   KOKKOS_INLINE_FUNCTION
121   void threebody(const Param&, const Param&, const Param&, const F_FLOAT&, const F_FLOAT&, F_FLOAT *, F_FLOAT *,
122                  F_FLOAT *, F_FLOAT *, const int&, F_FLOAT&) const;
123 
124   KOKKOS_INLINE_FUNCTION
125   void threebodyj(const Param&, const Param&, const Param&, const F_FLOAT&, const F_FLOAT&, F_FLOAT *, F_FLOAT *,
126                  F_FLOAT *) const;
127 
128   typename AT::t_x_array_randomread x;
129   typename AT::t_f_array f;
130   typename AT::t_tagint_1d tag;
131   typename AT::t_int_1d_randomread type;
132 
133   DAT::tdual_efloat_1d k_eatom;
134   DAT::tdual_virial_array k_vatom;
135   typename ArrayTypes<DeviceType>::t_efloat_1d d_eatom;
136   typename ArrayTypes<DeviceType>::t_virial_array d_vatom;
137 
138   typename AT::t_int_1d_randomread d_type2frho;
139   typename AT::t_int_2d_randomread d_type2rhor;
140   typename AT::t_int_2d_randomread d_type2z2r;
141 
142   typename AT::t_neighbors_2d d_neighbors;
143   typename AT::t_int_1d_randomread d_ilist;
144   typename AT::t_int_1d_randomread d_numneigh;
145   //NeighListKokkos<DeviceType> k_list;
146 
147   int neighflag,newton_pair;
148   int nlocal,nall,eflag,vflag;
149 
150   int inum;
151   Kokkos::View<int**,DeviceType> d_neighbors_short_2body;
152   Kokkos::View<int*,DeviceType> d_numneigh_short_2body;
153   Kokkos::View<int**,DeviceType> d_neighbors_short_3body;
154   Kokkos::View<int*,DeviceType> d_numneigh_short_3body;
155   friend void pair_virial_fdotr_compute<PairVashishtaKokkos>(PairVashishtaKokkos*);
156 };
157 
158 }
159 
160 #endif
161 #endif
162 
163 /* ERROR/WARNING messages:
164 
165 E: Cannot use chosen neighbor list style with pair vashishta/kk
166 
167 Self-explanatory.
168 
169 */
170