AutoPas  3.0.0
Loading...
Searching...
No Matches
VLCNeighborListInterface.h
Go to the documentation of this file.
1
7#pragma once
8
12
13namespace autopas {
18template <class Particle_T>
20 public:
24 virtual ~VLCNeighborListInterface() = default;
25
32 virtual void buildAoSNeighborList(TraversalOption vlcTraversalOpt, LinkedCells<Particle_T> &linkedCells,
33 bool useNewton3) = 0;
34
40 virtual size_t getNumberOfPartners(const Particle_T *particle) const = 0;
41
46 [[nodiscard]] virtual ContainerOption getContainerType() const = 0;
47
54 virtual void generateSoAFromAoS(LinkedCells<Particle_T> &linkedCells) = 0;
55
62 template <class TFunctor>
63 auto *loadSoA(TFunctor *f) {
64 _soa.clear();
65
66 // First resize the SoA to the required number of elements to store. This avoids resizing successively the SoA in
67 // SoALoader.
68 auto &cells = _internalLinkedCells->getCells();
69 std::vector<size_t> offsets(cells.size() + 1);
70 std::inclusive_scan(
71 cells.begin(), cells.end(), offsets.begin() + 1,
72 [](const size_t &partialSum, const auto &cell) { return partialSum + cell.size(); }, 0);
73 _soa.resizeArrays(offsets.back());
74
75 AUTOPAS_OPENMP(parallel for)
76 for (size_t i = 0; i < cells.size(); ++i) {
77 f->SoALoader(cells[i], _soa, offsets[i], /*skipSoAResize*/ true);
78 }
79
80 return &_soa;
81 }
82
88 template <class TFunctor>
89 void extractSoA(TFunctor *f) {
90 size_t offset = 0;
91 for (auto &cell : _internalLinkedCells->getCells()) {
92 f->SoAExtractor(cell, _soa, offset);
93 offset += cell.size();
94 }
95 }
96
104 virtual void setUpTraversal(TraversalInterface *traversal) = 0;
105
110 void setLinkedCellsPointer(LinkedCells<Particle_T> *linkedCells) { this->_internalLinkedCells = linkedCells; }
111
112 protected:
117
122};
123
124} // namespace autopas
#define AUTOPAS_OPENMP(args)
Empty macro to throw away any arguments.
Definition: WrapOpenMP.h:126
LinkedCells class.
Definition: LinkedCells.h:40
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
void clear()
delete all particles in the soa
Definition: SoA.h:186
This interface serves as a common parent class for all traversals.
Definition: TraversalInterface.h:18
Interface of neighbor lists to be used with VerletListsCells container.
Definition: VLCNeighborListInterface.h:19
void setLinkedCellsPointer(LinkedCells< Particle_T > *linkedCells)
Set the Linked Cells Pointer for this List.
Definition: VLCNeighborListInterface.h:110
virtual void generateSoAFromAoS(LinkedCells< Particle_T > &linkedCells)=0
Generates neighbor list in SoA layout from available neighbor list in AoS layout.
SoA< typename Particle_T::SoAArraysType > _soa
Structure of arrays necessary for SoA data layout.
Definition: VLCNeighborListInterface.h:121
void extractSoA(TFunctor *f)
Extracts cells from structure of arrays.
Definition: VLCNeighborListInterface.h:89
virtual ContainerOption getContainerType() const =0
Returns the container type of this neighbor list and the container it belongs to.
virtual size_t getNumberOfPartners(const Particle_T *particle) const =0
Gets the number of neighbors over all neighbor lists that belong to this particle.
virtual ~VLCNeighborListInterface()=default
Virtual default destructor.
auto * loadSoA(TFunctor *f)
Loads cells into structure of arrays.
Definition: VLCNeighborListInterface.h:63
virtual void buildAoSNeighborList(TraversalOption vlcTraversalOpt, LinkedCells< Particle_T > &linkedCells, bool useNewton3)=0
Builds AoS neighbor list from underlying linked cells object.
LinkedCells< Particle_T > * _internalLinkedCells
Internal linked cells structure.
Definition: VLCNeighborListInterface.h:116
virtual void setUpTraversal(TraversalInterface *traversal)=0
Assigns the current traversal to the correct traversal interface.
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32