AutoPas  3.0.0
Loading...
Searching...
No Matches
VLCSlicedBalancedTraversal.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <algorithm>
11
15
16namespace autopas {
17
32template <class ParticleCell, class PairwiseFunctor, class NeighborList>
33class VLCSlicedBalancedTraversal : public SlicedBalancedBasedTraversal<ParticleCell, PairwiseFunctor>,
34 public VLCTraversalInterface<typename ParticleCell::ParticleType, NeighborList> {
35 public:
47 explicit VLCSlicedBalancedTraversal(const std::array<unsigned long, 3> &dims, PairwiseFunctor &pairwiseFunctor,
48 double interactionLength, const std::array<double, 3> &cellLength,
49 DataLayoutOption dataLayout, bool useNewton3, ContainerOption::Value typeOfList)
50 : SlicedBalancedBasedTraversal<ParticleCell, PairwiseFunctor>(dims, pairwiseFunctor, interactionLength,
51 cellLength, dataLayout, useNewton3, false),
52 VLCTraversalInterface<typename ParticleCell::ParticleType, NeighborList>(typeOfList),
53 _functor(pairwiseFunctor) {}
54
55 void traverseParticles() override;
56
57 [[nodiscard]] TraversalOption getTraversalType() const override {
58 switch (this->_typeOfList) {
59 case (ContainerOption::verletListsCells):
60 return TraversalOption::vlc_sliced_balanced;
61 case (ContainerOption::pairwiseVerletLists):
62 return TraversalOption::vlp_sliced_balanced;
63 default:
64 autopas::utils::ExceptionHandler::exception("Traversal was created with an unsupported neighborlist type: {}",
65 this->_typeOfList.to_string());
66 }
67 // should never be reached.
68 return TraversalOption();
69 }
70
75 [[nodiscard]] bool isApplicableToDomain() const override { return true; }
76
81 void setAoSSortingThreshold(size_t aosSortingThreshold) override {}
85 void setSoASortingThreshold(size_t soaSortingThreshold) override {}
86
87 private:
88 PairwiseFunctor &_functor;
89};
90
91template <class ParticleCell, class PairwiseFunctor, class NeighborList>
93 if (this->_dataLayout == DataLayoutOption::soa) {
94 this->loadSoA(_functor, *(this->_verletList));
95 }
96
97 this->slicedTraversal([&](unsigned long x, unsigned long y, unsigned long z) {
98 auto baseIndex = utils::ThreeDimensionalMapping::threeToOneD(x, y, z, this->_cellsPerDimension);
99 this->template processCellLists<PairwiseFunctor>(*(this->_verletList), baseIndex, _functor, this->_dataLayout,
100 this->_useNewton3);
101 });
102
103 if (this->_dataLayout == DataLayoutOption::soa) {
104 this->extractSoA(_functor, *(this->_verletList));
105 }
106}
107
108} // namespace autopas
PairwiseFunctor class.
Definition: PairwiseFunctor.h:45
Class for Cells of Particles.
Definition: ParticleCell.h:49
This class provides a load balanced version of the base sliced traversal.
Definition: SlicedBalancedBasedTraversal.h:30
This class provides the balanced sliced traversal.
Definition: VLCSlicedBalancedTraversal.h:34
void setSoASortingThreshold(size_t soaSortingThreshold) override
Set the SoA sorting-threshold for traversals that use the CellFunctor.
Definition: VLCSlicedBalancedTraversal.h:85
TraversalOption getTraversalType() const override
Return a enum representing the name of the traversal class.
Definition: VLCSlicedBalancedTraversal.h:57
bool isApplicableToDomain() const override
VLC Sliced Balanced is always applicable to the domain.
Definition: VLCSlicedBalancedTraversal.h:75
void traverseParticles() override
Traverse the particles by pairs, triplets etc.
Definition: VLCSlicedBalancedTraversal.h:92
void setAoSSortingThreshold(size_t aosSortingThreshold) override
Set the aos-sorting-threshold for traversals that use the CellFunctor If the sum of the number of par...
Definition: VLCSlicedBalancedTraversal.h:81
VLCSlicedBalancedTraversal(const std::array< unsigned long, 3 > &dims, PairwiseFunctor &pairwiseFunctor, double interactionLength, const std::array< double, 3 > &cellLength, DataLayoutOption dataLayout, bool useNewton3, ContainerOption::Value typeOfList)
Constructor of the balanced sliced traversal.
Definition: VLCSlicedBalancedTraversal.h:47
This class provides the Traversal Interface for the verlet lists cells container.
Definition: VLCTraversalInterface.h:38
ContainerOption _typeOfList
The type of neighbor list as an enum value.
Definition: VLCTraversalInterface.h:108
static void exception(const Exception e)
Handle an exception derived by std::exception.
Definition: ExceptionHandler.h:64
constexpr T threeToOneD(T x, T y, T z, const std::array< T, 3 > &dims)
Convert a 3d index to a 1d index.
Definition: ThreeDimensionalMapping.h:29
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:34