Commit 7fb4faa4 authored by Dan Ibanez's avatar Dan Ibanez
Browse files

draft CUDA-callable version of Domain::unmap

parent 41c9357d
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#include "domain.h"
#include "kokkos_type.h"
#include "kokkos_few.h"

namespace LAMMPS_NS {

@@ -54,6 +55,10 @@ class DomainKokkos : public Domain {
  KOKKOS_INLINE_FUNCTION
  void operator()(TagDomain_x2lamda, const int&) const;

  static KOKKOS_INLINE_FUNCTION
  Few<double,3> unmap(Few<double,3> prd, Few<double,6> h, int triclinic,
      Few<double,3> x, imageint image);

 private:
  double lo[3],hi[3],period[3];
  int n_flip, m_flip, p_flip;
@@ -61,6 +66,26 @@ class DomainKokkos : public Domain {
  ArrayTypes<LMPDeviceType>::t_imageint_1d image;
};

KOKKOS_INLINE_FUNCTION
Few<double,3> DomainKokkos::unmap(Few<double,3> prd, Few<double,6> h,
    int triclinic, Few<double,3> x, imageint image)
{
  int xbox = (image & IMGMASK) - IMGMAX;
  int ybox = (image >> IMGBITS & IMGMASK) - IMGMAX;
  int zbox = (image >> IMG2BITS) - IMGMAX;
  Few<double,3> y;
  if (triclinic == 0) {
    y[0] = x[0] + xbox*prd[0];
    y[1] = x[1] + ybox*prd[1];
    y[2] = x[2] + zbox*prd[2];
  } else {
    y[0] = x[0] + h[0]*xbox + h[5]*ybox + h[4]*zbox;
    y[1] = x[1] + h[1]*ybox + h[3]*zbox;
    y[2] = x[2] + h[2]*zbox;
  }
  return y;
}

}

#endif