AutoPas  3.0.0
Loading...
Searching...
No Matches
OTTraversalInterface.h
Go to the documentation of this file.
1
8#pragma once
9
15
16namespace autopas {
17
21template <typename ParticleCell>
26 using ParticleType = typename ParticleCell::ParticleType;
27
28 public:
36 OTTraversalInterface(double interactionLength, DataLayoutOption dataLayout, bool useNewton3)
37 : TraversalInterface(dataLayout, useNewton3), _interactionLength(interactionLength) {}
38
43 void setCells(std::vector<OctreeNodeWrapper<ParticleType>> *cells) { _cells = cells; }
44
45 protected:
53 template <typename PairwiseFunctor>
55 OctreeNodeWrapper<ParticleType> *wrapper, std::vector<OctreeLeafNode<ParticleType> *> &leaves) {
56 wrapper->appendAllLeaves(leaves);
57
58 for (OctreeLeafNode<ParticleType> *leaf : leaves) {
59 dataLayoutConverter.loadDataLayout(*leaf);
60 }
61 }
62
69 template <typename PairwiseFunctor>
71 std::vector<OctreeLeafNode<ParticleType> *> &leaves) {
72 for (OctreeLeafNode<ParticleType> *leaf : leaves) {
73 dataLayoutConverter.storeDataLayout(*leaf);
74 }
75
76 // Remove the cached leaves
77 leaves.clear();
78 }
79
85 OctreeNodeWrapper<ParticleType> *getOwned() { return dynamic_cast<OctreeNodeWrapper<ParticleType> *>(&(*_cells)[0]); }
86
92 OctreeNodeWrapper<ParticleType> *getHalo() { return dynamic_cast<OctreeNodeWrapper<ParticleType> *>(&(*_cells)[1]); }
93
98 std::vector<OctreeNodeWrapper<ParticleType>> *_cells;
99
103 std::vector<OctreeLeafNode<ParticleType> *> _ownedLeaves;
104
108 std::vector<OctreeLeafNode<ParticleType> *> _haloLeaves;
109
114};
115
116} // namespace autopas
This interface exists to provide a row interface for octree to add its cells.
Definition: OTTraversalInterface.h:22
std::vector< OctreeLeafNode< ParticleType > * > _ownedLeaves
A list of all leaves in the owned octree.
Definition: OTTraversalInterface.h:103
OctreeNodeWrapper< ParticleType > * getOwned()
Get the octree cell that contains the owned octree.
Definition: OTTraversalInterface.h:85
std::vector< OctreeLeafNode< ParticleType > * > _haloLeaves
A list of all leaves in the halo octree.
Definition: OTTraversalInterface.h:108
std::vector< OctreeNodeWrapper< ParticleType > > * _cells
A list containing two cells.
Definition: OTTraversalInterface.h:98
double _interactionLength
The interaction length is used for finding neighbors.
Definition: OTTraversalInterface.h:113
OTTraversalInterface(double interactionLength, DataLayoutOption dataLayout, bool useNewton3)
Create a new traversal interface, which provides functionality that is required by all octree travers...
Definition: OTTraversalInterface.h:36
void loadBuffers(utils::DataLayoutConverter< PairwiseFunctor > &dataLayoutConverter, OctreeNodeWrapper< ParticleType > *wrapper, std::vector< OctreeLeafNode< ParticleType > * > &leaves)
Gather all leaves and load the SoA/AoS buffers.
Definition: OTTraversalInterface.h:54
void setCells(std::vector< OctreeNodeWrapper< ParticleType > > *cells)
Notify the traversal about the cells that it is able to traverse.
Definition: OTTraversalInterface.h:43
OctreeNodeWrapper< ParticleType > * getHalo()
Get the octree cell that contains the halo octree.
Definition: OTTraversalInterface.h:92
void unloadBuffers(utils::DataLayoutConverter< PairwiseFunctor > &dataLayoutConverter, std::vector< OctreeLeafNode< ParticleType > * > &leaves)
Unload the SoA/AoS buffers and clear the gathered leaves list.
Definition: OTTraversalInterface.h:70
An octree leaf node.
Definition: OctreeLeafNode.h:27
This class wraps the functionality provided by the octree leaves and inner nodes in a structure that ...
Definition: OctreeNodeWrapper.h:37
void appendAllLeaves(std::vector< OctreeLeafNode< Particle_T > * > &leaves)
Append all leaves in the octree to a list.
Definition: OctreeNodeWrapper.h:81
Particle_T ParticleType
The particle type for this cell.
Definition: ParticleCell.h:56
This interface serves as a common parent class for all traversals.
Definition: TraversalInterface.h:18
This converts cells to the target data Layout using the given functor.
Definition: DataLayoutConverter.h:19
void loadDataLayout(ParticleCell &cell)
loads the target dataLayout in a cell
Definition: DataLayoutConverter.h:36
void storeDataLayout(ParticleCell &cell)
converts the dataLayout to aos
Definition: DataLayoutConverter.h:55
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32