23template <
class ParticleCell_T,
class PairwiseFunctor_T>
25 using ParticleType = ParticleCell_T::ParticleType;
36 const std::array<unsigned long, 3> &cellsPerDim)
37 :
TraversalInterface(dataLayout, useNewton3), _functor(pairwiseFunctor), _cellsPerDim(cellsPerDim) {}
39 [[nodiscard]] TraversalOption
getTraversalType()
const override {
return TraversalOption::vl_list_iteration_c27; }
48 auto &cells = *(this->
_cells);
52 std::vector<size_t> offsets(cells.size() + 1);
54 for (
size_t c = 0; c < cells.size(); ++c) {
55 offsets[c + 1] = offsets[c] + cells[c].size();
59 for (
auto &colorGroup : _colorCells) {
63 for (
size_t c = 0; c < cells.size(); ++c) {
64 if (offsets[c] < offsets[c + 1]) {
66 const size_t color = (c3D[0] % 3) + 3 * (c3D[1] % 3) + 9 * (c3D[2] % 3);
67 _colorCells[color].push_back({offsets[c], offsets[c + 1]});
75 for (
size_t i = 0; i < cells.size(); ++i) {
76 _functor.SoALoader(cells[i], _soa, offsets[i],
true);
82 auto &cells = *(this->
_cells);
85 for (
auto &cell : cells) {
86 _functor.SoAExtractor(cell, _soa, offset);
87 offset += cell.size();
97 case DataLayoutOption::aos: {
99 for (
int color = 0; color < 27; ++color) {
100 const auto &cellsOfColor = _colorCells[color];
102 for (
size_t c = 0; c < cellsOfColor.size(); ++c) {
103 const auto &range = cellsOfColor[c];
104 for (
size_t i = range.first; i < range.second; ++i) {
105 ParticleType &particleI = *indexToParticle[i];
106 const size_t numNeighbors = neighborList.count(i);
107 const size_t *neighborsIPtr = neighborList.begin(i);
108 for (
size_t j = 0; j < numNeighbors; ++j) {
109 _functor.AoSFunctor(particleI, *indexToParticle[neighborsIPtr[j]],
_useNewton3);
117 case DataLayoutOption::soa: {
119 for (
int color = 0; color < 27; ++color) {
120 const auto &cellsOfColor = _colorCells[color];
122 for (
size_t c = 0; c < cellsOfColor.size(); ++c) {
123 const auto &range = cellsOfColor[c];
124 for (
size_t i = range.first; i < range.second; ++i) {
125 _functor.SoAFunctorVerlet(_soa, i, neighborList.getNeighbors(i),
_useNewton3);
141 PairwiseFunctor_T &_functor;
151 std::array<unsigned long, 3> _cellsPerDim;
156 std::array<std::vector<std::pair<size_t, size_t>>, 27> _colorCells;
#define AUTOPAS_OPENMP(args)
Empty macro to throw away any arguments.
Definition: WrapOpenMP.h:126
Structur of the array class.
Definition: SoA.h:28
void resizeArrays(size_t length)
Resizes all Vectors to the given length.
Definition: SoA.h:45
This interface serves as a common parent class for all traversals.
Definition: TraversalInterface.h:18
DataLayoutOption _dataLayout
The datalayout used by this traversal.
Definition: TraversalInterface.h:77
bool _useNewton3
If this traversal makes use of newton3.
Definition: TraversalInterface.h:82
This class provides a colored Traversal for the verlet lists container.
Definition: VLListIterationC27Traversal.h:24
bool isApplicableToDomain() const override
VL List iteration C27 is always applicable to the domain.
Definition: VLListIterationC27Traversal.h:45
void endTraversal() override
Finalizes the traversal.
Definition: VLListIterationC27Traversal.h:81
VLListIterationC27Traversal(PairwiseFunctor_T &pairwiseFunctor, DataLayoutOption dataLayout, bool useNewton3, const std::array< unsigned long, 3 > &cellsPerDim)
Constructor for colored Verlet Traversal.
Definition: VLListIterationC27Traversal.h:35
TraversalOption getTraversalType() const override
Return a enum representing the name of the traversal class.
Definition: VLListIterationC27Traversal.h:39
void initTraversal() override
Initializes the traversal.
Definition: VLListIterationC27Traversal.h:47
void traverseParticles() override
Traverse the particles by pairs, triplets etc.
Definition: VLListIterationC27Traversal.h:92
This class provides the Traversal Interface for the verlet lists container.
Definition: VLTraversalInterface.h:22
const std::vector< ParticleType * > * _indexToParticle
Vector mapping SoA indices to particle pointers.
Definition: VLTraversalInterface.h:69
std::vector< ParticleCell_T > * _cells
The cells of the underlying linked cells container of the verlet lists container.
Definition: VLTraversalInterface.h:52
VerletListHelpers< ParticleType >::NeighborListCRS * _neighborList
The flat CRS neighbor list.
Definition: VLTraversalInterface.h:57
static void exception(const Exception e)
Handle an exception derived by std::exception.
Definition: ExceptionHandler.h:64
constexpr std::array< T, 3 > oneToThreeD(T ind, const std::array< T, 3 > &dims)
Convert a 1d index to a 3d index.
Definition: ThreeDimensionalMapping.h:55
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:34