AutoPas  3.0.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
autopas::LCC01Traversal< ParticleCell, Functor, combineSoA > Class Template Reference

This class provides the c01 traversal and the c01 traversal with combined SoA buffers. More...

#include <LCC01Traversal.h>

Inheritance diagram for autopas::LCC01Traversal< ParticleCell, Functor, combineSoA >:
Inheritance graph
[legend]
Collaboration diagram for autopas::LCC01Traversal< ParticleCell, Functor, combineSoA >:
Collaboration graph
[legend]

Public Member Functions

 LCC01Traversal (const std::array< unsigned long, 3 > &dims, Functor *functor, const double interactionLength, const std::array< double, 3 > &cellLength, DataLayoutOption dataLayout, bool useNewton3)
 Constructor of the c01 traversal.
 
void computeOffsets ()
 Computes all combinations of cells used in processBaseCell()
 
void traverseParticles () override
 Traverse the particles by pairs, triplets etc.
 
bool isApplicable () const override
 C01 traversals are only usable if useNewton3 is disabled and combined SoA buffers are only applicable if SoA is set as DataLayout.
 
TraversalOption getTraversalType () const override
 Return a enum representing the name of the traversal class.
 
void setSortingThreshold (size_t sortingThreshold) override
 Set the sorting-threshold for traversals that use the CellFunctor If the sum of the number of particles in two cells is greater or equal to that value, the CellFunctor creates a sorted view of the particles to avoid unnecessary distance checks.
 
- Public Member Functions inherited from autopas::C01BasedTraversal< ParticleCell, Functor, collapseDepth >
 C01BasedTraversal (const std::array< unsigned long, 3 > &dims, Functor *functor, double interactionLength, const std::array< double, 3 > &cellLength, DataLayoutOption dataLayout, bool useNewton3)
 Constructor of the c01 traversal.
 
- Public Member Functions inherited from autopas::ColorBasedTraversal< ParticleCell, Functor, collapseDepth >
void initTraversal () override
 load Data Layouts required for this Traversal if cells have been set through setCellsToTraverse().
 
void endTraversal () override
 write Data to AoS if cells have been set through setCellsToTraverse().
 
- Public Member Functions inherited from autopas::CellTraversal< ParticleCell >
 CellTraversal (const std::array< unsigned long, 3 > &dims)
 Constructor of CellTraversal.
 
virtual ~CellTraversal ()=default
 Destructor of CellTraversal.
 
virtual void setCellsToTraverse (std::vector< ParticleCell > &cells)
 Sets the cells to iterate over.
 
virtual void setSortingThreshold (size_t sortingThreshold)=0
 Set the sorting-threshold for traversals that use the CellFunctor If the sum of the number of particles in two cells is greater or equal to that value, the CellFunctor creates a sorted view of the particles to avoid unnecessary distance checks.
 
- Public Member Functions inherited from autopas::TraversalInterface
virtual ~TraversalInterface ()=default
 Destructor of TraversalInterface.
 
 TraversalInterface (DataLayoutOption dataLayout, bool useNewton3)
 Constructor of the TraversalInterface.
 
virtual TraversalOption getTraversalType () const =0
 Return a enum representing the name of the traversal class.
 
virtual bool isApplicable () const =0
 Checks if the traversal is applicable to the current state of the domain.
 
virtual void initTraversal ()=0
 Initializes the traversal.
 
virtual void traverseParticles ()=0
 Traverse the particles by pairs, triplets etc.
 
virtual void endTraversal ()=0
 Finalizes the traversal.
 
bool getUseNewton3 () const
 Return whether the traversal uses newton 3.
 
DataLayoutOption getDataLayout () const
 Return the data layout option.
 

Additional Inherited Members

- Protected Member Functions inherited from autopas::C01BasedTraversal< ParticleCell, Functor, collapseDepth >
template<typename LoopBody >
void c01Traversal (LoopBody &&loopBody)
 The main traversal of the C01Traversal.
 
