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> {
21 public:
32 VarVerletLists(const std::array<double, 3> &boxMin, const std::array<double, 3> &boxMax, const double cutoff,
33 const double skin, const unsigned int rebuildFrequency, const double cellSizeFactor = 1.0)
34 : VerletListsLinkedBase<Particle_T>(boxMin, boxMax, cutoff, skin, rebuildFrequency,
35 compatibleTraversals::allVarVLAsBuildCompatibleTraversals(), cellSizeFactor),
36 _neighborList{} {}
37
41 [[nodiscard]] ContainerOption getContainerType() const override { return _neighborList.getContainerType(); }
42
43 void computeInteractions(TraversalInterface *traversal) override {
44 auto *traversalInterface = dynamic_cast<VVLTraversalInterface<NeighborList> *>(traversal);
45 if (traversalInterface) {
46 traversalInterface->setNeighborListToTraverse(_neighborList);
47 } else {
49 "trying to use a traversal of wrong type in VarVerletLists::computeInteractions");
50 }
51
52 traversal->initTraversal();
53 traversal->traverseParticles();
54 traversal->endTraversal();
55 }
56
61 long getNumberOfNeighborPairs() const { return _neighborList.getNumberOfNeighborPairs(); }
62
63 void rebuildNeighborLists(TraversalInterface *traversal) override {
64 this->_verletBuiltNewton3 = traversal->getUseNewton3();
65 _neighborList.buildAoSNeighborList(this->_linkedCells, traversal->getUseNewton3());
66 // the neighbor list is now valid
67 this->_neighborListIsValid.store(true, std::memory_order_relaxed);
68
69 if (traversal->getDataLayout() == DataLayoutOption::soa and not _neighborList.isSoAListValid()) {
70 _neighborList.generateSoAFromAoS();
71 }
72 }
73
74 private:
75 NeighborList _neighborList;
76};
77
78} // 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:63
VarVerletLists(const std::array< double, 3 > &boxMin, const std::array< double, 3 > &boxMax, const double cutoff, const double skin, const unsigned int rebuildFrequency, const double cellSizeFactor=1.0)
Constructor of the Variable VerletLists class.
Definition: VarVerletLists.h:32
long getNumberOfNeighborPairs() const
Returns the number of neighbor pairs in the list.
Definition: VarVerletLists.h:61
void computeInteractions(TraversalInterface *traversal) override
Iterates over all particle multiples (e.g.
Definition: VarVerletLists.h:43
ContainerOption getContainerType() const override
Get the ContainerType.
Definition: VarVerletLists.h:41
Base class for Verlet lists which use an underlying linked cells container.
Definition: VerletListsLinkedBase.h:26
bool _verletBuiltNewton3
specifies if the current verlet list was built for newton3
Definition: VerletListsLinkedBase.h:329
std::atomic< bool > _neighborListIsValid
specifies if the neighbor list is currently valid
Definition: VerletListsLinkedBase.h:326
LinkedCells< Particle_T > _linkedCells
internal linked cells storage, handles Particle storage and used to build verlet lists
Definition: VerletListsLinkedBase.h:323
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