25template <
class Particle_T>
36 explicit Cluster(Particle_T *firstParticle,
size_t clusterSize)
37 : _firstParticle(firstParticle), _clusterSize(clusterSize) {}
47 Particle_T &
operator[](
size_t index) {
return *(_firstParticle + index); }
52 const Particle_T &
operator[](
size_t index)
const {
return *(_firstParticle + index); }
59 const auto firstNonDummy = std::find_if(_firstParticle, _firstParticle + _clusterSize,
60 [](
const auto &particle) {
return not particle.isDummy(); });
61 return firstNonDummy > &_firstParticle[_clusterSize - 1];
70 [[nodiscard]] std::tuple<double, double, bool>
getZMinMax()
const {
74 auto pfirst = std::find_if(begin, end, [](
const auto &particle) {
return not particle.isDummy(); });
75 double min = pfirst != end ? pfirst->getR()[2] : std::numeric_limits<double>::max();
78 auto rbegin = std::make_reverse_iterator(end);
79 auto rend = std::make_reverse_iterator(begin);
80 auto plast = std::find_if(rbegin, rend, [](
const auto &particle) {
return not particle.isDummy(); });
81 double max = plast != rend ? plast->getR()[2] : std::numeric_limits<double>::min();
83 return {min, max, pfirst != end};
108 std::vector<Cluster<Particle_T> *> *
getNeighbors() {
return _neighborClusters; }
120 if (_neighborClusters) {
121 _neighborClusters->clear();
129 void reset(Particle_T *firstParticle) { _firstParticle = firstParticle; }
135 [[nodiscard]] std::tuple<std::array<double, 3>, std::array<double, 3>>
getBoundingBox()
const {
136 auto lowerCorner = _firstParticle->getR();
137 auto upperCorner = _firstParticle[_clusterSize - 1].getR();
139 for (
size_t i = 0; i < _clusterSize; ++i) {
140 const auto &pos = _firstParticle[i].getR();
143 for (
size_t dim = 0; dim < 2; ++dim) {
144 lowerCorner[dim] = std::min(lowerCorner[dim], pos[dim]);
145 upperCorner[dim] = std::max(upperCorner[dim], pos[dim]);
148 return {lowerCorner, upperCorner};
160 Particle_T *_firstParticle =
nullptr;
168 std::vector<Cluster *> *_neighborClusters =
nullptr;
View on a fixed part of a SoA between a start index and an end index.
Definition: SoAView.h:23
This class represents a cluster in the VerletClusterLists container.
Definition: Cluster.h:26
std::vector< Cluster< Particle_T > * > * getNeighbors()
Returns the reference to the neighbor list for this cluster.
Definition: Cluster.h:108
Particle_T & operator[](size_t index)
Returns the particle at position index in the cluster.
Definition: Cluster.h:47
const Particle_T & operator[](size_t index) const
Returns the particle at position index in the cluster.
Definition: Cluster.h:52
bool empty() const
Indicates if the cluster contains any non-dummy particles.
Definition: Cluster.h:58
std::tuple< double, double, bool > getZMinMax() const
Get Minimum and Maximum of the particles in z-direction.
Definition: Cluster.h:70
void addNeighbor(Cluster< Particle_T > &neighbor)
Adds the given cluster to the neighbor list of this cluster.
Definition: Cluster.h:114
void reset(Particle_T *firstParticle)
Definition: Cluster.h:129
Cluster(Particle_T *firstParticle, size_t clusterSize)
Constructs a cluster starting from firstParticle and going on for clusterSize particles.
Definition: Cluster.h:36
void setNeighborList(std::vector< Cluster< Particle_T > * > *neighborList)
Set the internal neighbor list pointer to an allocated, but not necessarily complete,...
Definition: Cluster.h:102
std::tuple< std::array< double, 3 >, std::array< double, 3 > > getBoundingBox() const
Get the bounding box of this cluster.
Definition: Cluster.h:135
auto getSoAView()
Returns the SoAView for this cluster.
Definition: Cluster.h:90
void clearNeighbors()
Remove all neighbors.
Definition: Cluster.h:119
void setSoAView(const SoAView< typename Particle_T::SoAArraysType > &view)
Set the SoAView for this cluster.
Definition: Cluster.h:96
This namespace is used for implementation specifics.
Definition: CellFunctor.h:14