From 18c77db8c3989d8308d967a5c08bc5b69b51c374 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Thu, 7 May 2020 15:16:17 -0600 Subject: [PATCH] Add Kokkos vel methods --- src/KOKKOS/atom_vec_kokkos.cpp | 47 ++++++++++++++++++++++++++++++++++ src/KOKKOS/atom_vec_kokkos.h | 3 +++ src/atom_vec.cpp | 3 --- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/KOKKOS/atom_vec_kokkos.cpp b/src/KOKKOS/atom_vec_kokkos.cpp index 7d5df17544..c8fe6373b5 100644 --- a/src/KOKKOS/atom_vec_kokkos.cpp +++ b/src/KOKKOS/atom_vec_kokkos.cpp @@ -16,6 +16,7 @@ #include "comm_kokkos.h" #include "domain.h" #include "atom_masks.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -992,3 +993,49 @@ void AtomVecKokkos::unpack_reverse(int n, int *list, double *buf) if(n > 0) modified(Host,F_MASK); } + +/* ---------------------------------------------------------------------- + * unpack one line from Velocities section of data file + * ------------------------------------------------------------------------- */ + +void AtomVecKokkos::data_vel(int m, char **values) +{ + double **v = atom->v; + v[m][0] = utils::numeric(FLERR,values[0],true,lmp); + v[m][1] = utils::numeric(FLERR,values[1],true,lmp); + v[m][2] = utils::numeric(FLERR,values[2],true,lmp); + + modified(Host,V_MASK); +} + +/* ---------------------------------------------------------------------- + * pack velocity info for data file + * ------------------------------------------------------------------------- */ + +void AtomVecKokkos::pack_vel(double **buf) +{ + double **v = atom->v; + tagint *tag = atom->tag; + int nlocal = atom->nlocal; + + sync(Host,V_MASK|TAG_MASK); + + for (int i = 0; i < nlocal; i++) { + buf[i][0] = ubuf(tag[i]).d; + buf[i][1] = v[i][0]; + buf[i][2] = v[i][1]; + buf[i][3] = v[i][2]; + } +} + +/* ---------------------------------------------------------------------- + * write velocity info to data file + * ------------------------------------------------------------------------- */ + +void AtomVecKokkos::write_vel(FILE *fp, int n, double **buf) +{ + for (int i = 0; i < n; i++) + fprintf(fp,TAGINT_FORMAT " %-1.16e %-1.16e %-1.16e\n", + (tagint) ubuf(buf[i][0]).i,buf[i][1],buf[i][2],buf[i][3]); +} + diff --git a/src/KOKKOS/atom_vec_kokkos.h b/src/KOKKOS/atom_vec_kokkos.h index 2111e73208..b93fb42e75 100644 --- a/src/KOKKOS/atom_vec_kokkos.h +++ b/src/KOKKOS/atom_vec_kokkos.h @@ -41,6 +41,9 @@ class AtomVecKokkos : public AtomVec { virtual void unpack_comm_vel(int, int, double *); virtual int pack_reverse(int, int, double *); virtual void unpack_reverse(int, int *, double *); + virtual void data_vel(int, char **); + virtual void pack_vel(double **); + virtual void write_vel(FILE *, int, double **); virtual void sync(ExecutionSpace space, unsigned int mask) = 0; virtual void modified(ExecutionSpace space, unsigned int mask) = 0; diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 6baeaeacc3..194cf246ce 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -55,9 +55,6 @@ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp) threads = NULL; nthreads = comm->nthreads; - ngrow = ncopy = ncomm = ncomm_vel = nreverse = nborder = nborder_vel = 0; - nexchange = nrestart = ncreate = ndata_atom = ndata_vel = 0; - // peratom variables auto-included in corresponding child style fields string // these fields cannot be specified in the fields string