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