26template <
class ParticleCell,
class Functor,
int collapseDepth = 3>
40 const double interactionLength,
const std::array<double, 3> &cellLength,
41 DataLayoutOption dataLayout,
bool useNewton3)
46 _dataLayoutConverter(functor, dataLayout) {
47 for (
unsigned int d = 0; d < 3; d++) {
63 auto &cells = *(this->
_cells);
66 for (
size_t i = 0; i < cells.size(); ++i) {
67 _dataLayoutConverter.loadDataLayout(cells[i]);
77 auto &cells = *(this->
_cells);
80 for (
size_t i = 0; i < cells.size(); ++i) {
81 _dataLayoutConverter.storeDataLayout(cells[i]);
96 template <
typename LoopBody>
97 inline void colorTraversal(LoopBody &&loopBody,
const std::array<unsigned long, 3> &end,
98 const std::array<unsigned long, 3> &stride,
99 const std::array<unsigned long, 3> &offset = {0ul, 0ul, 0ul});
130template <
class ParticleCell,
class Functor,
int collapseDepth>
131template <
typename LoopBody>
133 LoopBody &&loopBody,
const std::array<unsigned long, 3> &end,
const std::array<unsigned long, 3> &stride,
134 const std::array<unsigned long, 3> &offset) {
135 using namespace autopas::utils::ArrayMath::literals;
137 const unsigned long numColors = stride[0] * stride[1] * stride[2];
138 for (
unsigned long col = 0; col < numColors; ++col) {
141 notifyColorChange(col);
145 const std::array<unsigned long, 3> start(startWithoutOffset + offset);
148 const unsigned long start_x = start[0], start_y = start[1], start_z = start[2];
149 const unsigned long end_x = end[0], end_y = end[1], end_z = end[2];
150 const unsigned long stride_x = stride[0], stride_y = stride[1], stride_z = stride[2];
151 if (collapseDepth == 2) {
153 for (
unsigned long z = start_z; z < end_z; z += stride_z) {
154 for (
unsigned long y = start_y; y < end_y; y += stride_y) {
155 for (
unsigned long x = start_x; x < end_x; x += stride_x) {
163 for (
unsigned long z = start_z; z < end_z; z += stride_z) {
164 for (
unsigned long y = start_y; y < end_y; y += stride_y) {
165 for (
unsigned long x = start_x; x < end_x; x += stride_x) {
#define AUTOPAS_OPENMP(args)
Empty macro to throw away any arguments.
Definition: WrapOpenMP.h:126
A cell pair traversal.
Definition: CellTraversal.h:23
std::vector< ParticleCell > * _cells
The cells to traverse.
Definition: CellTraversal.h:60
This class provides the base for traversals using base steps based on cell coloring.
Definition: ColorBasedTraversal.h:27
void initTraversal() override
load Data Layouts required for this Traversal if cells have been set through setCellsToTraverse().
Definition: ColorBasedTraversal.h:61
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.
Definition: ColorBasedTraversal.h:39
const double _interactionLength
Interaction length (cutoff + skin).
Definition: ColorBasedTraversal.h:111
std::array< unsigned long, 3 > _overlap
overlap of interacting cells.
Definition: ColorBasedTraversal.h:121
~ColorBasedTraversal() override=default
Destructor of ColorBasedTraversal.
const std::array< double, 3 > _cellLength
cell length in CellBlock3D.
Definition: ColorBasedTraversal.h:116
void endTraversal() override
write Data to AoS if cells have been set through setCellsToTraverse().
Definition: ColorBasedTraversal.h:75
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.
Definition: ColorBasedTraversal.h:132
virtual void notifyColorChange(unsigned long newColor)
This method is called when the color during the traversal has changed.
Definition: ColorBasedTraversal.h:106
Functor base class.
Definition: Functor.h:40
Class for Cells of Particles.
Definition: ParticleCell.h:51
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
constexpr std::array< T, 3 > oneToThreeD(T ind, const std::array< T, 3 > &dims)
Convert a 1d index to a 3d index.
Definition: ThreeDimensionalMapping.h:55
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32