Skip to content

Commit

Permalink
Implement StructOfArray::empty() and ParticleTile::empty() for pure S…
Browse files Browse the repository at this point in the history
…oA (#3296)

The implementation of `ParticleTile::empty()` was wrong for pure SoA,
which led to problems in ImpactX:
ECP-WarpX/impactx#348

The proposed changes:
- [x] 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
- [ ] 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 committed May 4, 2023
1 parent c2f49bf commit a393d7f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Src/Particle/AMReX_ParticleTile.H
Original file line number Diff line number Diff line change
Expand Up @@ -746,8 +746,12 @@ struct ParticleTile
SoA& GetStructOfArrays () { return m_soa_tile; }
const SoA& GetStructOfArrays () const { return m_soa_tile; }

template <typename T = ParticleType, typename std::enable_if<!T::is_soa_particle, int>::type = 0>
bool empty () const { return m_aos_tile.empty(); }

template <typename T = ParticleType, typename std::enable_if<T::is_soa_particle, int>::type = 0>
bool empty () const { return m_soa_tile.empty(); }

/**
* \brief Returns the total number of particles (real and neighbor)
*
Expand Down
6 changes: 6 additions & 0 deletions Src/Particle/AMReX_StructOfArrays.H
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ struct StructOfArrays {
return 0;
}

/**
* \brief Returns whether the SoA is empty (i.e. has size() == 0)
*
*/
[[nodiscard]] bool empty () const { return this->size() == 0; }

/**
* \brief Returns the number of real particles (excluding neighbors)
*
Expand Down

0 comments on commit a393d7f

Please sign in to comment.