Get< PArrs > Struct Template Reference

SPADES API: spades::particles::Get< PArrs > Struct Template Reference
SPADES API
spades::particles::Get< PArrs > Struct Template Reference

Functor for accessing a particle in a cell. More...

#include <ParticleOps.H>

Public Member Functions

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.
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE int operator() (const int n, const int typ) const
 Get a particle in a cell.
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE bool check (const int n, const int typ) const
 Check validity of the particle type.
 
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.
 

Public Attributes

const amrex::IntVect & m_iv
 Cell index.
 
const amrex::Array4< const int > & m_counts
 Cell counts of particle types.
 
const amrex::Array4< const int > & m_offsets
 Cell offsets of particle types.
 
PArrs & m_parrs
 Particle array.
 

Detailed Description

template<class PArrs>
struct spades::particles::Get< PArrs >

Functor for accessing a particle in a cell.

Constructor & Destructor Documentation

◆ Get()

template<class PArrs >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE spades::particles::Get< PArrs >::Get ( const amrex::IntVect & iv,
const amrex::Array4< const int > & counts,
const amrex::Array4< const int > & offsets,
PArrs & parrs )
inline

Constructor.

Parameters
iv[in] cell index of the particle
counts[in] cell counts of particle types
offsets[in] cell offsets of particle types
parrs[in] particle arrays
129 : m_iv(iv), m_counts(counts), m_offsets(offsets), m_parrs(parrs)
130 {}
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
const amrex::Array4< const int > & m_counts
Cell counts of particle types.
Definition ParticleOps.H:194

Member Function Documentation

◆ assert_different()

template<class PArrs >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void spades::particles::Get< PArrs >::assert_different ( const int n,
const int typ,
const int expected_type ) const
inline

Assert that the particle is of a different but expected type.

A particle sometimes changes type (e.g., marked as undefined) but the counts and offsets haven't been updated yet. This asserts that the requested particle of a certain type typ changed to another type expected_type.

Parameters
n[in] nth particle to return
typ[in] particle type that is requested
expected_type[in] expected particle type
180 {
181#ifdef AMREX_DEBUG
182 const int idx = m_offsets(m_iv, typ) + n;
183 AMREX_ASSERT(
184 m_parrs.m_idata[CommonIntData::type_id][idx] == expected_type);
185#else
186 amrex::ignore_unused(n, typ, expected_type);
187#endif
188 }
@ type_id
Definition ParticleData.H:18

◆ check()

template<class PArrs >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE bool spades::particles::Get< PArrs >::check ( const int n,
const int typ ) const
inline

Check validity of the particle type.

Parameters
n[in] nth particle to return
typ[in] particle type that is requested
Returns
boolean if the particle is of the requested type
159 {
160 AMREX_ASSERT(m_counts(m_iv, typ) > n);
161 const int idx = m_offsets(m_iv, typ) + n;
162 return m_parrs.m_idata[CommonIntData::type_id][idx] == typ;
163 }

◆ operator()()

template<class PArrs >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE int spades::particles::Get< PArrs >::operator() ( const int n,
const int typ ) const
inline

Get a particle in a cell.

Parameters
n[in] nth particle to return
typ[in] particle type that is requested
Returns
particle index of type typ and at position n
140 {
141
142 AMREX_ASSERT(m_counts(m_iv, typ) > n);
143 const int idx = m_offsets(m_iv, typ) + n;
144
145 AMREX_ASSERT(m_parrs.m_aos[idx].id() >= 0);
146 AMREX_ASSERT(m_parrs.m_idata[CommonIntData::type_id][idx] == typ);
147
148 return idx;
149 }

Member Data Documentation

◆ m_counts

template<class PArrs >
const amrex::Array4<const int>& spades::particles::Get< PArrs >::m_counts

Cell counts of particle types.

◆ m_iv

template<class PArrs >
const amrex::IntVect& spades::particles::Get< PArrs >::m_iv

Cell index.

◆ m_offsets

template<class PArrs >
const amrex::Array4<const int>& spades::particles::Get< PArrs >::m_offsets

Cell offsets of particle types.

◆ m_parrs

template<class PArrs >
PArrs& spades::particles::Get< PArrs >::m_parrs

Particle array.


The documentation for this struct was generated from the following file: