Skip to content

Commit

Permalink
Support SoA-Only Particles (#2878)
Browse files Browse the repository at this point in the history
Add support for storing particle positions and ids SoA style.

The proposed changes:
- [ ] fix a bug or incorrect behavior in AMReX
- [x] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [x] are likely to significantly affect the results of downstream AMReX
users
- [ ] include documentation in the code and/or rst files, if appropriate

---------

Co-authored-by: Andrew Myers <atmyers2@gmail.com>
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
  • Loading branch information
3 people committed Apr 17, 2023
1 parent 27ef4ea commit 6b294a5
Show file tree
Hide file tree
Showing 35 changed files with 2,104 additions and 499 deletions.
45 changes: 26 additions & 19 deletions Src/AmrCore/AMReX_AmrParticles.H
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

namespace amrex {

template <int NStructReal, int NStructInt, int NArrayReal, int NArrayInt,
template <typename ParticleType, int NArrayReal, int NArrayInt,
template<class> class Allocator>
void
ParticleContainer<NStructReal, NStructInt, NArrayReal, NArrayInt, Allocator>
ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator>
::AssignDensity (int rho_index,
Vector<std::unique_ptr<MultiFab> >& mf_to_be_filled,
int lev_min, int ncomp, int finest_level, int ngrow) const
Expand Down Expand Up @@ -249,40 +249,47 @@ ParticleToMesh (PC const& pc, const Vector<MultiFab*>& mf,
}
}

template <int NStructReal, int NStructInt=0, int NArrayReal=0, int NArrayInt=0,
template <typename T_ParticleType, int NArrayReal=0, int NArrayInt=0,
template<class> class Allocator=DefaultAllocator>
class AmrParticleContainer // NOLINT
: public ParticleContainer<NStructReal, NStructInt, NArrayReal, NArrayInt, Allocator>
class AmrParticleContainer_impl // NOLINT(cppcoreguidelines-virtual-class-destructor)
: public ParticleContainer_impl<T_ParticleType, NArrayReal, NArrayInt, Allocator>
{

public:

typedef Particle<NStructReal, NStructInt> ParticleType;
using ParticleType = T_ParticleType;

AmrParticleContainer () = default;
AmrParticleContainer_impl ()
: ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator>()
{
}

AmrParticleContainer (AmrCore* amr_core)
: ParticleContainer<NStructReal, NStructInt, NArrayReal, NArrayInt, Allocator>(amr_core->GetParGDB())
AmrParticleContainer_impl (AmrCore* amr_core)
: ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator>(amr_core->GetParGDB())
{
}

AmrParticleContainer (const Vector<Geometry> & geom,
const Vector<DistributionMapping> & dmap,
const Vector<BoxArray> & ba,
const Vector<int> & rr)
: ParticleContainer<NStructReal, NStructInt, NArrayReal, NArrayInt, Allocator>(geom, dmap, ba, rr)
AmrParticleContainer_impl (const Vector<Geometry> & geom,
const Vector<DistributionMapping> & dmap,
const Vector<BoxArray> & ba,
const Vector<int> & rr)
: ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator>(geom, dmap, ba, rr)
{
}

~AmrParticleContainer () override = default;
~AmrParticleContainer_impl () override = default;

AmrParticleContainer ( const AmrParticleContainer &) = delete;
AmrParticleContainer& operator= ( const AmrParticleContainer & ) = delete;
AmrParticleContainer_impl ( const AmrParticleContainer_impl &) = delete;
AmrParticleContainer_impl& operator= ( const AmrParticleContainer_impl & ) = delete;

AmrParticleContainer ( AmrParticleContainer && ) noexcept = default;
AmrParticleContainer& operator= ( AmrParticleContainer && ) noexcept = default;
AmrParticleContainer_impl ( AmrParticleContainer_impl && ) noexcept = default;
AmrParticleContainer_impl& operator= ( AmrParticleContainer_impl && ) noexcept = default;
};

template <int T_NStructReal, int T_NStructInt=0, int T_NArrayReal=0, int T_NArrayInt=0,
template<class> class Allocator=DefaultAllocator>
using AmrParticleContainer = AmrParticleContainer_impl<Particle<T_NStructReal, T_NStructInt>, T_NArrayReal, T_NArrayInt, Allocator>;

class AmrTracerParticleContainer
: public TracerParticleContainer
{
Expand Down
1 change: 1 addition & 0 deletions Src/Base/AMReX_Array.H
Original file line number Diff line number Diff line change
Expand Up @@ -897,3 +897,4 @@ namespace amrex
}

#endif

1 change: 1 addition & 0 deletions Src/Base/AMReX_Geometry.H
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ public:
[[nodiscard]] GpuArray<ParticleReal,AMREX_SPACEDIM> ProbLoArrayInParticleReal () const noexcept {
return roundoff_lo;
}

[[nodiscard]] GpuArray<ParticleReal,AMREX_SPACEDIM> ProbHiArrayInParticleReal () const noexcept {
return roundoff_hi;
}
Expand Down
18 changes: 9 additions & 9 deletions Src/Base/AMReX_TypeTraits.H
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ namespace amrex
struct IsMultiFabIterator : public std::is_base_of<MFIter, T>::type {};

#ifdef AMREX_PARTICLES
template <bool is_const, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt,
template<class> class Allocator>
class ParIterBase;
// template <bool is_const, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt,
// template<class> class Allocator>
// class ParIterBase;

template <int NStructReal, int NStructInt, int NArrayReal, int NArrayInt,
template<class> class Allocator>
class ParIter;
// template <int NStructReal, int NStructInt, int NArrayReal, int NArrayInt,
// template<class> class Allocator>
// class ParIter;

template <int NStructReal, int NStructInt, int NArrayReal, int NArrayInt,
template<class> class Allocator>
class ParConstIter;
// template <int NStructReal, int NStructInt, int NArrayReal, int NArrayInt,
// template<class> class Allocator>
// class ParConstIter;

class ParticleContainerBase;

Expand Down
1 change: 0 additions & 1 deletion Src/EB/AMReX_EB2.H
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ void Build (const Geometry& geom,
bool extend_domain_face = ExtendDomainFace(),
int num_coarsen_opt = NumCoarsenOpt());


void BuildFromChkptFile (std::string const& fname,
const Geometry& geom,
int required_coarsening_level,
Expand Down
Loading

0 comments on commit 6b294a5

Please sign in to comment.