Skip to content

Commit

Permalink
Follow-on to 3499 (AMReX-Codes#3514)
Browse files Browse the repository at this point in the history
A few more places needed to be generalized for terrain-fitted particles
in ERF.

The proposed changes:
- [ ] fix a bug or incorrect behavior in AMReX
- [ ] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [ ] are likely to significantly affect the results of downstream AMReX
users
- [ ] include documentation in the code and/or rst files, if appropriate
  • Loading branch information
atmyers authored Aug 25, 2023
1 parent de86b7d commit bad61ac
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 37 deletions.
59 changes: 29 additions & 30 deletions Src/Particle/AMReX_ParIter.H
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ template <int T_NStructReal, int T_NStructInt=0, int T_NArrayReal=0, int T_NArra
using ParticleContainer = ParticleContainer_impl<Particle<T_NStructReal, T_NStructInt>, T_NArrayReal, T_NArrayInt, Allocator, CellAssignor>;

template <bool is_const, typename T_ParticleType, int NArrayReal=0, int NArrayInt=0,
template<class> class Allocator=DefaultAllocator>

template<class> class Allocator=DefaultAllocator, class CellAssignor=DefaultAssignor>
class ParIterBase_impl
: public MFIter
{

private:

using PCType = ParticleContainer_impl<T_ParticleType, NArrayReal, NArrayInt, Allocator,DefaultAssignor>;
using PCType = ParticleContainer_impl<T_ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>;
using ContainerRef = typename std::conditional<is_const, PCType const&, PCType&>::type;
using ParticleTileRef = typename std::conditional
<is_const, typename PCType::ParticleTileType const&, typename PCType::ParticleTileType &>::type;
Expand All @@ -47,7 +46,7 @@ private:

public:

using ContainerType = ParticleContainer_impl<T_ParticleType, NArrayReal, NArrayInt, Allocator, DefaultAssignor>;
using ContainerType = ParticleContainer_impl<T_ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>;
using ParticleTileType = typename ContainerType::ParticleTileType;
using AoS = typename ContainerType::AoS;
using SoA = typename ContainerType::SoA;
Expand Down Expand Up @@ -112,17 +111,17 @@ protected:
};

template <typename T_ParticleType, int NArrayReal=0, int NArrayInt=0,
template<class> class Allocator=DefaultAllocator>
template<class> class Allocator=DefaultAllocator, class CellAssignor=DefaultAssignor>
class ParIter_impl
: public ParIterBase_impl<false, T_ParticleType, NArrayReal, NArrayInt, Allocator>
: public ParIterBase_impl<false, T_ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>
{
public:

using ParticleType=T_ParticleType;
static constexpr int NStructReal = ParticleType::NReal;
static constexpr int NStructInt = ParticleType::NInt;

using ContainerType = ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, DefaultAssignor>;
using ContainerType = ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>;
using ConstParticleType = typename ContainerType::ConstParticleType;
using ParticleTileType = typename ContainerType::ParticleTileType;
using AoS = typename ContainerType::AoS;
Expand All @@ -131,41 +130,41 @@ public:
using IntVector = typename SoA::IntVector;

ParIter_impl (ContainerType& pc, int level)
: ParIterBase_impl<false, T_ParticleType, NArrayReal, NArrayInt, Allocator>(pc,level)
: ParIterBase_impl<false, T_ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>(pc,level)
{}

ParIter_impl (ContainerType& pc, int level, MFItInfo& info)
: ParIterBase_impl<false, T_ParticleType, NArrayReal, NArrayInt, Allocator>(pc,level,info)
: ParIterBase_impl<false, T_ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>(pc,level,info)
{}
};

template <typename T_ParticleType, int NArrayReal=0, int NArrayInt=0,
template<class> class Allocator=DefaultAllocator>
template<class> class Allocator=DefaultAllocator, class CellAssignor=DefaultAssignor>
class ParConstIter_impl
: public ParIterBase_impl<true,T_ParticleType, NArrayReal, NArrayInt, Allocator>
: public ParIterBase_impl<true,T_ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>
{
public:

using ParticleType = T_ParticleType;
using ContainerType = ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, DefaultAssignor>;
using ContainerType = ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>;
using ParticleTileType = typename ContainerType::ParticleTileType;
using AoS = typename ContainerType::AoS;
using SoA = typename ContainerType::SoA;
using RealVector = typename SoA::RealVector;
using IntVector = typename SoA::IntVector;

ParConstIter_impl (ContainerType const& pc, int level)
: ParIterBase_impl<true,ParticleType,NArrayReal,NArrayInt,Allocator>(pc,level)
: ParIterBase_impl<true,ParticleType,NArrayReal,NArrayInt,Allocator,CellAssignor>(pc,level)
{}

ParConstIter_impl (ContainerType const& pc, int level, MFItInfo& info)
: ParIterBase_impl<true,ParticleType,NArrayReal,NArrayInt,Allocator>(pc,level,info)
: ParIterBase_impl<true,ParticleType,NArrayReal,NArrayInt,Allocator, CellAssignor>(pc,level,info)
{}
};

template <bool is_const, typename ParticleType, int NArrayReal, int NArrayInt,
template<class> class Allocator>
ParIterBase_impl<is_const, ParticleType, NArrayReal, NArrayInt, Allocator>::ParIterBase_impl
template<class> class Allocator, class CellAssignor>
ParIterBase_impl<is_const, ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>::ParIterBase_impl
(ContainerRef pc, int level, MFItInfo& info)
:
MFIter(*pc.m_dummy_mf[level], pc.do_tiling ? info.EnableTiling(pc.tile_size) : info),
Expand Down Expand Up @@ -215,8 +214,8 @@ ParIterBase_impl<is_const, ParticleType, NArrayReal, NArrayInt, Allocator>::ParI
}

