Skip to content

Commit

Permalink
One More Attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
ax3l committed Apr 27, 2023
1 parent 5ea9392 commit 843122b
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions Src/Particle/AMReX_MakeParticle.H
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
#ifndef AMREX_MAKEPARTICLE_H_
#define AMREX_MAKEPARTICLE_H_

#include "AMReX_ParticleTile.H"

#include <type_traits>

template< class T >
struct is_const_soa_particle
: std::integral_constant<
bool,
T::is_soa_particle && T::is_constsoa_particle
> {};

template <typename T_ParticleType, class Enable = void>
struct make_particle
{
template <typename PTD>

namespace amrex {

template<class T>
struct is_soa_particle
: std::integral_constant<
bool,
T::is_soa_particle
> {
};

template<typename T_ParticleType, class Enable = void>
struct make_particle {
template<typename PTD>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
auto&
operator() (PTD const& ptd, int i)
{
auto &
operator()(PTD const &ptd, int i) {
// legacy Particle (AoS)
return ptd.m_aos[i];
}
};

template <typename T_ParticleType>
struct make_particle<T_ParticleType, typename std::enable_if<is_const_soa_particle<T_ParticleType>::value>::type>
{
template <typename PTD>
template<typename T_ParticleType>
struct make_particle<T_ParticleType, typename std::enable_if<is_soa_particle<T_ParticleType>::value>::type> {
template<typename PTD>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
auto
operator() (PTD const& ptd, int index)
{
// ConstSoAParticle
return T_ParticleType(ptd, index);
operator()(PTD const &ptd, int index) {
// pure SoA particle (by value)
return ConstSoAParticle<T_ParticleType::NArrayReal, T_ParticleType::NArrayInt>(ptd, index);
}
};

} // namespace amrex

#endif

0 comments on commit 843122b

Please sign in to comment.