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
17
18namespace autopas {
19
37template <class ParticleCell, class PairwiseFunctor, class NeighborList>
38class VLCSlicedTraversal : public SlicedLockBasedTraversal<ParticleCell, PairwiseFunctor>,
39 public VLCTraversalInterface<typename ParticleCell::ParticleType, NeighborList> {
40 public:
52 explicit VLCSlicedTraversal(const std::array<unsigned long, 3> &dims, PairwiseFunctor *pairwiseFunctor,
53 double interactionLength, const std::array<double, 3> &cellLength,
54 DataLayoutOption dataLayout, bool useNewton3, ContainerOption::Value typeOfList)
55 : SlicedLockBasedTraversal<ParticleCell, PairwiseFunctor>(dims, pairwiseFunctor, interactionLength, cellLength,
56 dataLayout, useNewton3, false),
57 VLCTraversalInterface<typename ParticleCell::ParticleType, NeighborList>(typeOfList),
58 _functor(pairwiseFunctor) {}
59
60 void traverseParticles() override;
61
62 [[nodiscard]] TraversalOption getTraversalType() const override {
63 switch (this->_typeOfList) {
64 case (ContainerOption::verletListsCells):
65 return TraversalOption::vlc_sliced;
66 case (ContainerOption::pairwiseVerletLists):
67 return TraversalOption::vlp_sliced;
68 default:
69 autopas::utils::ExceptionHandler::exception("Traversal was created with an unsupported neighborlist type: {}",
70 this->_typeOfList.to_string());
71 }
72 // should never be reached.
73 return TraversalOption();
74 }
75
76 [[nodiscard]] bool isApplicable() const override {
77 return (this->_dataLayout == DataLayoutOption::aos or this->_dataLayout == DataLayoutOption::soa);
78 }
79
84 void setSortingThreshold(size_t sortingThreshold) override {}
85
86 private:
87 PairwiseFunctor *_functor;
88};
89
90template <class ParticleCell, class PairwiseFunctor, class NeighborList>
92 if (this->_dataLayout == DataLayoutOption::soa) {
93 this->loadSoA(_functor, *(this->_verletList));
94 }
95
96 this->slicedTraversal([&](unsigned long x, unsigned long y, unsigned long z) {
97 auto baseIndex = utils::ThreeDimensionalMapping::threeToOneD(x, y, z, this->_cellsPerDimension);
98 this->template processCellLists<PairwiseFunctor>(*(this->_verletList), baseIndex, _functor, this->_dataLayout,
99 this->_useNewton3);
100 });
101
102 if (this->_dataLayout == DataLayoutOption::soa) {
103 this->extractSoA(_functor, *(this->_verletList));
104 }
105}
106
107} // namespace autopas
PairwiseFunctor class.
Definition: PairwiseFunctor.h:31
Class for Cells of Particles.
Definition: ParticleCell.h:51
This class provides the sliced traversal.
Definition: SlicedLockBasedTraversal.h:32
DataLayoutOption _dataLayout
The datalayout used by this traversal.
Definition: TraversalInterface.h:75
This class provides the (locked) sliced traversal.
Definition: VLCSlicedTraversal.h:39
TraversalOption getTraversalType() const override
Return a enum representing the name of the traversal class.
Definition: VLCSlicedTraversal.h:62
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:52
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: VLCSlicedTraversal.h:84
bool isApplicable() const override
Checks if the traversal is applicable to the current state of the domain.
Definition: VLCSlicedTraversal.h:76
void traverseParticles() override
Traverse the particles by pairs, triplets etc.
Definition: VLCSlicedTraversal.h:91
This class provides the Traversal Interface for the verlet lists cells container.
Definition: VLCTraversalInterface.h:27
ContainerOption _typeOfList
The type of neighbor list as an enum value.
Definition: VLCTraversalInterface.h:97
static void exception(const Exception e)
Handle an exception derived by std::exception.
Definition: ExceptionHandler.h:63
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:32