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
36 virtual void buildAoSNeighborList(LinkedCells<Particle_T> &linkedCells, bool useNewton3, double cutoff, double skin,
37 double interactionLength, const TraversalOption vlcTraversalOpt,
38 typename VerletListsCellsHelpers::VLCBuildType buildType) = 0;
39
45 virtual size_t getNumberOfPartners(const Particle_T *particle) const = 0;
46
51 [[nodiscard]] virtual ContainerOption getContainerType() const = 0;
52
59 virtual void generateSoAFromAoS(LinkedCells<Particle_T> &linkedCells) = 0;
60
67 template <class TFunctor>
68 auto *loadSoA(TFunctor *f) {
69 _soa.clear();
70
71 // First resize the SoA to the required number of elements to store. This avoids resizing successively the SoA in
72 // SoALoader.
73 auto &cells = _internalLinkedCells->getCells();
74 std::vector<size_t> offsets(cells.size() + 1);
75 std::inclusive_scan(
76 cells.begin(), cells.end(), offsets.begin() + 1,
77 [](const size_t &partialSum, const auto &cell) { return partialSum + cell.size(); }, 0);
78 _soa.resizeArrays(offsets.back());
79
80 AUTOPAS_OPENMP(parallel for)
81 for (size_t i = 0; i < cells.size(); ++i) {
82 f->SoALoader(cells[i], _soa, offsets[i], /*skipSoAResize*/ true);
83 }
84
85 return &_soa;
86 }
87
93 template <class TFunctor>
94 void extractSoA(TFunctor *f) {
95 size_t offset = 0;
96 for (auto &cell : _internalLinkedCells->getCells()) {
97 f->SoAExtractor(cell, _soa, offset);
98 offset += cell.size();
99 }
100 }
101
109 virtual void setUpTraversal(TraversalInterface *traversal) = 0;
110
115 void setLinkedCellsPointer(LinkedCells<Particle_T> *linkedCells) { this->_internalLinkedCells = linkedCells; }
116
117 protected:
122
127
138 virtual void applyBuildFunctor(LinkedCells<Particle_T> &linkedCells, bool useNewton3, double cutoff, double skin,
139 double interactionLength, const TraversalOption &vlcTraversalOpt,
140 typename VerletListsCellsHelpers::VLCBuildType buildType) = 0;
141};
142
143} // 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:115
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:126
void extractSoA(TFunctor *f)
Extracts cells from structure of arrays.
Definition: VLCNeighborListInterface.h:94
virtual ContainerOption getContainerType() const =0
Returns the container type of this neighbor list and the container it belongs to.
virtual void applyBuildFunctor(LinkedCells< Particle_T > &linkedCells, bool useNewton3, double cutoff, double skin, double interactionLength, const TraversalOption &vlcTraversalOpt, typename VerletListsCellsHelpers::VLCBuildType buildType)=0
Creates and applies a generator functor for the building of the neighbor list.
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:68
virtual void buildAoSNeighborList(LinkedCells< Particle_T > &linkedCells, bool useNewton3, double cutoff, double skin, double interactionLength, const TraversalOption vlcTraversalOpt, typename VerletListsCellsHelpers::VLCBuildType buildType)=0
Builds AoS neighbor list from underlying linked cells object.
LinkedCells< Particle_T > * _internalLinkedCells
Internal linked cells structure.
Definition: VLCNeighborListInterface.h:121
virtual void setUpTraversal(TraversalInterface *traversal)=0
Assigns the current traversal to the correct traversal interface.
VLCBuildType
Indicates which build functor should be used for the generation of the neighbor list.
Definition: VerletListsCellsHelpers.h:44
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32