AutoPas  3.0.0
Loading...
Searching...
No Matches
VLCSlicedC02Traversal.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <algorithm>
11
17
18namespace autopas {
19
32template <class ParticleCell, class PairwiseFunctor, class NeighborList>
33class VLCSlicedC02Traversal : public SlicedC02BasedTraversal<ParticleCell, PairwiseFunctor>,
34 public VLCTraversalInterface<typename ParticleCell::ParticleType, NeighborList> {
35 public:
47 explicit VLCSlicedC02Traversal(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 : SlicedC02BasedTraversal<ParticleCell, PairwiseFunctor>(dims, pairwiseFunctor, interactionLength, cellLength,
51 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_c02;
61 case (ContainerOption::pairwiseVerletLists):
62 return TraversalOption::vlp_sliced_c02;
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
71 [[nodiscard]] bool isApplicable() const override {
72 return (this->_dataLayout == DataLayoutOption::aos or this->_dataLayout == DataLayoutOption::soa);
73 }
74
79 void setSortingThreshold(size_t sortingThreshold) override {}
80
81 private:
82 PairwiseFunctor *_functor;
83};
84
85template <class ParticleCell, class PairwiseFunctor, class NeighborList>
87 if (this->_dataLayout == DataLayoutOption::soa) {
88 this->loadSoA(_functor, *(this->_verletList));
89 }
90
91 this->cSlicedTraversal([&](unsigned long x, unsigned long y, unsigned long z) {
92 auto baseIndex = utils::ThreeDimensionalMapping::threeToOneD(x, y, z, this->_cellsPerDimension);
93 this->template processCellLists<PairwiseFunctor>(*(this->_verletList), baseIndex, _functor, this->_dataLayout,
94 this->_useNewton3);
95 });
96
97 if (this->_dataLayout == DataLayoutOption::soa) {
98 this->extractSoA(_functor, *(this->_verletList));
99 }
100}
101
102} // namespace autopas
PairwiseFunctor class.
Definition: PairwiseFunctor.h:31
Class for Cells of Particles.
Definition: ParticleCell.h:51
This class provides the colored sliced traversal.
Definition: SlicedC02BasedTraversal.h:33
DataLayoutOption _dataLayout
The datalayout used by this traversal.
Definition: TraversalInterface.h:75
This class provides the colored sliced traversal.
Definition: VLCSlicedC02Traversal.h:34
TraversalOption getTraversalType() const override
Return a enum representing the name of the traversal class.
Definition: VLCSlicedC02Traversal.h:57
VLCSlicedC02Traversal(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 colored sliced traversal.
Definition: VLCSlicedC02Traversal.h:47
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: VLCSlicedC02Traversal.h:79
void traverseParticles() override
Traverse the particles by pairs, triplets etc.
Definition: VLCSlicedC02Traversal.h:86
bool isApplicable() const override
Checks if the traversal is applicable to the current state of the domain.
Definition: VLCSlicedC02Traversal.h:71
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