Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MakeParticle SoA: Const Only #3281

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions Src/Particle/AMReX_MakeParticle.H
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
#ifndef AMREX_MAKEPARTICLE_H_
#define AMREX_MAKEPARTICLE_H_

#include "AMReX_ParticleTile.H"

#include <type_traits>

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

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>
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_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)
{
// SoAParticle
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