5#include <AMReX_Array4.H>
6#include <AMReX_Print.H>
12template <
size_t NReal,
size_t NInt,
class P,
class RT,
class IT>
22 P* aos, std::array<RT, NReal>& rdata, std::array<IT, NInt>& idata)
25 for (
size_t i = 0; i < NReal; i++) {
28 for (
size_t i = 0; i < NInt; i++) {
37 amrex::GpuArray<amrex::Real*, NReal>
m_rdata;
51 template <
class PArrs>
54 auto& p = parrs.m_aos[n];
55 amrex::Print() <<
"Particle data: \n"
56 <<
" id = " << p.id() <<
"\n"
57 <<
" cpu = " << p.cpu() <<
"\n"
60 for (
int i = 0; i < p.NInt; i++) {
61 amrex::Print() <<
" int comp(" << i
62 <<
") = " << parrs.m_idata[i][n] <<
"\n";
64 for (
int i = 0; i < p.NReal; i++) {
65 amrex::Print() <<
" real comp(" << i
66 <<
") = " << parrs.m_rdata[i][n] <<
"\n";
79 template <
class PArrs>
80 AMREX_GPU_DEVICE
void operator()(
const amrex::Long n, PArrs& parrs)
const
82 auto& p = parrs.m_aos[n];
84 "Particle data: id = %ld, cpu = %ld, type = %d, timestamp = %.8e\n",
85 static_cast<amrex::Long
>(p.id()),
static_cast<amrex::Long
>(p.cpu()),
100 template <
class PArrs>
101 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
void
102 operator()(
const amrex::Long p1,
const amrex::Long p2, PArrs& parrs)
const
104 for (
int i = 0; i < PArrs::NReal; i++) {
105 parrs.m_rdata[i][p2] = parrs.m_rdata[i][p1];
107 for (
int i = 0; i < PArrs::NInt; i++) {
108 parrs.m_idata[i][p2] = parrs.m_idata[i][p1];
114template <
class PArrs>
124 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
125 Get(
const amrex::IntVect& iv,
126 const amrex::Array4<const int>& counts,
127 const amrex::Array4<const int>& offsets,
138 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
int
145 AMREX_ASSERT(
m_parrs.m_aos[idx].id() >= 0);
157 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
bool
158 check(
const int n,
const int typ)
const
178 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
void
186 amrex::ignore_unused(n, typ, expected_type);
211 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
bool
233 template <
class PArrs>
234 AMREX_GPU_DEVICE AMREX_FORCE_INLINE
bool
235 operator()(
const amrex::Long p1,
const amrex::Long p2, PArrs& parrs)
const
238 const amrex::IntVect piv1(AMREX_D_DECL(
239 parrs.m_idata[CommonIntData::i][p1],
240 parrs.m_idata[CommonIntData::j][p1],
241 parrs.m_idata[CommonIntData::k][p1]));
242 const amrex::IntVect piv2(AMREX_D_DECL(
243 parrs.m_idata[CommonIntData::i][p2],
244 parrs.m_idata[CommonIntData::j][p2],
245 parrs.m_idata[CommonIntData::k][p2]));
251 return (piv1 < piv2) ||
252 (piv1 == piv2 && ((m1 < m2) || (m1 == m2 && t1 < t2)));
SPADES particles.
Definition EntityData.H:7
Functor for pairing particles.
Definition ParticleOps.H:205
AMREX_GPU_DEVICE AMREX_FORCE_INLINE bool operator()(const P &, const P &) const
Compare particles for pairing.
Definition ParticleOps.H:212
@ type_id
Definition ParticleData.H:18
@ timestamp
Definition ParticleData.H:12
Functor for comparing particles.
Definition ParticleOps.H:225
AMREX_GPU_DEVICE AMREX_FORCE_INLINE bool operator()(const amrex::Long p1, const amrex::Long p2, PArrs &parrs) const
Compare particles.
Definition ParticleOps.H:235
Functor for copying a particle's data to another.
Definition ParticleOps.H:93
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:102
Functor for printing particle data on device.
Definition ParticleOps.H:73
AMREX_GPU_DEVICE void operator()(const amrex::Long n, PArrs &parrs) const
Print particle data to screen.
Definition ParticleOps.H:80
Functor for accessing a particle in a cell.
Definition ParticleOps.H:116
const amrex::Array4< const int > & m_offsets
Cell offsets of particle types.
Definition ParticleOps.H:197
PArrs & m_parrs
Particle array.
Definition ParticleOps.H:200
const amrex::IntVect & m_iv
Cell index.
Definition ParticleOps.H:191
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:125
AMREX_GPU_DEVICE AMREX_FORCE_INLINE int operator()(const int n, const int typ) const
Get a particle in a cell.
Definition ParticleOps.H:139
AMREX_GPU_DEVICE AMREX_FORCE_INLINE bool check(const int n, const int typ) const
Check validity of the particle type.
Definition ParticleOps.H:158
const amrex::Array4< const int > & m_counts
Cell counts of particle types.
Definition ParticleOps.H:194
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:179
Particle operations.
Definition ParticleOps.H:14
P * m_aos
AOS data.
Definition ParticleOps.H:34
ParticleArrays(P *aos, std::array< RT, NReal > &rdata, std::array< IT, NInt > &idata)
Constructor.
Definition ParticleOps.H:21
amrex::GpuArray< amrex::Real *, NReal > m_rdata
Pointers to real data.
Definition ParticleOps.H:37
amrex::GpuArray< int *, NInt > m_idata
Pointers to int data.
Definition ParticleOps.H:40
Functor for printing particle data on host.
Definition ParticleOps.H:45
void operator()(const amrex::Long n, PArrs &parrs) const
Print particle data to screen.
Definition ParticleOps.H:52