5#include <AMReX_Array4.H>
6#include <AMReX_Print.H>
12template <
size_t NRealT,
size_t NIntT,
class P,
class RT,
class IT>
15 static constexpr size_t NREAL = NRealT;
16 static constexpr size_t NINT = NIntT;
25 P* aos, std::array<RT, NRealT>& rdata, std::array<IT, NIntT>& idata)
28 for (
size_t i = 0; i < NRealT; i++) {
31 for (
size_t i = 0; i < NIntT; i++) {
40 amrex::GpuArray<amrex::Real*, NRealT>
m_rdata;
54 template <
class PArrs>
57 auto& p = parrs.m_aos[n];
58 amrex::Print() <<
"Particle data: \n"
59 <<
" id = " << p.id() <<
"\n"
60 <<
" cpu = " << p.cpu() <<
"\n"
63 for (
size_t i = 0; i < PArrs::NINT; i++) {
64 amrex::Print() <<
" int comp(" << i
65 <<
") = " << parrs.m_idata[i][n] <<
"\n";
67 for (
size_t i = 0; i < PArrs::NREAL; i++) {
68 amrex::Print() <<
" real comp(" << i
69 <<
") = " << parrs.m_rdata[i][n] <<
"\n";
82 template <
class PArrs>
83 AMREX_GPU_DEVICE
void operator()(
const amrex::Long n, PArrs& parrs)
const
85 auto& p = parrs.m_aos[n];
87 "Particle data: id = %ld, cpu = %ld, type = %d, timestamp = %.8e\n",
88 static_cast<amrex::Long
>(p.id()),
static_cast<amrex::Long
>(p.cpu()),
103 template <
class PArrs>
104 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
void
105 operator()(
const amrex::Long p1,
const amrex::Long p2, PArrs& parrs)
const
107 for (
size_t i = 0; i < PArrs::NREAL; i++) {
108 parrs.m_rdata[i][p2] = parrs.m_rdata[i][p1];
110 for (
size_t i = 0; i < PArrs::NINT; i++) {
111 parrs.m_idata[i][p2] = parrs.m_idata[i][p1];
117template <
class PArrs>
127 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
128 Get(
const amrex::IntVect& iv,
129 const amrex::Array4<const int>& counts,
130 const amrex::Array4<const int>& offsets,
141 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
int
148 AMREX_ASSERT(
m_parrs.m_aos[idx].id() >= 0);
160 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
bool
161 check(
const int n,
const int typ)
const
181 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
void
189 amrex::ignore_unused(n, typ, expected_type);
214 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
bool
236 template <
class PArrs>
237 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
bool
238 operator()(
const amrex::Long p1,
const amrex::Long p2, PArrs& parrs)
const
241 const amrex::IntVect piv1(AMREX_D_DECL(
242 parrs.m_idata[CommonIntData::i][p1],
243 parrs.m_idata[CommonIntData::j][p1],
244 parrs.m_idata[CommonIntData::k][p1]));
245 const amrex::IntVect piv2(AMREX_D_DECL(
246 parrs.m_idata[CommonIntData::i][p2],
247 parrs.m_idata[CommonIntData::j][p2],
248 parrs.m_idata[CommonIntData::k][p2]));
254 return (piv1 < piv2) ||
255 (piv1 == piv2 && ((m1 < m2) || (m1 == m2 && t1 < t2)));
SPADES particles.
Definition EntityData.H:7
Functor for pairing particles.
Definition ParticleOps.H:208
AMREX_GPU_DEVICE AMREX_FORCE_INLINE bool operator()(const P &, const P &) const
Compare particles for pairing.
Definition ParticleOps.H:215
@ type_id
Definition ParticleData.H:18
@ timestamp
Definition ParticleData.H:12
Functor for comparing particles.
Definition ParticleOps.H:228
AMREX_GPU_DEVICE AMREX_FORCE_INLINE bool operator()(const amrex::Long p1, const amrex::Long p2, PArrs &parrs) const
Compare particles.
Definition ParticleOps.H:238
Functor for copying a particle's data to another.
Definition ParticleOps.H:96
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void operator()(const amrex::Long p1, const amrex::Long p2, PArrs &parrs) const
Copy particle data.
Definition ParticleOps.H:105
Functor for printing particle data on device.
Definition ParticleOps.H:76
AMREX_GPU_DEVICE void operator()(const amrex::Long n, PArrs &parrs) const
Print particle data to screen.
Definition ParticleOps.H:83
Functor for accessing a particle in a cell.
Definition ParticleOps.H:119
const amrex::Array4< const int > & m_offsets
Cell offsets of particle types.
Definition ParticleOps.H:200
PArrs & m_parrs
Particle array.
Definition ParticleOps.H:203
const amrex::IntVect & m_iv
Cell index.
Definition ParticleOps.H:194
AMREX_GPU_DEVICE AMREX_FORCE_INLINE Get(const amrex::IntVect &iv, const amrex::Array4< const int > &counts, const amrex::Array4< const int > &offsets, PArrs &parrs)
Constructor.
Definition ParticleOps.H:128
AMREX_GPU_DEVICE AMREX_FORCE_INLINE int operator()(const int n, const int typ) const
Get a particle in a cell.
Definition ParticleOps.H:142
AMREX_GPU_DEVICE AMREX_FORCE_INLINE bool check(const int n, const int typ) const
Check validity of the particle type.
Definition ParticleOps.H:161
const amrex::Array4< const int > & m_counts
Cell counts of particle types.
Definition ParticleOps.H:197
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void assert_different(const int n, const int typ, const int expected_type) const
Assert that the particle is of a different but expected type.
Definition ParticleOps.H:182
Particle operations.
Definition ParticleOps.H:14
amrex::GpuArray< amrex::Real *, NRealT > m_rdata
Pointers to real data.
Definition ParticleOps.H:40
ParticleArrays(P *aos, std::array< RT, NRealT > &rdata, std::array< IT, NIntT > &idata)
Constructor.
Definition ParticleOps.H:24
static constexpr size_t NREAL
Definition ParticleOps.H:15
P * m_aos
AOS data.
Definition ParticleOps.H:37
static constexpr size_t NINT
Definition ParticleOps.H:16
amrex::GpuArray< int *, NIntT > m_idata
Pointers to int data.
Definition ParticleOps.H:43
Functor for printing particle data on host.
Definition ParticleOps.H:48
void operator()(const amrex::Long n, PArrs &parrs) const
Print particle data to screen.
Definition ParticleOps.H:55