26template <
class Particle_T,
bool modifiable,
bool regionIter>
27class ContainerIterator;
36template <
class Particle_T>
81 virtual void reserve(
size_t numParticles,
size_t numParticlesHaloEstimate) = 0;
89 template <
bool checkInBox = true>
91 if constexpr (checkInBox) {
94 "ParticleContainerInterface: Trying to add a particle that is not in the bounding box.\n"
120 template <
bool checkInBox = true>
122 if constexpr (checkInBox) {
124 if (
utils::inBox(haloParticle.getR(), this->getBoxMin(), this->getBoxMax())) {
126 "ParticleContainerInterface: Trying to add a halo particle that is not outside of in the bounding box.\n"
178 [[nodiscard]]
virtual size_t getNumberOfParticles(IteratorBehavior behavior = IteratorBehavior::owned)
const = 0;
184 [[nodiscard]]
virtual size_t size()
const = 0;
195 IteratorBehavior behavior = IteratorBehavior::ownedOrHalo,
203 IteratorBehavior behavior = IteratorBehavior::ownedOrHalo,
211 IteratorBehavior behavior = IteratorBehavior::ownedOrHalo,
213 return begin(behavior, additionalVectors);
226 const std::array<double, 3> &lowerCorner,
const std::array<double, 3> &higherCorner, IteratorBehavior behavior,
234 const std::array<double, 3> &lowerCorner,
const std::array<double, 3> &higherCorner, IteratorBehavior behavior,
240 [[nodiscard]]
constexpr bool end()
const {
return false; }
252 [[nodiscard]]
virtual const std::array<double, 3> &
getBoxMax()
const = 0;
258 [[nodiscard]]
virtual const std::array<double, 3> &
getBoxMin()
const = 0;
307 [[nodiscard]]
virtual std::vector<Particle_T>
updateContainer(
bool keepNeighborListsValid) = 0;
323 [[nodiscard]] std::set<TraversalOption>
getAllTraversals(
const InteractionTypeOption interactionType)
const {
324 return compatibleTraversals::allCompatibleTraversals(this->
getContainerType(), interactionType);
347 virtual std::tuple<const Particle_T *, size_t, size_t>
getParticle(
size_t cellIndex,
size_t particleIndex,
348 IteratorBehavior iteratorBehavior)
const = 0;
358 virtual std::tuple<const Particle_T *, size_t, size_t>
getParticle(
size_t cellIndex,
size_t particleIndex,
359 IteratorBehavior iteratorBehavior,
360 const std::array<double, 3> &boxMin,
361 const std::array<double, 3> &boxMax)
const = 0;
370 std::tuple<Particle_T *, size_t, size_t>
getParticle(
size_t cellIndex,
size_t particleIndex,
371 IteratorBehavior iteratorBehavior,
372 const std::array<double, 3> &boxMin,
373 const std::array<double, 3> &boxMax) {
374 const Particle_T *ptr{};
375 size_t nextCellIndex{}, nextParticleIndex{};
376 std::tie(ptr, nextCellIndex, nextParticleIndex) =
378 iteratorBehavior, boxMin, boxMax);
379 return {
const_cast<Particle_T *
>(ptr), nextCellIndex, nextParticleIndex};
387 std::tuple<Particle_T *, size_t, size_t>
getParticle(
size_t cellIndex,
size_t particleIndex,
388 IteratorBehavior iteratorBehavior) {
389 const Particle_T *ptr{};
390 size_t nextCellIndex{}, nextParticleIndex{};
391 std::tie(ptr, nextCellIndex, nextParticleIndex) =
394 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:323
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:370
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.
virtual ContainerIterator< Particle_T, false, true > getRegionIterator(const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior, typename ContainerIterator< Particle_T, false, true >::ParticleVecType *additionalVectors=nullptr) const =0
Iterate over all particles in a specified region for(auto iter = container.getRegionIterator(lowCorne...
constexpr bool end() const
Dummy to make range-based for loops work.
Definition: ParticleContainerInterface.h:240
virtual double getVerletSkin() const =0
Return the verletSkin of the container verletSkin.
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:387
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...
virtual std::vector< Particle_T > updateContainer(bool keepNeighborListsValid)=0
Updates the container.
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:121
virtual ContainerIterator< Particle_T, true, true > getRegionIterator(const std::array< double, 3 > &lowerCorner, const std::array< double, 3 > &higherCorner, IteratorBehavior behavior, typename ContainerIterator< Particle_T, true, true >::ParticleVecType *additionalVectors=nullptr)=0
Iterate over all particles in a specified region for(auto iter = container.getRegionIterator(lowCorne...
ContainerIterator< Particle_T, false, false > cbegin(IteratorBehavior behavior=IteratorBehavior::ownedOrHalo, typename ContainerIterator< Particle_T, false, false >::ParticleVecType *additionalVectors=nullptr) const
Iterate over all particles using for(auto iter = container.begin(); iter.isValid(); ++iter) .
Definition: ParticleContainerInterface.h:210
virtual void setCutoff(double cutoff)=0
Set the cutoff of the container.
virtual ContainerIterator< Particle_T, false, false > begin(IteratorBehavior behavior=IteratorBehavior::ownedOrHalo, typename ContainerIterator< Particle_T, false, false >::ParticleVecType *additionalVectors=nullptr) const =0
Iterate over all particles using for(auto iter = container.begin(); iter.isValid(); ++iter) .
size_t _stepsSinceLastRebuild
Stores the number of time-steps since last neighbor list rebuild.
Definition: ParticleContainerInterface.h:422
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 ContainerIterator< Particle_T, true, false > begin(IteratorBehavior behavior=IteratorBehavior::ownedOrHalo, typename ContainerIterator< Particle_T, true, false >::ParticleVecType *additionalVectors=nullptr)=0
Iterate over all particles using for(auto iter = container.begin(); iter.isValid(); ++iter) .
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:290
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:427
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:90
virtual void computeInteractions(TraversalInterface *traversal)=0
Iterates over all particle multiples (e.g.
virtual void deleteHaloParticles()=0
Deletes all halo particles.
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:48
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:284
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 ~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