AutoPas  3.0.0
Loading...
Searching...
No Matches
VCLClusterFunctor.h
Go to the documentation of this file.
1
7#pragma once
8
12
13namespace autopas::internal {
20template <class Particle_T, class PairwiseFunctor>
22 public:
30 explicit VCLClusterFunctor(PairwiseFunctor *functor, size_t clusterSize, DataLayoutOption dataLayout, bool useNewton3)
31 : _functor(functor), _clusterSize(clusterSize), _dataLayout(dataLayout), _useNewton3(useNewton3) {}
32
38 void processCluster(internal::Cluster<Particle_T> &cluster, bool isHaloCluster) {
39 if (not isHaloCluster) {
40 traverseCluster(cluster);
41 }
42
43 // only iterate neighbors if the neighbor list contains more than just nullptr
44 if (*(cluster.getNeighbors()->data())) {
45 for (auto *neighborClusterPtr : *(cluster.getNeighbors())) {
46 traverseClusterPair(cluster, *neighborClusterPtr);
47 }
48 }
49 }
50
51 private:
56 void traverseCluster(internal::Cluster<Particle_T> &cluster) {
57 if (_dataLayout == DataLayoutOption::aos) {
58 for (size_t i = 0; i < _clusterSize; i++) {
59 for (size_t j = i + 1; j < _clusterSize; j++) {
60 // this if else branch is needed because of https://github.com/AutoPas/AutoPas/issues/426
61 if (_useNewton3) {
62 _functor->AoSFunctor(cluster[i], cluster[j], true);
63 } else {
64 _functor->AoSFunctor(cluster[i], cluster[j], false);
65 _functor->AoSFunctor(cluster[j], cluster[i], false);
66 }
67 }
68 }
69 } else {
70 _functor->SoAFunctorSingle(cluster.getSoAView(), _useNewton3);
71 }
72 }
73
79 void traverseClusterPair(internal::Cluster<Particle_T> &cluster, internal::Cluster<Particle_T> &neighborCluster) {
80 if (_dataLayout == DataLayoutOption::aos) {
81 for (size_t i = 0; i < _clusterSize; i++) {
82 for (size_t j = 0; j < _clusterSize; j++) {
83 _functor->AoSFunctor(cluster[i], neighborCluster[j], _useNewton3);
84 }
85 }
86 } else {
87 _functor->SoAFunctorPair(cluster.getSoAView(), neighborCluster.getSoAView(), _useNewton3);
88 }
89 }
90
91 private:
92 PairwiseFunctor *_functor;
93 size_t _clusterSize;
94 DataLayoutOption _dataLayout;
95 bool _useNewton3;
96};
97
98} // namespace autopas::internal
PairwiseFunctor class.
Definition: PairwiseFunctor.h:31
virtual void AoSFunctor(Particle_T &i, Particle_T &j, bool newton3)
PairwiseFunctor for arrays of structures (AoS).
Definition: PairwiseFunctor.h:56
virtual void SoAFunctorPair(SoAView< SoAArraysType > soa1, SoAView< SoAArraysType > soa2, bool newton3)
PairwiseFunctor for structure of arrays (SoA)
Definition: PairwiseFunctor.h:102
virtual void SoAFunctorSingle(SoAView< SoAArraysType > soa, bool newton3)
PairwiseFunctor for structure of arrays (SoA)
Definition: PairwiseFunctor.h:70
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
auto getSoAView()
Returns the SoAView for this cluster.
Definition: Cluster.h:90
Provides methods to traverse a single cluster and a pair of clusters.
Definition: VCLClusterFunctor.h:21
void processCluster(internal::Cluster< Particle_T > &cluster, bool isHaloCluster)
Invokes the calculations of all interactions within the cluster and, if they exist,...
Definition: VCLClusterFunctor.h:38
VCLClusterFunctor(PairwiseFunctor *functor, size_t clusterSize, DataLayoutOption dataLayout, bool useNewton3)
Constructs a VCLClusterFunctor that uses the given functor internally.
Definition: VCLClusterFunctor.h:30
This namespace is used for implementation specifics.
Definition: CellFunctor.h:14