AutoPas  3.0.0
Loading...
Searching...
No Matches
VLCSlicedTraversal.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <algorithm>
11
16
17namespace autopas {
18
36template <class ParticleCell, class PairwiseFunctor, class NeighborList>
37class VLCSlicedTraversal : public SlicedLockBasedTraversal<ParticleCell, PairwiseFunctor>,
38 public VLCTraversalInterface<typename ParticleCell::ParticleType, NeighborList> {
39 public:
51 explicit VLCSlicedTraversal(const std::array<unsigned long, 3> &dims, PairwiseFunctor &pairwiseFunctor,
52 double interactionLength, const std::array<double, 3> &cellLength,
53 DataLayoutOption dataLayout, bool useNewton3, ContainerOption::Value typeOfList)
54 : SlicedLockBasedTraversal<ParticleCell, PairwiseFunctor>(dims, pairwiseFunctor, interactionLength, cellLength,
55 dataLayout, useNewton3, false),
56 VLCTraversalInterface<typename ParticleCell::ParticleType, NeighborList>(typeOfList),
57 _functor(pairwiseFunctor) {}
58
59 void traverseParticles() override;
60
61 [[nodiscard]] TraversalOption getTraversalType() const override {
62 switch (this->_typeOfList) {
63 case (ContainerOption::verletListsCells):
64 return TraversalOption::vlc_sliced;
65 case (ContainerOption::pairwiseVerletLists):
66 return TraversalOption::vlp_sliced;
67 default:
68 autopas::utils::ExceptionHandler::exception("Traversal was created with an unsupported neighborlist type: {}",
69 this->_typeOfList.to_string());
70 }
71 // should never be reached.
72 return TraversalOption();
73 }
74
79 [[nodiscard]] bool isApplicableToDomain() const override { return true; }
80
85 void setAoSSortingThreshold(size_t aosSortingThreshold) override {}
89 void setSoASortingThreshold(size_t soaSortingThreshold) override {}
90
91 private:
92 PairwiseFunctor &_functor;
93};
94
95template <class ParticleCell, class PairwiseFunctor, class NeighborList>
97 if (this->_dataLayout == DataLayoutOption::soa) {
98 this->loadSoA(_functor, *(this->_verletList));
99 }
100
101 this->slicedTraversal([&](unsigned long x, unsigned long y, unsigned long z) {
102 auto baseIndex = utils::ThreeDimensionalMapping::threeToOneD(x, y, z, this->_cellsPerDimension);
103 this->template processCellLists<PairwiseFunctor>(*(this->_verletList), baseIndex, _functor, this->_dataLayout,
104 this->_useNewton3);
105 });
106
107 if (this->_dataLayout == DataLayoutOption::soa) {
108 this->extractSoA(_functor, *(this->_verletList));
109 }
110}
111
112} // namespace autopas
PairwiseFunctor class.
Definition: PairwiseFunctor.h:45
Class for Cells of Particles.
Definition: ParticleCell.h:49
This class provides the sliced traversal.
Definition: SlicedLockBasedTraversal.h:32
This class provides the (locked) sliced traversal.
Definition: VLCSlicedTraversal.h:38
TraversalOption getTraversalType() const override
Return a enum representing the name of the traversal class.
Definition: VLCSlicedTraversal.h:61
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: VLCSlicedTraversal.h:85
VLCSlicedTraversal(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 sliced traversal.
Definition: VLCSlicedTraversal.h:51
void setSoASortingThreshold(size_t soaSortingThreshold) override
Set the SoA sorting-threshold for traversals that use the CellFunctor.
Definition: VLCSlicedTraversal.h:89
bool isApplicableToDomain() const override
VLC Sliced is always applicable to the domain.
Definition: VLCSlicedTraversal.h:79
void traverseParticles() override
Traverse the particles by pairs, triplets etc.
Definition: VLCSlicedTraversal.h:96
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