AutoPas  3.0.0
Loading...
Searching...
No Matches
VLCC01Traversal.h
Go to the documentation of this file.
1
7#pragma once
8
12
13namespace autopas {
14
25template <class ParticleCell, class PairwiseFunctor, class NeighborList>
26class VLCC01Traversal : public C01BasedTraversal<ParticleCell, PairwiseFunctor, InteractionTypeOption::pairwise>,
27 public VLCTraversalInterface<typename ParticleCell::ParticleType, NeighborList> {
28 public:
40 explicit VLCC01Traversal(const std::array<unsigned long, 3> &dims, PairwiseFunctor *pairwiseFunctor,
41 double interactionLength, const std::array<double, 3> &cellLength,
42 DataLayoutOption dataLayout, bool useNewton3, ContainerOption::Value typeOfList)
43 : C01BasedTraversal<ParticleCell, PairwiseFunctor, InteractionTypeOption::pairwise>(
44 dims, pairwiseFunctor, interactionLength, cellLength, dataLayout, useNewton3),
45 VLCTraversalInterface<typename ParticleCell::ParticleType, NeighborList>(typeOfList),
46 _functor(pairwiseFunctor) {}
47
48 void traverseParticles() override;
49
50 [[nodiscard]] TraversalOption getTraversalType() const override {
51 switch (this->_typeOfList) {
52 case (ContainerOption::verletListsCells):
53 return TraversalOption::vlc_c01;
54 case (ContainerOption::pairwiseVerletLists):
55 return TraversalOption::vlp_c01;
56 default:
57 autopas::utils::ExceptionHandler::exception("Traversal was created with an unsupported neighborlist type: {}",
58 this->_typeOfList.to_string());
59 }
60 // should never be reached.
61 return TraversalOption();
62 }
63
64 [[nodiscard]] bool isApplicable() const override {
65 return (not this->_useNewton3) and
66 (this->_dataLayout == DataLayoutOption::aos or this->_dataLayout == DataLayoutOption::soa);
67 }
68
73 void setSortingThreshold(size_t sortingThreshold) override {}
74
75 private:
76 PairwiseFunctor *_functor;
77};
78
79template <class ParticleCell, class PairwiseFunctor, class NeighborList>
81 if (this->_dataLayout == DataLayoutOption::soa) {
82 this->loadSoA(_functor, *(this->_verletList));
83 }
84
85 this->c01Traversal([&](unsigned long x, unsigned long y, unsigned long z) {
86 unsigned long baseIndex = utils::ThreeDimensionalMapping::threeToOneD(x, y, z, this->_cellsPerDimension);
87 this->template processCellLists<PairwiseFunctor>(*(this->_verletList), baseIndex, _functor, this->_dataLayout,
88 this->_useNewton3);
89 });
90
91 if (this->_dataLayout == DataLayoutOption::soa) {
92 this->extractSoA(_functor, *(this->_verletList));
93 }
94}
95
96} // namespace autopas
This class provides the base for traversals using the c01 base step.
Definition: C01BasedTraversal.h:25
PairwiseFunctor class.
Definition: PairwiseFunctor.h:31
Class for Cells of Particles.
Definition: ParticleCell.h:51
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 class provides the c01 traversal.
Definition: VLCC01Traversal.h:27
TraversalOption getTraversalType() const override
Return a enum representing the name of the traversal class.
Definition: VLCC01Traversal.h:50
VLCC01Traversal(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 c01 traversal.
Definition: VLCC01Traversal.h:40
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: VLCC01Traversal.h:73
void traverseParticles() override
Traverse the particles by pairs, triplets etc.
Definition: VLCC01Traversal.h:80
bool isApplicable() const override
Checks if the traversal is applicable to the current state of the domain.
Definition: VLCC01Traversal.h:64
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