AutoPas  3.0.0
Loading...
Searching...
No Matches
VLCTraversalInterface.h
Go to the documentation of this file.
1
7#pragma once
8
9#include <array>
10#include <utility>
11#include <vector>
12
15
16namespace autopas {
17
26template <class Particle_T, class NeighborList>
28 public:
29 VLCTraversalInterface() = delete;
30
35 VLCTraversalInterface(ContainerOption typeOfList) : _typeOfList(typeOfList) {}
36
41 virtual void setVerletList(NeighborList &verlet) { _verletList = &verlet; }
42
43 protected:
53 template <class PairwiseFunctor>
54 void processCellLists(NeighborList &neighborLists, unsigned long cellIndex, PairwiseFunctor *pairwiseFunctor,
55 DataLayoutOption dataLayout, bool useNewton3) {
56 processCellListsImpl<PairwiseFunctor>(neighborLists, cellIndex, pairwiseFunctor, dataLayout, useNewton3);
57 }
58
65 template <class PairwiseFunctor>
66 void loadSoA(PairwiseFunctor *pairwiseFunctor, NeighborList &neighborLists) {
67 // send to loadSoA in the neighbor list
68 _soa = neighborLists.loadSoA(pairwiseFunctor);
69 }
70
77 template <class PairwiseFunctor>
78 void extractSoA(PairwiseFunctor *pairwiseFunctor, NeighborList &neighborLists) {
79 // send to extractSoA in the neighbor list
80 neighborLists.extractSoA(pairwiseFunctor);
81 _soa = nullptr;
82 }
83
87 NeighborList *_verletList;
88
93
97 ContainerOption _typeOfList;
98
99 private:
109 template <class PairwiseFunctor>
110 void processCellListsImpl(VLCAllCellsNeighborList<Particle_T> &neighborList, unsigned long cellIndex,
111 PairwiseFunctor *pairwiseFunctor, DataLayoutOption dataLayout, bool useNewton3) {
112 if (dataLayout == DataLayoutOption::aos) {
113 auto &aosList = neighborList.getAoSNeighborList();
114 for (auto &[particlePtr, neighbors] : aosList[cellIndex]) {
115 Particle_T &particle = *particlePtr;
116 for (auto neighborPtr : neighbors) {
117 Particle_T &neighbor = *neighborPtr;
118 pairwiseFunctor->AoSFunctor(particle, neighbor, useNewton3);
119 }
120 }
121 }
122
123 else if (dataLayout == DataLayoutOption::soa) {
124 auto &soaList = neighborList.getSoANeighborList();
125 for (auto &[particleIndex, neighbors] : soaList[cellIndex]) {
126 if (not neighbors.empty()) {
127 pairwiseFunctor->SoAFunctorVerlet(*_soa, particleIndex, neighbors, useNewton3);
128 }
129 }
130 }
131 }
132
142 template <class PairwiseFunctor>
143 void processCellListsImpl(VLCCellPairNeighborList<Particle_T> &neighborList, unsigned long cellIndex,
144 PairwiseFunctor *pairwiseFunctor, DataLayoutOption dataLayout, bool useNewton3) {
145 if (dataLayout == DataLayoutOption::aos) {
146 auto &aosList = neighborList.getAoSNeighborList();
147 for (auto &cellPair : aosList[cellIndex]) {
148 for (auto &[particlePtr, neighbors] : cellPair) {
149 Particle_T &particle = *particlePtr;
150 for (auto neighborPtr : neighbors) {
151 Particle_T &neighbor = *neighborPtr;
152 pairwiseFunctor->AoSFunctor(particle, neighbor, useNewton3);
153 }
154 }
155 }
156 }
157
158 else if (dataLayout == DataLayoutOption::soa) {
159 auto &soaList = neighborList.getSoANeighborList();
160 // iterate over soa and call soaFunctorVerlet for each of the neighbor lists
161 for (auto &cellPair : soaList[cellIndex]) {
162 for (auto &[particleIndex, neighbors] : cellPair) {
163 if (not neighbors.empty()) {
164 pairwiseFunctor->SoAFunctorVerlet(*_soa, particleIndex, neighbors, useNewton3);
165 }
166 }
167 }
168 }
169 }
170};
171
172} // namespace autopas
PairwiseFunctor class.
Definition: PairwiseFunctor.h:31
virtual void AoSFunctor(Particle_T &i, Particle_T &j, bool newton3)
PairwiseFunctor for arrays of structures (AoS).
Definition: PairwiseFunctor.h:56
virtual void SoAFunctorVerlet(SoAView< SoAArraysType > soa, const size_t indexFirst, const std::vector< size_t, AlignedAllocator< size_t > > &neighborList, bool newton3)
PairwiseFunctor for structure of arrays (SoA) for neighbor lists.
Definition: PairwiseFunctor.h:86
Structur of the array class.
Definition: SoA.h:28
Neighbor list to be used with VerletListsCells container.
Definition: VLCAllCellsNeighborList.h:38
VerletListsCellsHelpers::AllCellsNeighborListsType< Particle_T > & getAoSNeighborList()
Returns the neighbor list in AoS layout.
Definition: VLCAllCellsNeighborList.h:162
auto & getSoANeighborList()
Returns the neighbor list in SoA layout.
Definition: VLCAllCellsNeighborList.h:170
Neighbor list to be used with VerletListsCells container.
Definition: VLCCellPairNeighborList.h:31
auto & getSoANeighborList()
Returns the neighbor list in SoA layout.
Definition: VLCCellPairNeighborList.h:80
VerletListsCellsHelpers::PairwiseNeighborListsType< Particle_T > & getAoSNeighborList()
Returns the neighbor list in AoS layout.
Definition: VLCCellPairNeighborList.h:64
This class provides the Traversal Interface for the verlet lists cells container.
Definition: VLCTraversalInterface.h:27
VLCTraversalInterface(ContainerOption typeOfList)
Constructor of the VLCTraversalInterface.
Definition: VLCTraversalInterface.h:35
NeighborList * _verletList
The verlet list to iterate over.
Definition: VLCTraversalInterface.h:87
ContainerOption _typeOfList
The type of neighbor list as an enum value.
Definition: VLCTraversalInterface.h:97
void extractSoA(PairwiseFunctor *pairwiseFunctor, NeighborList &neighborLists)
Extract the SoA from the respective neighbor list.
Definition: VLCTraversalInterface.h:78
void processCellLists(NeighborList &neighborLists, unsigned long cellIndex, PairwiseFunctor *pairwiseFunctor, DataLayoutOption dataLayout, bool useNewton3)
Iterate over all neighbor lists list of a given cell.
Definition: VLCTraversalInterface.h:54
virtual void setVerletList(NeighborList &verlet)
Sets the verlet list for the traversal to iterate over.
Definition: VLCTraversalInterface.h:41
void loadSoA(PairwiseFunctor *pairwiseFunctor, NeighborList &neighborLists)
Load the SoA from the respective neighbor list.
Definition: VLCTraversalInterface.h:66
SoA< typename Particle_T::SoAArraysType > * _soa
Structure of arrays to be used if the data layout is SoA.
Definition: VLCTraversalInterface.h:92
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32