AutoPas  3.0.0
Loading...
Searching...
No Matches
LCC08CellHandler.h
Go to the documentation of this file.
1
7#pragma once
8
13
14namespace autopas {
15
27template <class ParticleCell, class PairwiseFunctor>
29 public:
42 explicit LCC08CellHandler(PairwiseFunctor *pairwiseFunctor, const std::array<unsigned long, 3> &cellsPerDimension,
43 double interactionLength, const std::array<double, 3> &cellLength,
44 const std::array<unsigned long, 3> &overlap, DataLayoutOption dataLayout, bool useNewton3)
45 : _cellFunctor(pairwiseFunctor, interactionLength /*should use cutoff here, if not used to build verlet-lists*/,
46 dataLayout, useNewton3),
47 _interactionLength(interactionLength),
48 _cellLength(cellLength),
49 _overlap(overlap),
50 _dataLayout(dataLayout),
51 _useNewton3(useNewton3),
52 _cellPairOffsets{LCC08CellHandlerUtility::computePairwiseCellOffsetsC08<
53 LCC08CellHandlerUtility::C08OffsetMode::c08CellPairsSorting>(cellsPerDimension, cellLength,
54 interactionLength)} {}
55
62 void processBaseCell(std::vector<ParticleCell> &cells, unsigned long baseIndex);
63
67 void setSortingThreshold(size_t sortingThreshold) { _cellFunctor.setSortingThreshold(sortingThreshold); }
68
69 protected:
74 std::vector<LCC08CellHandlerUtility::OffsetPairSorting> _cellPairOffsets;
75
79 const std::array<unsigned long, 3> _overlap;
80
84 DataLayoutOption _dataLayout;
85
90
91 private:
96 /*bidirectional*/ true>
97 _cellFunctor;
98
102 const double _interactionLength;
103
107 const std::array<double, 3> _cellLength;
108};
109
110template <class ParticleCell, class PairwiseFunctor>
111inline void LCC08CellHandler<ParticleCell, PairwiseFunctor>::processBaseCell(std::vector<ParticleCell> &cells,
112 unsigned long baseIndex) {
113 for (auto const &[offset1, offset2, r] : _cellPairOffsets) {
114 const unsigned long cellIndex1 = baseIndex + offset1;
115 const unsigned long cellIndex2 = baseIndex + offset2;
116
117 ParticleCell &cell1 = cells[cellIndex1];
118 ParticleCell &cell2 = cells[cellIndex2];
119
120 if (cellIndex1 == cellIndex2) {
121 this->_cellFunctor.processCell(cell1);
122 } else {
123 this->_cellFunctor.processCellPair(cell1, cell2, r);
124 }
125 }
126}
127
128} // namespace autopas
This class provides the base for traversals using the c08 base step.
Definition: LCC08CellHandler.h:28
void setSortingThreshold(size_t sortingThreshold)
Set the sorting-threshold for traversals that use the CellFunctor If the sum of the number of particl...
Definition: LCC08CellHandler.h:67
LCC08CellHandler(PairwiseFunctor *pairwiseFunctor, const std::array< unsigned long, 3 > &cellsPerDimension, double interactionLength, const std::array< double, 3 > &cellLength, const std::array< unsigned long, 3 > &overlap, DataLayoutOption dataLayout, bool useNewton3)
Constructor of the LCC08CellHandler.
Definition: LCC08CellHandler.h:42
const std::array< unsigned long, 3 > _overlap
Overlap of interacting cells.
Definition: LCC08CellHandler.h:79
void processBaseCell(std::vector< ParticleCell > &cells, unsigned long baseIndex)
Computes one interaction for each spacial direction based on the lower left frontal corner (=base ind...
Definition: LCC08CellHandler.h:111
DataLayoutOption _dataLayout
The datalayout to be used.
Definition: LCC08CellHandler.h:84
std::vector< LCC08CellHandlerUtility::OffsetPairSorting > _cellPairOffsets
Pair sets for processBaseCell().
Definition: LCC08CellHandler.h:74
bool _useNewton3
If newton3 should be used or not.
Definition: LCC08CellHandler.h:89
PairwiseFunctor class.
Definition: PairwiseFunctor.h:31
Class for Cells of Particles.
Definition: ParticleCell.h:51
A cell functor.
Definition: CellFunctor.h:25
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32