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
14
15namespace autopas {
16
23template <class Particle_T>
24class VLCAllCellsNeighborList;
25
26template <class Particle_T>
27class VLCCellPairNeighborList;
28
37template <class Particle_T, class NeighborList>
39 public:
40 VLCTraversalInterface() = delete;
41
46 VLCTraversalInterface(ContainerOption typeOfList) : _typeOfList(typeOfList) {}
47
52 virtual void setVerletList(NeighborList &verlet) { _verletList = &verlet; }
53
54 protected:
64 template <class PairwiseFunctor>
65 void processCellLists(NeighborList &neighborLists, unsigned long cellIndex, PairwiseFunctor *pairwiseFunctor,
66 DataLayoutOption dataLayout, bool useNewton3) {
67 processCellListsImpl<PairwiseFunctor>(neighborLists, cellIndex, pairwiseFunctor, dataLayout, useNewton3);
68 }
69
76 template <class PairwiseFunctor>
77 void loadSoA(PairwiseFunctor *pairwiseFunctor, NeighborList &neighborLists) {
78 // send to loadSoA in the neighbor list
79 _soa = neighborLists.loadSoA(pairwiseFunctor);
80 }
81
88 template <class PairwiseFunctor>
89 void extractSoA(PairwiseFunctor *pairwiseFunctor, NeighborList &neighborLists) {
90 // send to extractSoA in the neighbor list
91 neighborLists.extractSoA(pairwiseFunctor);
92 _soa = nullptr;
93 }
94
98 NeighborList *_verletList;
99
104
108 ContainerOption _typeOfList;
109
110 private:
120 template <class PairwiseFunctor>
121 void processCellListsImpl(VLCAllCellsNeighborList<Particle_T> &neighborList, unsigned long cellIndex,
122 PairwiseFunctor *pairwiseFunctor, DataLayoutOption dataLayout, bool useNewton3) {
123 if (dataLayout == DataLayoutOption::aos) {
124 auto &aosList = neighborList.getAoSNeighborList();
125 for (auto &[particlePtr, neighbors] : aosList[cellIndex]) {
126 Particle_T &particle = *particlePtr;
127 for (auto neighborPtr : neighbors) {
128 Particle_T &neighbor = *neighborPtr;
129 pairwiseFunctor->AoSFunctor(particle, neighbor, useNewton3);
130 }
131 }
132 }
133
134 else if (dataLayout == DataLayoutOption::soa) {
135 auto &soaList = neighborList.getSoANeighborList();
136 for (auto &[particleIndex, neighbors] : soaList[cellIndex]) {
137 if (not neighbors.empty()) {
138 pairwiseFunctor->SoAFunctorVerlet(*_soa, particleIndex, neighbors, useNewton3);
139 }
140 }
141 }
142 }
143
153 template <class PairwiseFunctor>
154 void processCellListsImpl(VLCCellPairNeighborList<Particle_T> &neighborList, unsigned long cellIndex,
155 PairwiseFunctor *pairwiseFunctor, DataLayoutOption dataLayout, bool useNewton3) {
156 if (dataLayout == DataLayoutOption::aos) {
157 auto &aosList = neighborList.getAoSNeighborList();
158 for (auto &cellPair : aosList[cellIndex]) {
159 for (auto &[particlePtr, neighbors] : cellPair) {
160 Particle_T &particle = *particlePtr;
161 for (auto neighborPtr : neighbors) {
162 Particle_T &neighbor = *neighborPtr;
163 pairwiseFunctor->AoSFunctor(particle, neighbor, useNewton3);
164 }
165 }
166 }
167 }
168
169 else if (dataLayout == DataLayoutOption::soa) {
170 auto &soaList = neighborList.getSoANeighborList();
171 // iterate over soa and call soaFunctorVerlet for each of the neighbor lists
172 for (auto &cellPair : soaList[cellIndex]) {
173 for (auto &[particleIndex, neighbors] : cellPair) {
174 if (not neighbors.empty()) {
175 pairwiseFunctor->SoAFunctorVerlet(*_soa, particleIndex, neighbors, useNewton3);
176 }
177 }
178 }
179 }
180 }
181};
182
183} // 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:27
VerletListsCellsHelpers::AllCellsNeighborListsType< Particle_T > & getAoSNeighborList()
Returns the neighbor list in AoS layout.
Definition: VLCAllCellsNeighborList.h:274
auto & getSoANeighborList()
Returns the neighbor list in SoA layout.
Definition: VLCAllCellsNeighborList.h:282
Neighbor list to be used with VerletListsCells container.
Definition: VLCCellPairNeighborList.h:23
auto & getSoANeighborList()
Returns the neighbor list in SoA layout.
Definition: VLCCellPairNeighborList.h:81
VerletListsCellsHelpers::PairwiseNeighborListsType< Particle_T > & getAoSNeighborList()
Returns the neighbor list in AoS layout.
Definition: VLCCellPairNeighborList.h:73
This class provides the Traversal Interface for the verlet lists cells container.
Definition: VLCTraversalInterface.h:38
VLCTraversalInterface(ContainerOption typeOfList)
Constructor of the VLCTraversalInterface.
Definition: VLCTraversalInterface.h:46
NeighborList * _verletList
The verlet list to iterate over.
Definition: VLCTraversalInterface.h:98
ContainerOption _typeOfList
The type of neighbor list as an enum value.
Definition: VLCTraversalInterface.h:108
void extractSoA(PairwiseFunctor *pairwiseFunctor, NeighborList &neighborLists)
Extract the SoA from the respective neighbor list.
Definition: VLCTraversalInterface.h:89
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:65
virtual void setVerletList(NeighborList &verlet)
Sets the verlet list for the traversal to iterate over.
Definition: VLCTraversalInterface.h:52
void loadSoA(PairwiseFunctor *pairwiseFunctor, NeighborList &neighborLists)
Load the SoA from the respective neighbor list.
Definition: VLCTraversalInterface.h:77
SoA< typename Particle_T::SoAArraysType > * _soa
Structure of arrays to be used if the data layout is SoA.
Definition: VLCTraversalInterface.h:103
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32