AutoPas  3.0.0
Loading...
Searching...
No Matches
VCLSlicedBalancedTraversal.h
Go to the documentation of this file.
1
7#pragma once
8
13
14namespace autopas {
15
24template <class ParticleCell, class PairwiseFunctor>
25class VCLSlicedBalancedTraversal : public SlicedBalancedBasedTraversal<ParticleCell, PairwiseFunctor>,
26 public VCLTraversalInterface<typename ParticleCell::ParticleType> {
27 private:
28 using ParticleType = typename ParticleCell::ParticleType;
29
30 PairwiseFunctor *_functor;
32
33 void processBaseStep(unsigned long x, unsigned long y) {
35 auto &currentTower = clusterList.getTowerByIndex(x, y);
36
37 for (auto clusterIter =
38 (this->_useNewton3 ? currentTower.getClusters().begin() : currentTower.getFirstOwnedCluster());
39 clusterIter < (this->_useNewton3 ? currentTower.getClusters().end() : currentTower.getFirstTailHaloCluster());
40 ++clusterIter) {
41 const auto isHaloCluster =
42 clusterIter < currentTower.getFirstOwnedCluster() or clusterIter >= currentTower.getFirstTailHaloCluster();
43 _clusterFunctor.processCluster(*clusterIter, isHaloCluster);
44 }
45 }
46
47 public:
59 explicit VCLSlicedBalancedTraversal(const std::array<unsigned long, 3> &dims, PairwiseFunctor *pairwiseFunctor,
60 double interactionLength, const std::array<double, 3> &cellLength,
61 size_t clusterSize, DataLayoutOption dataLayout, bool useNewton3)
62 : SlicedBalancedBasedTraversal<ParticleCell, PairwiseFunctor>(dims, pairwiseFunctor, interactionLength,
63 cellLength, dataLayout, useNewton3, false),
64 _functor(pairwiseFunctor),
65 _clusterFunctor(pairwiseFunctor, clusterSize, dataLayout, useNewton3) {}
66
67 [[nodiscard]] TraversalOption getTraversalType() const override { return TraversalOption::vcl_sliced_balanced; }
68
69 void loadDataLayout() override {
70 if (this->_dataLayout == DataLayoutOption::soa) {
71 VCLTraversalInterface<ParticleType>::_verletClusterLists->loadParticlesIntoSoAs(_functor);
72 }
73 }
74
75 void endTraversal() override {
76 if (this->_dataLayout == DataLayoutOption::soa) {
77 VCLTraversalInterface<ParticleType>::_verletClusterLists->extractParticlesFromSoAs(_functor);
78 }
79 }
80
81 void traverseParticles() override {
82 this->slicedTraversal([&](unsigned long x, unsigned long y, unsigned long z) { processBaseStep(x, y); });
83 }
84
89 void setSortingThreshold(size_t sortingThreshold) override {}
90};
91} // namespace autopas
PairwiseFunctor class.
Definition: PairwiseFunctor.h:31
Class for Cells of Particles.
Definition: ParticleCell.h:51
Particle_T ParticleType
The particle type for this cell.
Definition: ParticleCell.h:56
This class provides a load balanced version of the base sliced traversal.
Definition: SlicedBalancedBasedTraversal.h:30
void slicedTraversal(LoopBody &&loopBody)
The main traversal of the sliced traversal.
Definition: SlicedLockBasedTraversal.h:62
DataLayoutOption _dataLayout
The datalayout used by this traversal.
Definition: TraversalInterface.h:75
bool _useNewton3
If this traversal makes use of newton3.
Definition: TraversalInterface.h:80
This traversal splits the domain into slices along the longer dimension among x and y.
Definition: VCLSlicedBalancedTraversal.h:26
void loadDataLayout() override
Load Data Layouts required for this Traversal if cells have been set through setCellsToTraverse().
Definition: VCLSlicedBalancedTraversal.h:69
void setSortingThreshold(size_t sortingThreshold) override
Set the sorting-threshold for traversals that use the CellFunctor If the sum of the number of particl...
Definition: VCLSlicedBalancedTraversal.h:89
TraversalOption getTraversalType() const override
Return a enum representing the name of the traversal class.
Definition: VCLSlicedBalancedTraversal.h:67
VCLSlicedBalancedTraversal(const std::array< unsigned long, 3 > &dims, PairwiseFunctor *pairwiseFunctor, double interactionLength, const std::array< double, 3 > &cellLength, size_t clusterSize, DataLayoutOption dataLayout, bool useNewton3)
Constructor of the VCLSlicedBalancedTraversal.
Definition: VCLSlicedBalancedTraversal.h:59
void endTraversal() override
Write Data to AoS if cells have been set through setCellsToTraverse().
Definition: VCLSlicedBalancedTraversal.h:75
void traverseParticles() override
Traverse the particles by pairs, triplets etc.
Definition: VCLSlicedBalancedTraversal.h:81
Interface for traversals of the VerletClusterLists container.
Definition: VCLTraversalInterface.h:20
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
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32