- Protected Member Functions inherited from autopas::ColorBasedTraversal< ParticleCell, Functor, collapseDepth >
 ColorBasedTraversal (const std::array< unsigned long, 3 > &dims, Functor *functor, const double interactionLength, const std::array< double, 3 > &cellLength, DataLayoutOption dataLayout, bool useNewton3)
 Constructor of the ColorBasedTraversal.
 
 ~ColorBasedTraversal () override=default
 Destructor of ColorBasedTraversal.
 
template<typename LoopBody >
void colorTraversal (LoopBody &&loopBody, const std::array< unsigned long, 3 > &end, const std::array< unsigned long, 3 > &stride, const std::array< unsigned long, 3 > &offset={0ul, 0ul, 0ul})
 The main traversal of the ColorBasedTraversal.
 
virtual void notifyColorChange (unsigned long newColor)
 This method is called when the color during the traversal has changed.
 
- Protected Attributes inherited from autopas::ColorBasedTraversal< ParticleCell, Functor, collapseDepth >
const double _interactionLength
 Interaction length (cutoff + skin).
 
const std::array< double, 3 > _cellLength
 cell length in CellBlock3D.
 
std::array< unsigned long, 3 > _overlap
 overlap of interacting cells.
 
- Protected Attributes inherited from autopas::CellTraversal< ParticleCell >
std::array< unsigned long, 3 > _cellsPerDimension
 The dimensions of the cellblock.
 
std::vector< ParticleCell > * _cells
 The cells to traverse.
 
- Protected Attributes inherited from autopas::TraversalInterface
DataLayoutOption _dataLayout
 The datalayout used by this traversal.
 
bool _useNewton3
 If this traversal makes use of newton3.
 

Detailed Description

template<class ParticleCell, class Functor, bool combineSoA = false>
class autopas::LCC01Traversal< ParticleCell, Functor, combineSoA >

This class provides the c01 traversal and the c01 traversal with combined SoA buffers.

The traversal uses the c01 base step performed on every single cell.

C01 base step in 2D. (dark blue cell = base cell)

newton3 cannot be applied! If combineSoA equals true, SoA buffers are combined slice-wise, as described below. Note: combineSoA is only implemented for pairwise Functors at the moment!

Each slice is constructed as FIFO buffer and slices are stored in circular buffer (_combinationSlices).

Combination Principle

The sphere of interacting cells is divided into slices along the y-axis, as seen in Figure 1. Each slice represents a combined SoA buffer. We assume that the creation of combined SoA buffers starts at the first evaluated cell of an axis. Since there is no previously evaluated cell on the beginning of the axis, the whole buffer is initially filled by copying the data from the cells. The combined SoA buffers are stored in a circular/ring buffer (_combinationSlices), shown in Figure 2. To keep track of the position of the first slice inside the circular buffer, an additional variable for the start index (_currentSlices) is necessary which is initialized to zero. Inside the combined SoA buffer, the particles are ordered according their insertion. Note, that the base cell (dark blue) always represents the first cell in the slice buffer.

Now, all interactions can be calculated by iterating over all slices and compute the interactions with the current base cell. Since information in the buffers is not persistent, it is important to use the SoA buffer of the base cell and not the copy inside of the combined buffer. If the current base cell interacts with the slice which contains a copy of the base cell, it is necessary to exclude the copy from the calculations. Otherwise, particles would interact with themselves. It is not possible to remove the copy from the buffer slice, since the current base cell is an interacting cell of the next base cell. Therefore, the SoA data structure defines a custom view on the underlying data structure. Since the copy of the current base cell is the first cell in the buffer slice, it is possible to set the start of the view to the first particle after the base cell.

In the next step, the sphere of interactions moves one cell further. Figure 1 shows that most of the new and old interaction cells are the same. To reduce the number of copies, we'll keep the combined SoA buffers from the previous step and only apply an update to them. Here, the symmetry of interactions can be exploited. Each combined SoA buffer is a LIFO (Last In, First Out) buffer, meaning that they are demolished in the reverse order of their construction. This effect can be seen as well in the circular buffer (Figure 2). The former leftmost slice goes completely out of scope and can be deleted from the circular buffer. The position of this slice inside the circular buffer is represented by the start index inside the buffer. At the same time, a new SoA buffer is created to represent the rightmost slice, which has just entered the interaction sphere. This slice is written on the same index inside the SoA buffer as the former leftmost slice. Since the first slice has moved inside the circular buffer, the start index is incremented. Due to the circular characteristics, an additional modulo operation is applied to the start index to jump back to the first slice in the ring buffer if the end is reached. At this point, the buffer is fully updated and all interactions can be evaluated. This procedure is repeated until the end of the axis is reached.

