26template <
class Particle_T,
bool modifiable,
bool regionIter>
27class ContainerIterator;
36template <
class Particle_T>
87 virtual void reserve(
size_t numParticles,
size_t numParticlesHaloEstimate) = 0;
95 template <
bool checkInBox = true>
97 if constexpr (checkInBox) {
100 "ParticleContainerInterface: Trying to add a particle that is not in the bounding box.\n"
126 template <
bool checkInBox = true>
128 if constexpr (checkInBox) {
130 if (
utils::inBox(haloParticle.getR(), this->getBoxMin(), this->getBoxMax())) {
132 "ParticleContainerInterface: Trying to add a halo particle that is not outside of in the bounding box.\n"
184 [[nodiscard]]
virtual size_t getNumberOfParticles(IteratorBehavior behavior = IteratorBehavior::owned)
const = 0;
190 [[nodiscard]]
virtual size_t size()
const = 0;
201 IteratorBehavior behavior = autopas::IteratorBehavior::ownedOrHalo,
209 IteratorBehavior behavior = autopas::IteratorBehavior::ownedOrHalo,
217 IteratorBehavior behavior = autopas::IteratorBehavior::ownedOrHalo,
219 nullptr) const final {
220 return begin(behavior);
233 const std::array<double, 3> &lowerCorner,
const std::array<double, 3> &higherCorner, IteratorBehavior behavior,
241 const std::array<double, 3> &lowerCorner,
const std::array<double, 3> &higherCorner, IteratorBehavior behavior,
247 [[nodiscard]]
constexpr bool end()
const {
return false; }
259 [[nodiscard]]
virtual const std::array<double, 3> &
getBoxMax()
const = 0;
265 [[nodiscard]]
virtual const std::array<double, 3> &
getBoxMin()
const = 0;
314 [[nodiscard]]
virtual std::vector<ParticleType>
updateContainer(
bool keepNeighborListsValid) = 0;
330 [[nodiscard]] std::set<TraversalOption>
getAllTraversals(
const InteractionTypeOption interactionType)
const {
331 return compatibleTraversals::allCompatibleTraversals(this->
getContainerType(), interactionType);
354 virtual std::tuple<const Particle_T *, size_t, size_t>
getParticle(
size_t cellIndex,
size_t particleIndex,
355 IteratorBehavior iteratorBehavior)
const = 0;
365 virtual std::tuple<const Particle_T *, size_t, size_t>
getParticle(
size_t cellIndex,
size_t particleIndex,
366 IteratorBehavior iteratorBehavior,
367 const std::array<double, 3> &boxMin,
368 const std::array<double, 3> &boxMax)
const = 0;
377 std::tuple<Particle_T *, size_t, size_t>
getParticle(
size_t cellIndex,
size_t particleIndex,
378 IteratorBehavior iteratorBehavior,
379 const std::array<double, 3> &boxMin,
380 const std::array<double, 3> &boxMax) {
381 const Particle_T *ptr{};
382 size_t nextCellIndex{}, nextParticleIndex{};
383 std::tie(ptr, nextCellIndex, nextParticleIndex) =
385 iteratorBehavior, boxMin, boxMax);
386 return {
const_cast<Particle_T *
>(ptr), nextCellIndex, nextParticleIndex};
394 std::tuple<Particle_T *, size_t, size_t>
getParticle(
size_t cellIndex,
size_t particleIndex,
395 IteratorBehavior iteratorBehavior) {
396 const Particle_T *ptr{};
397 size_t nextCellIndex{}, nextParticleIndex{};
398 std::tie(ptr, nextCellIndex, nextParticleIndex) =
401 return {
const_cast<Particle_T *
>(ptr), nextCellIndex, nextParticleIndex};
Public iterator class that iterates over a particle container and additional vectors (which are typic...
Definition: ContainerIterator.h:93
std::conditional_t< modifiable, std::vector< std::vector< Particle_T > * >, std::vector< std::vector< Particle_T > const * > > ParticleVecType
Type of the additional vector collection.
Definition: ContainerIterator.h:106
The ParticleContainerInterface class provides a basic interface for all Containers within AutoPas.
Definition: ParticleContainerInterface.h:37
std::set< TraversalOption > getAllTraversals(const InteractionTypeOption interactionType) const
Generates a list of all traversals that are theoretically applicable to this container.
Definition: ParticleContainerInterface.h:330
virtual void rebuildNeighborLists(TraversalInterface *traversal)=0
Rebuilds the neighbor lists for the next traversals.
std::tuple< Particle_T *, size_t, size_t > getParticle(size_t cellIndex, size_t particleIndex, IteratorBehavior iteratorBehavior, const std::array< double, 3 > &boxMin, const std::array< double, 3 > &boxMax)
Fetch the pointer to a particle, identified via a cell and particle index.
Definition: ParticleContainerInterface.h:377
virtual const std::array< double, 3 > & getBoxMin() const =0
Get the lower corner of the container without halo.
ParticleContainerInterface & operator=(const ParticleContainerInterface &other)=delete
Delete the copy assignment operator to prevent unwanted copies.
virtual double getCutoff() const =0
Return the cutoff of the container.
virtual const std::array< double, 3 > & getBoxMax() const =0
Get the upper corner of the container without halo.
virtual TraversalSelectorInfo getTraversalSelectorInfo() const =0
Generates a traversal selector info for this container.
constexpr bool end() const
Dummy to make range-based for loops work.
Definition: ParticleContainerInterface.h:247
virtual double getVerletSkin() const =0
Return the verletSkin of the container verletSkin.
virtual ContainerIterator< ParticleType, true, true > getRegionIterator(const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior, typename ContainerIterator< ParticleType, true, true >::ParticleVecType *additionalVectors=nullptr)=0
Iterate over all particles in a specified region for(auto iter = container.getRegionIterator(lowCorne...
std::tuple< Particle_T *, size_t, size_t > getParticle(size_t cellIndex, size_t particleIndex, IteratorBehavior iteratorBehavior)
Fetch the pointer to a particle, identified via a cell and particle index.
Definition: ParticleContainerInterface.h:394
virtual double getInteractionLength() const =0
Return the interaction length (cutoff+skin) of the container.
virtual bool deleteParticle(size_t cellIndex, size_t particleIndex)=0
Deletes the particle at the given index positions as long as this does not compromise the validity of...
Particle_T ParticleType
Type of the Particle.
Definition: ParticleContainerInterface.h:42
void addHaloParticle(const Particle_T &haloParticle)
Adds a particle to the container that lies in the halo region of the container.
Definition: ParticleContainerInterface.h:127
virtual ContainerIterator< ParticleType, true, false > begin(IteratorBehavior behavior=autopas::IteratorBehavior::ownedOrHalo, typename ContainerIterator< ParticleType, true, false >::ParticleVecType *additionalVectors=nullptr)=0
Iterate over all particles using for(auto iter = container.begin(); iter.isValid(); ++iter) .
virtual void setCutoff(double cutoff)=0
Set the cutoff of the container.
size_t _stepsSinceLastRebuild
Stores the number of time-steps since last neighbor list rebuild.
Definition: ParticleContainerInterface.h:429
virtual void deleteAllParticles()=0
Deletes all particles.
virtual size_t getNumberOfParticles(IteratorBehavior behavior=IteratorBehavior::owned) const =0
Get the number of particles with respect to the specified IteratorBehavior.
virtual bool updateHaloParticle(const Particle_T &haloParticle)=0
Update a halo particle of the container with the given haloParticle.
virtual void reserve(size_t numParticles, size_t numParticlesHaloEstimate)=0
Reserve memory for a given number of particles in the container and logic layers.
virtual std::vector< ParticleType > updateContainer(bool keepNeighborListsValid)=0
Updates the container.
virtual ContainerOption getContainerType() const =0
Get the ContainerType.
virtual void setStepsSinceLastRebuild(size_t stepsSinceLastRebuild)
Set the number of time-steps since last neighbor list rebuild.
Definition: ParticleContainerInterface.h:297
virtual void addParticleImpl(const Particle_T &p)=0
Adds a particle to the container.
double _skin
Skin distance a particle is allowed to move in one time-step.
Definition: ParticleContainerInterface.h:434
virtual CellType getParticleCellTypeEnum() const =0
Get the ParticleCell type as an Enum.
virtual ContainerIterator< ParticleType, false, false > cbegin(IteratorBehavior behavior=autopas::IteratorBehavior::ownedOrHalo, typename ContainerIterator< ParticleType, false, false >::ParticleVecType *additionalVectors=nullptr) const final
Iterate over all particles using for(auto iter = container.begin(); iter.isValid(); ++iter) .
Definition: ParticleContainerInterface.h:216
virtual std::tuple< const Particle_T *, size_t, size_t > getParticle(size_t cellIndex, size_t particleIndex, IteratorBehavior iteratorBehavior) const =0
Fetch the pointer to a particle, identified via a cell and particle index.
void addParticle(const Particle_T &p)
Adds a particle to the container.
Definition: ParticleContainerInterface.h:96
virtual void computeInteractions(TraversalInterface *traversal)=0
Iterates over all particle multiples (e.g.
virtual void deleteHaloParticles()=0
Deletes all halo particles.
virtual ContainerIterator< ParticleType, false, false > begin(IteratorBehavior behavior=autopas::IteratorBehavior::ownedOrHalo, typename ContainerIterator< ParticleType, false, false >::ParticleVecType *additionalVectors=nullptr) const =0
Iterate over all particles using for(auto iter = container.begin(); iter.isValid(); ++iter) .
virtual bool deleteParticle(Particle_T &particle)=0
Deletes the given particle as long as this does not compromise the validity of the container.
ParticleContainerInterface(double skin)
Constructor.
Definition: ParticleContainerInterface.h:54
virtual std::tuple< const Particle_T *, size_t, size_t > getParticle(size_t cellIndex, size_t particleIndex, IteratorBehavior iteratorBehavior, const std::array< double, 3 > &boxMin, const std::array< double, 3 > &boxMax) const =0
Fetch the pointer to a particle, identified via a cell and particle index.
virtual size_t getStepsSinceLastRebuild() const
Return the number of time-steps since last neighbor list rebuild.
Definition: ParticleContainerInterface.h:291
virtual void addHaloParticleImpl(const Particle_T &haloParticle)=0
Adds a particle to the container that lies in the halo region of the container.
ParticleContainerInterface(const ParticleContainerInterface &obj)=delete
Delete the copy constructor to prevent unwanted copies.
virtual size_t size() const =0
Get the total number of particles saved in the container (owned + halo + dummy).
virtual ContainerIterator< ParticleType, false, true > getRegionIterator(const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior, typename ContainerIterator< ParticleType, false, true >::ParticleVecType *additionalVectors=nullptr) const =0
Iterate over all particles in a specified region for(auto iter = container.getRegionIterator(lowCorne...
virtual ~ParticleContainerInterface()=default
Destructor of ParticleContainerInterface.
This interface serves as a common parent class for all traversals.
Definition: TraversalInterface.h:18
Info for traversals of a specific container.
Definition: TraversalSelectorInfo.h:14
static void exception(const Exception e)
Handle an exception derived by std::exception.
Definition: ExceptionHandler.h:63
bool notInBox(const std::array< T, 3 > &position, const std::array< T, 3 > &low, const std::array< T, 3 > &high)
Checks if position is not inside of a box defined by low and high.
Definition: inBox.h:50
bool inBox(const std::array< T, 3 > &position, const std::array< T, 3 > &low, const std::array< T, 3 > &high)
Checks if position is inside of a box defined by low and high.
Definition: inBox.h:26
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32
CellType
The ParticleCell Type as an Enum.
Definition: ParticleCell.h:19