aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/Sorting/SortingUtils.H
diff options
context:
space:
mode:
authorGravatar Remi Lehe <remi.lehe@normalesup.org> 2019-09-25 13:12:23 -0700
committerGravatar Remi Lehe <remi.lehe@normalesup.org> 2019-10-01 16:32:38 -0700
commit69b512e9fb315bd987314ec71ff463c6a90afde0 (patch)
tree7522b6b19f2de59d95c07e28af62876459d5af24 /Source/Particles/Sorting/SortingUtils.H
parentfeac8d56e5cc84f63f6e7be7e1668113558c9e47 (diff)
downloadWarpX-69b512e9fb315bd987314ec71ff463c6a90afde0.tar.gz
WarpX-69b512e9fb315bd987314ec71ff463c6a90afde0.tar.zst
WarpX-69b512e9fb315bd987314ec71ff463c6a90afde0.zip
Replaced Index function
Diffstat (limited to 'Source/Particles/Sorting/SortingUtils.H')
-rw-r--r--Source/Particles/Sorting/SortingUtils.H22
1 files changed, 22 insertions, 0 deletions
diff --git a/Source/Particles/Sorting/SortingUtils.H b/Source/Particles/Sorting/SortingUtils.H
index d072ebd2a..7dec21446 100644
--- a/Source/Particles/Sorting/SortingUtils.H
+++ b/Source/Particles/Sorting/SortingUtils.H
@@ -15,4 +15,26 @@ void fillWithConsecutiveIntegers( amrex::Gpu::ManagedDeviceVector<long>& v ) {
#endif
}
+// TODO: Add documentation
+template< typename PType >
+AMREX_GPU_HOST_DEVICE AMREX_INLINE
+amrex::IntVect findParticleIndex ( PType p,
+ const amrex::Real prob_lo_x,
+ const amrex::Real prob_lo_y,
+ const amrex::Real prob_lo_z,
+ const amrex::Real inv_dx,
+ const amrex::Real inv_dy,
+ const amrex::Real inv_dz,
+ const amrex::IntVect domain_small_end )
+{
+ amrex::IntVect iv;
+ AMREX_D_TERM(iv[0]=static_cast<int>(floor((p.m_rdata.pos[0]-prob_lo_x)*inv_dx));,
+ iv[1]=static_cast<int>(floor((p.m_rdata.pos[1]-prob_lo_y)*inv_dy));,
+ iv[2]=static_cast<int>(floor((p.m_rdata.pos[2]-prob_lo_z)*inv_dz)););
+
+ iv += domain_small_end;
+
+ return iv;
+};
+
#endif // WARPX_PARTICLES_SORTING_SORTINGUTILS_H_