/* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator http://lammps.sandia.gov, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software. This software is distributed under the GNU General Public License. See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ #include "fix_freeze_kokkos.h" #include "atom_masks.h" #include "atom_kokkos.h" using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ template FixFreezeKokkos::FixFreezeKokkos(LAMMPS *lmp, int narg, char **arg) : FixFreeze(lmp, narg, arg) { kokkosable = 1; atomKK = (AtomKokkos *)atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = F_MASK | MASK_MASK; datamask_modify = F_MASK | TORQUE_MASK; } /* ---------------------------------------------------------------------- */ template int FixFreezeKokkos::setmask() { return FixFreeze::setmask(); } /* ---------------------------------------------------------------------- */ template void FixFreezeKokkos::init() { FixFreeze::init(); } /* ---------------------------------------------------------------------- */ template void FixFreezeKokkos::setup(int vflag) { FixFreeze::setup(vflag); } /* ---------------------------------------------------------------------- */ template void FixFreezeKokkos::post_force(int vflag) { atomKK->sync(execution_space,datamask_read); atomKK->modified(execution_space,datamask_modify); f = atomKK->k_f.view(); torque = atomKK->k_torque.view(); mask = atomKK->k_mask.view(); int nlocal = atom->nlocal; if (igroup == atom->firstgroup) nlocal = atom->nfirst; force_flag = 0; copymode = 1; OriginalForce original; Kokkos::parallel_reduce(nlocal, *this, original); copymode = 0; foriginal[0] = original.values[0]; foriginal[1] = original.values[1]; foriginal[2] = original.values[2]; } /* ---------------------------------------------------------------------- */ template void FixFreezeKokkos::post_force_respa(int vflag, int ilevel, int iloop) { post_force(vflag); } /* ---------------------------------------------------------------------- return components of total force on fix group before force was changed ------------------------------------------------------------------------- */ template double FixFreezeKokkos::compute_vector(int n) { return FixFreeze::compute_vector(n); } /* ---------------------------------------------------------------------- */ template void FixFreezeKokkos::operator()(const int i, OriginalForce &original) const { if (mask[i] & groupbit) { original.values[0] += f(i,0); original.values[1] += f(i,1); original.values[2] += f(i,2); f(i,0) = 0.0; f(i,1) = 0.0; f(i,2) = 0.0; torque(i,0) = 0.0; torque(i,1) = 0.0; torque(i,2) = 0.0; } } namespace LAMMPS_NS { template class FixFreezeKokkos; #ifdef KOKKOS_HAVE_CUDA template class FixFreezeKokkos; #endif }