template <bool is_const, typename T_ParticleType, int NArrayReal, int NArrayInt,
template<class> class Allocator>
ParIterBase_impl<is_const, T_ParticleType, NArrayReal, NArrayInt, Allocator>::ParIterBase_impl
template<class> class Allocator, class CellAssignor>
ParIterBase_impl<is_const, T_ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>::ParIterBase_impl
(ContainerRef pc, int level)
:
MFIter(*pc.m_dummy_mf[level],
Expand Down Expand Up @@ -252,26 +251,26 @@ ParIterBase_impl<is_const, T_ParticleType, NArrayReal, NArrayInt, Allocator>::Pa
}

template <bool is_const, int T_NStructReal, int T_NStructInt, int T_NArrayReal=0, int T_NArrayInt=0,
template<class> class Allocator=DefaultAllocator>
using ParIterBase = ParIterBase_impl<is_const, Particle<T_NStructReal, T_NStructInt>, T_NArrayReal, T_NArrayInt, Allocator>;
template<class> class Allocator=DefaultAllocator, class CellAssignor=DefaultAssignor>
using ParIterBase = ParIterBase_impl<is_const, Particle<T_NStructReal, T_NStructInt>, T_NArrayReal, T_NArrayInt, Allocator, CellAssignor>;

template <bool is_const, int T_NArrayReal=0, int T_NArrayInt=0,
template<class> class Allocator=DefaultAllocator>
using ParIterBaseSoA = ParIterBase_impl<is_const,SoAParticle<T_NArrayReal, T_NArrayInt>, T_NArrayReal, T_NArrayInt, Allocator>;
template<class> class Allocator=DefaultAllocator, class CellAssignor=DefaultAssignor>
using ParIterBaseSoA = ParIterBase_impl<is_const,SoAParticle<T_NArrayReal, T_NArrayInt>, T_NArrayReal, T_NArrayInt, Allocator, CellAssignor>;

template <int T_NStructReal, int T_NStructInt=0, int T_NArrayReal=0, int T_NArrayInt=0,
template<class> class Allocator=DefaultAllocator>
using ParConstIter = ParConstIter_impl<Particle<T_NStructReal, T_NStructInt>, T_NArrayReal, T_NArrayInt, Allocator>;
template<class> class Allocator=DefaultAllocator, class CellAssignor=DefaultAssignor>
using ParConstIter = ParConstIter_impl<Particle<T_NStructReal, T_NStructInt>, T_NArrayReal, T_NArrayInt, Allocator, CellAssignor>;

