AutoPas  3.0.0
Loading...
Searching...
No Matches
ParticleCell.h
Go to the documentation of this file.
1
7#pragma once
8
12#include "autopas/utils/inBox.h"
13
14namespace autopas {
15
19enum class CellType {
40};
41
50template <class Particle_T>
52 public:
56 using ParticleType = Particle_T;
57
61 virtual ~ParticleCell() = default;
62
66 explicit ParticleCell() = default;
67
72 ParticleCell(ParticleCell &&other) noexcept = default;
73
78 ParticleCell(const ParticleCell &other) : _cellLock(){};
79
84 virtual void addParticle(const Particle_T &p) = 0;
85
90 [[nodiscard]] virtual size_t size() const = 0;
91
101 [[nodiscard]] virtual size_t getNumberOfParticles(IteratorBehavior behavior = IteratorBehavior::owned) const = 0;
102
107 [[nodiscard]] virtual bool isEmpty() const = 0;
108
112 virtual void clear() = 0;
113
117 virtual void deleteDummyParticles() = 0;
118
124
129 virtual void deleteByIndex(size_t index) = 0;
130
135 virtual void setCellLength(std::array<double, 3> &cellLength) = 0;
136
141 [[nodiscard]] virtual std::array<double, 3> getCellLength() const = 0;
142
152
163 std::lock_guard<AutoPasLock> guard(this->_cellLock);
166 "ParticleCell::setPossibleParticleOwnerships() can not set OwnershipState of a cell after "
167 "it has been set");
168 }
169 _ownershipState = state;
171 }
172
177 AutoPasLock &getCellLock() const { return _cellLock; }
178
179 protected:
185
194};
195
196} // namespace autopas
AutoPasLock for the sequential case.
Definition: WrapOpenMP.h:155
This class handles the storage of particles in their full form.
Definition: FullParticleCell.h:26
Class for Cells of Particles.
Definition: ParticleCell.h:51
ParticleCell(ParticleCell &&other) noexcept=default
Default move constructor.
virtual void clear()=0
Deletes all particles in this cell.
virtual size_t size() const =0
Get the number of all particles stored in this cell (owned, halo and dummy).
virtual bool isEmpty() const =0
Check if the cell is empty.
virtual ~ParticleCell()=default
Default destructor.
ParticleCell()=default
Default default constructor.
void setPossibleParticleOwnerships(OwnershipState state)
Set the type of particles contained in this cell.
Definition: ParticleCell.h:162
OwnershipState _ownershipState
The particles which can be contained in this cell are determined by the OwnershipState.
Definition: ParticleCell.h:189
virtual void deleteByIndex(size_t index)=0
Deletes the index-th particle.
virtual void deleteDummyParticles()=0
Deletes all dummy particles in this cell.
virtual void addParticle(const Particle_T &p)=0
Adds a Particle to the cell.
OwnershipState getPossibleParticleOwnerships() const
Get the type of particles contained in this cell.
Definition: ParticleCell.h:151
virtual CellType getParticleCellTypeAsEnum()=0
Get the ParticleCell type as an ParticleCellTypeEnum.
virtual std::array< double, 3 > getCellLength() const =0
Get the side lengths of this cell.
virtual void setCellLength(std::array< double, 3 > &cellLength)=0
Set the side lengths of this cell.
ParticleCell(const ParticleCell &other)
Copy constructor that creates a new default constructed lock for the new cell.
Definition: ParticleCell.h:78
AutoPasLock _cellLock
Lock object for exclusive access to this cell.
Definition: ParticleCell.h:184
bool _ownershipStateDefined
Flag that is set to true once OwnershipState has been set to avoid resetting the OwnershipState.
Definition: ParticleCell.h:193
virtual size_t getNumberOfParticles(IteratorBehavior behavior=IteratorBehavior::owned) const =0
Get the number of particles with respect to the specified IteratorBehavior.
AutoPasLock & getCellLock() const
Get a reference to the lock object for exclusive access to this cell.
Definition: ParticleCell.h:177
Particle_T ParticleType
The particle type for this cell.
Definition: ParticleCell.h:56
This class handles the storage of particles in their full form.
Definition: ReferenceParticleCell.h:24
This class defines a sorted view on a given ParticleCell.
Definition: SortedCellView.h:28
static void exception(const Exception e)
Handle an exception derived by std::exception.
Definition: ExceptionHandler.h:63
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32
CellType
The ParticleCell Type as an Enum.
Definition: ParticleCell.h:19
@ ClusterTower
ClusterTower : Tower for the 2D tower structure of VerletClusterLists.
@ IsNoCell
Currently unused.
OwnershipState
Enum that specifies the state of ownership.
Definition: OwnershipState.h:19
@ halo
Halo state, a particle with this state is an actual particle, but not owned by the current AutoPas ob...
@ owned
Owned state, a particle with this state is an actual particle and owned by the current AutoPas object...