Since the offsets of the interacting cells relative to the base cell do not change during the traversal, they can be computed beforehand. All offsets are stored in a 2D-array (_cellOffsets) where the first dimension represents the individual slices of the interaction sphere and the second dimension represents the cell offsets inside the slice. The cell offsets are sorted to resemble the order of growth/destruction of the combined SoA buffers. This is important since the initialized buffer must show the same behavior as a buffer which was updated multiple times.

Figure 1: Movement of the interaction sphere in 2D. (dark blue cell = base cell)
Figure 2: Evolution of the circular buffer.
Template Parameters
ParticleCellthe type of cells
FunctorThe functor that defines the interaction of two particles.
combineSoA

Constructor & Destructor Documentation

◆ LCC01Traversal()

template<class ParticleCell , class Functor , bool combineSoA = false>
autopas::LCC01Traversal< ParticleCell, Functor, combineSoA >::LCC01Traversal ( const std::array< unsigned long, 3 > &  dims,
Functor functor,
const double  interactionLength,
const std::array< double, 3 > &  cellLength,
DataLayoutOption  dataLayout,
bool  useNewton3 
)
inlineexplicit

Constructor of the c01 traversal.

Parameters
dimsThe dimensions of the cellblock, i.e. the number of cells in x, y and z direction (incl. halo).
functorThe functor that defines the interaction of particles.
interactionLengthInteraction length (cutoff + skin).
cellLengthcell length in CellBlock3D
dataLayoutThe data layout with which this traversal should be initialized.
useNewton3Parameter to specify whether the traversal makes use of newton3 or not.
Todo:
Pass cutoff to _cellFunctor instead of interactionLength, unless this functor is used to build verlet-lists, in that case the interactionLength is needed!

Member Function Documentation

◆ getTraversalType()

template<class ParticleCell , class Functor , bool combineSoA = false>
TraversalOption autopas::LCC01Traversal< ParticleCell, Functor, combineSoA >::getTraversalType ( ) const
inlineoverridevirtual

Return a enum representing the name of the traversal class.

Returns
Enum representing traversal.

Implements autopas::TraversalInterface.

◆ isApplicable()

template<class ParticleCell , class Functor , bool combineSoA = false>
bool autopas::LCC01Traversal< ParticleCell, Functor, combineSoA >::isApplicable ( ) const
inlineoverridevirtual

C01 traversals are only usable if useNewton3 is disabled and combined SoA buffers are only applicable if SoA is set as DataLayout.

This is because the cell functor in the c01 traversal is hardcoded to not allow newton 3 even if only one thread is used.

Also, combined SoA buffers are only implemented for pairwise interactions.

Returns

Implements autopas::TraversalInterface.

◆ setSortingThreshold()

template<class ParticleCell , class Functor , bool combineSoA = false>
void autopas::LCC01Traversal< ParticleCell, Functor, combineSoA >::setSortingThreshold ( size_t  sortingThreshold)
inlineoverridevirtual

Set the sorting-threshold for traversals that use the CellFunctor If the sum of the number of particles in two cells is greater or equal to that value, the CellFunctor creates a sorted view of the particles to avoid unnecessary distance checks.

Parameters
sortingThresholdSum of the number of particles in two cells from which sorting should be enabled

Implements autopas::CellTraversal< ParticleCell >.

◆ traverseParticles()

template<class ParticleCell , class Functor , bool combineSoA>
void autopas::LCC01Traversal< ParticleCell, Functor, combineSoA >::traverseParticles ( )
inlineoverridevirtual

Traverse the particles by pairs, triplets etc.

as determined by the Functor type.

Implements autopas::TraversalInterface.


The documentation for this class was generated from the following file: