diff --git a/src/KOKKOS/compute_local_comp_atom_kokkos.cpp b/src/KOKKOS/compute_local_comp_atom_kokkos.cpp index 7ee63eafea..5dbe436e29 100644 --- a/src/KOKKOS/compute_local_comp_atom_kokkos.cpp +++ b/src/KOKKOS/compute_local_comp_atom_kokkos.cpp @@ -83,10 +83,11 @@ void ComputeLocalCompAtomKokkos::compute_peratom() // grow result array if necessary + int size_peratom_cols = 1 + atom->ntypes; if (atom->nmax > nmax) { memoryKK->destroy_kokkos(k_result,result); nmax = atom->nmax; - memoryKK->create_kokkos(k_result,result,nmax,2,"local/comp/atom:result"); + memoryKK->create_kokkos(k_result,result,nmax,size_peratom_cols,"local/comp/atom:result"); d_result = k_result.view(); array_atom = result; } @@ -107,13 +108,12 @@ void ComputeLocalCompAtomKokkos::compute_peratom() atomKK->sync(execution_space,X_MASK|V_MASK|RMASS_MASK|TYPE_MASK|MASK_MASK); x = atomKK->k_x.view(); type = atomKK->k_type.view(); - ntypes = atomKK->k_ntypes.view(); mask = atomKK->k_mask.view(); Kokkos::deep_copy(d_result,0.0); copymode = 1; - typename Kokkos::RangePolicy policy(0,inum); + typename Kokkos::RangePolicy policy(0,inum); Kokkos::parallel_for("ComputeLocalComp",policy,*this); copymode = 0; @@ -123,15 +123,17 @@ void ComputeLocalCompAtomKokkos::compute_peratom() template KOKKOS_INLINE_FUNCTION -void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalComp, const int &ii) const +void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalCompAtom, const int &ii) const { double typeone_i, typeone_j; + int ntypes = atom->ntypes; int lcomp[ntypes]; // get per-atom local compositions - for (ii = 0; ii < inum; ii++) { + int inum = list->inum; + for (int ii = 0; ii < inum; ii++) { for (int i = 0; i < ntypes; i++) lcomp[i] = 0; @@ -148,13 +150,14 @@ void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalComp, con int count = 1; - itype = type[i]; + int itype = type[i]; + lcomp[itype-1]++; for (int jj = 0; jj < jnum; jj++) { int j = d_neighbors(i,jj); j &= NEIGHMASK; - jtype = type[j]; + int jtype = type[j]; const F_FLOAT delx = x(j,0) - xtmp; const F_FLOAT dely = x(j,1) - ytmp; @@ -162,12 +165,20 @@ void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalComp, con const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; if (rsq < cutsq) { count++; - lcomp[jtype]++; + lcomp[jtype-1]++; } } - for (int n = 0 n < 4; n++) { - d_result(i,n+1) = lcomp[n] / density; - } + + // total count of atoms found in sampled radius range + + d_result(i,0) = count; + + // local comp fractions per element + + double lfac = 1.0 / count; + for (int n = 0; n < ntypes; n++) + d_result(i,n+1) = lcomp[n] * lfac; + } } } diff --git a/src/KOKKOS/compute_local_comp_atom_kokkos.h b/src/KOKKOS/compute_local_comp_atom_kokkos.h index 5f9baa2af0..2f1c6ea3d4 100644 --- a/src/KOKKOS/compute_local_comp_atom_kokkos.h +++ b/src/KOKKOS/compute_local_comp_atom_kokkos.h @@ -48,7 +48,6 @@ template class ComputeLocalCompAtomKokkos : public ComputeLoc private: typename AT::t_x_array x; - typename AT::t_v_array v; typename ArrayTypes::t_int_1d type; typename ArrayTypes::t_int_1d mask;