AutoPas  3.0.0
Loading...
Searching...
No Matches
VarVerletLists.h
Go to the documentation of this file.
1
7#pragma once
8
11
12namespace autopas {
13
19template <class Particle_T, class NeighborList>
20class VarVerletLists : public VerletListsLinkedBase<Particle_T> {
24 using ParticleType = Particle_T;
25
26 public:
36 VarVerletLists(const std::array<double, 3> &boxMin, const std::array<double, 3> &boxMax, const double cutoff,
37 const double skin, const double cellSizeFactor = 1.0)
38 : VerletListsLinkedBase<Particle_T>(boxMin, boxMax, cutoff, skin, cellSizeFactor), _neighborList{} {}
39
43 [[nodiscard]] ContainerOption getContainerType() const override { return _neighborList.getContainerType(); }
44
45 void computeInteractions(TraversalInterface *traversal) override {
46 auto *traversalInterface = dynamic_cast<VVLTraversalInterface<NeighborList> *>(traversal);
47 if (traversalInterface) {
48 traversalInterface->setNeighborListToTraverse(_neighborList);
49 } else {
51 "trying to use a traversal of wrong type in VarVerletLists::computeInteractions");
52 }
53
54 traversal->initTraversal();
55 traversal->traverseParticles();
56 traversal->endTraversal();
57 }
58
63 long getNumberOfNeighborPairs() const { return _neighborList.getNumberOfNeighborPairs(); }
64
65 void rebuildNeighborLists(TraversalInterface *traversal) override {
66 this->_verletBuiltNewton3 = traversal->getUseNewton3();
67 _neighborList.buildAoSNeighborList(this->_linkedCells, traversal->getUseNewton3());
68 // the neighbor list is now valid
69 this->_neighborListIsValid.store(true, std::memory_order_relaxed);
70
71 if (traversal->getDataLayout() == DataLayoutOption::soa and not _neighborList.isSoAListValid()) {
72 _neighborList.generateSoAFromAoS();
73 }
74 }
75
76 private:
77 NeighborList _neighborList;
78};
79
80} // namespace autopas
This interface serves as a common parent class for all traversals.
Definition: TraversalInterface.h:18
virtual void endTraversal()=0
Finalizes the traversal.
virtual void traverseParticles()=0
Traverse the particles by pairs, triplets etc.
virtual void initTraversal()=0
Initializes the traversal.
DataLayoutOption getDataLayout() const
Return the data layout option.
Definition: TraversalInterface.h:69
bool getUseNewton3() const
Return whether the traversal uses newton 3.
Definition: TraversalInterface.h:63
Interface for all traversals for VarVerletLists containers.
Definition: VVLTraversalInterface.h:16
virtual void setNeighborListToTraverse(NeighborList &neighborList)
Sets the neighbor list to traverse.
Definition: VVLTraversalInterface.h:32
Variable Verlet Lists container with different neighbor lists.
Definition: VarVerletLists.h:20
void rebuildNeighborLists(TraversalInterface *traversal) override
Rebuilds the neighbor lists for the next traversals.
Definition: VarVerletLists.h:65
long getNumberOfNeighborPairs() const
Returns the number of neighbor pairs in the list.
Definition: VarVerletLists.h:63
VarVerletLists(const std::array< double, 3 > &boxMin, const std::array< double, 3 > &boxMax, const double cutoff, const double skin, const double cellSizeFactor=1.0)
Constructor of the Variable VerletLists class.
Definition: VarVerletLists.h:36
void computeInteractions(TraversalInterface *traversal) override
Iterates over all particle multiples (e.g.
Definition: VarVerletLists.h:45
ContainerOption getContainerType() const override
Get the ContainerType.
Definition: VarVerletLists.h:43
Base class for Verlet lists which use an underlying linked cells container.
Definition: VerletListsLinkedBase.h:25
bool _verletBuiltNewton3
specifies if the current verlet list was built for newton3
Definition: VerletListsLinkedBase.h:330
std::atomic< bool > _neighborListIsValid
specifies if the neighbor list is currently valid
Definition: VerletListsLinkedBase.h:327
LinkedCells< Particle_T > _linkedCells
internal linked cells storage, handles Particle storage and used to build verlet lists
Definition: VerletListsLinkedBase.h:324
static void exception(const Exception e)
Handle an exception derived by std::exception.
Definition: ExceptionHandler.h:63
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32