AutoPas  3.0.0
Loading...
Searching...
No Matches
VLCSlicedBalancedTraversal.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <algorithm>
11
17
18namespace autopas {
19
34template <class ParticleCell, class PairwiseFunctor, class NeighborList>
35class VLCSlicedBalancedTraversal : public SlicedBalancedBasedTraversal<ParticleCell, PairwiseFunctor>,
36 public VLCTraversalInterface<typename ParticleCell::ParticleType, NeighborList> {
37 public:
49 explicit VLCSlicedBalancedTraversal(const std::array<unsigned long, 3> &dims, PairwiseFunctor *pairwiseFunctor,
50 double interactionLength, const std::array<double, 3> &cellLength,
51 DataLayoutOption dataLayout, bool useNewton3, ContainerOption::Value typeOfList)
52 : SlicedBalancedBasedTraversal<ParticleCell, PairwiseFunctor>(dims, pairwiseFunctor, interactionLength,
53 cellLength, dataLayout, useNewton3, false),
54 VLCTraversalInterface<typename ParticleCell::ParticleType, NeighborList>(typeOfList),
55 _functor(pairwiseFunctor) {}
56
57 void traverseParticles() override;
58
59 [[nodiscard]] TraversalOption getTraversalType() const override {
60 switch (this->_typeOfList) {
61 case (ContainerOption::verletListsCells):
62 return TraversalOption::vlc_sliced_balanced;
63 case (ContainerOption::pairwiseVerletLists):
64 return TraversalOption::vlp_sliced_balanced;
65 default:
66 autopas::utils::ExceptionHandler::exception("Traversal was created with an unsupported neighborlist type: {}",
67 this->_typeOfList.to_string());
68 }
69 // should never be reached.
70 return TraversalOption();
71 }
72
73 [[nodiscard]] bool isApplicable() const override {
74 return (this->_dataLayout == DataLayoutOption::aos or this->_dataLayout == DataLayoutOption::soa);
75 }
76
81 void setSortingThreshold(size_t sortingThreshold) override {}
82
83 private:
84 PairwiseFunctor *_functor;
85};
86
87template <class ParticleCell, class PairwiseFunctor, class NeighborList>
89 if (this->_dataLayout == DataLayoutOption::soa) {
90 this->loadSoA(_functor, *(this->_verletList));
91 }
92
93 this->slicedTraversal([&](unsigned long x, unsigned long y, unsigned long z) {
94 auto baseIndex = utils::ThreeDimensionalMapping::threeToOneD(x, y, z, this->_cellsPerDimension);
95 this->template processCellLists<PairwiseFunctor>(*(this->_verletList), baseIndex, _functor, this->_dataLayout,
96 this->_useNewton3);
97 });
98
99 if (this->_dataLayout == DataLayoutOption::soa) {
100 this->extractSoA(_functor, *(this->_verletList));
101 }
102}
103
104} // namespace autopas
PairwiseFunctor class.
Definition: PairwiseFunctor.h:31
Class for Cells of Particles.
Definition: ParticleCell.h:51
This class provides a load balanced version of the base sliced traversal.
Definition: SlicedBalancedBasedTraversal.h:30
DataLayoutOption _dataLayout
The datalayout used by this traversal.
Definition: TraversalInterface.h:75
This class provides the balanced sliced traversal.
Definition: VLCSlicedBalancedTraversal.h:36
bool isApplicable() const override
Checks if the traversal is applicable to the current state of the domain.
Definition: VLCSlicedBalancedTraversal.h:73
TraversalOption getTraversalType() const override
Return a enum representing the name of the traversal class.
Definition: VLCSlicedBalancedTraversal.h:59
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: VLCSlicedBalancedTraversal.h:81
void traverseParticles() override
Traverse the particles by pairs, triplets etc.
Definition: VLCSlicedBalancedTraversal.h:88
VLCSlicedBalancedTraversal(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 balanced sliced traversal.
Definition: VLCSlicedBalancedTraversal.h:49
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