template <int T_NArrayReal, int T_NArrayInt, template<class> class Allocator=DefaultAllocator>
using ParConstIterSoA = ParConstIter_impl<SoAParticle<T_NArrayReal, T_NArrayInt>, T_NArrayReal, T_NArrayInt, Allocator>;
template <int T_NArrayReal, int T_NArrayInt, template<class> class Allocator=DefaultAllocator, class CellAssignor=DefaultAssignor>
using ParConstIterSoA = ParConstIter_impl<SoAParticle<T_NArrayReal, T_NArrayInt>, T_NArrayReal, T_NArrayInt, Allocator, CellAssignor>;

template <int T_NStructReal, int T_NStructInt=0, int T_NArrayReal=0, int T_NArrayInt=0,
template<class> class Allocator=DefaultAllocator>
using ParIter = ParIter_impl<Particle<T_NStructReal, T_NStructInt>, T_NArrayReal, T_NArrayInt, Allocator>;
template<class> class Allocator=DefaultAllocator, class CellAssignor=DefaultAssignor>
using ParIter = ParIter_impl<Particle<T_NStructReal, T_NStructInt>, T_NArrayReal, T_NArrayInt, Allocator, CellAssignor>;

template <int T_NArrayReal, int T_NArrayInt, template<class> class Allocator=DefaultAllocator>
using ParIterSoA = ParIter_impl<SoAParticle<T_NArrayReal, T_NArrayInt>, T_NArrayReal, T_NArrayInt, Allocator>;
template <int T_NArrayReal, int T_NArrayInt, template<class> class Allocator=DefaultAllocator, class CellAssignor=DefaultAssignor>
using ParIterSoA = ParIter_impl<SoAParticle<T_NArrayReal, T_NArrayInt>, T_NArrayReal, T_NArrayInt, Allocator, CellAssignor>;

}

Expand Down
13 changes: 6 additions & 7 deletions Src/Particle/AMReX_ParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ struct ParticleInitType
};

template <bool is_const, typename T_ParticleType, int NArrayReal, int NArrayInt,
template<class> class Allocator>

template<class> class Allocator, class CellAssignor>
class ParIterBase_impl;

/**
Expand Down Expand Up @@ -159,8 +158,8 @@ public:
//! \brief The type of the "Particle"

private:
friend class ParIterBase_impl<true,ParticleType, NArrayReal, NArrayInt, Allocator>;
friend class ParIterBase_impl<false,ParticleType, NArrayReal, NArrayInt, Allocator>;
friend class ParIterBase_impl<true,ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>;
friend class ParIterBase_impl<false,ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>;

public:
//! \brief The memory allocator in use.
Expand All @@ -177,7 +176,7 @@ public:
RealDescriptor ParticleRealDescriptor = FPC::Native64RealDescriptor();
#endif

using ParticleContainerType = ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator>;
using ParticleContainerType = ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>;
using ParticleTileType = ParticleTile<ParticleType, NArrayReal, NArrayInt, Allocator>;
using ParticleInitData = ParticleInitType<NStructReal, NStructInt, NArrayReal, NArrayInt>;

Expand All @@ -191,8 +190,8 @@ public:
using IntVector = typename SoA::IntVector;
using ParticleVector = typename AoS::ParticleVector;
using CharVector = Gpu::DeviceVector<char>;
using ParIterType = ParIter_impl<ParticleType, NArrayReal, NArrayInt, Allocator>;
using ParConstIterType = ParConstIter_impl<ParticleType, NArrayReal, NArrayInt, Allocator>;
using ParIterType = ParIter_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>;
using ParConstIterType = ParConstIter_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>;

//! \brief Default constructor - construct an empty particle container that has no concept
//! of a level hierarchy. Must be properly initialized later.
Expand Down

0 comments on commit bad61ac

Please sign in to comment.