28template <
class ParticleCell,
class PairwiseFunctor>
42 const std::array<double, 3> &cellLength, DataLayoutOption dataLayout,
bool useNewton3)
44 dataLayout, useNewton3),
45 _cellOffsets32Pack(computeOffsets32Pack()),
47 dataLayout, useNewton3),
48 _end(utils::ArrayMath::subScalar(utils::ArrayUtils::static_cast_copy_array<long>(this->
_cellsPerDimension),
53 [[nodiscard]] TraversalOption
getTraversalType()
const override {
return TraversalOption::lc_c04; }
62 const double minLength = *std::min_element(this->
_cellLength.cbegin(), this->_cellLength.cend());
63 const unsigned long minDim = *std::min_element(this->
_cellsPerDimension.cbegin(), this->_cellsPerDimension.cend());
71 void setSortingThreshold(
size_t sortingThreshold)
override { _cellHandler.setSortingThreshold(sortingThreshold); }
74 void traverseSingleColor(std::vector<ParticleCell> &cells,
int color);
76 void processBasePack32(std::vector<ParticleCell> &cells,
const std::array<long, 3> &base3DIndex);
78 constexpr auto computeOffsets32Pack()
const;
80 [[nodiscard]]
constexpr long parity(
long x,
long y,
long z)
const {
return (x + y + z + 24) % 8; }
82 std::array<std::array<long, 3>, 32> _cellOffsets32Pack;
84 LCC08CellHandler<ParticleCell, PairwiseFunctor> _cellHandler;
86 std::array<long, 3> _end;
95template <
class ParticleCell,
class PairwiseFunctor>
96constexpr auto LCC04Traversal<ParticleCell, PairwiseFunctor>::computeOffsets32Pack()
const {
100 std::array<std::array<long, 3>, 32> cellOffsets32Pack = {};
104 cellOffsets32Pack[i++] = {1l, 1l, z};
105 cellOffsets32Pack[i++] = {1l, 2l, z};
106 cellOffsets32Pack[i++] = {2l, 1l, z};
107 cellOffsets32Pack[i++] = {2l, 2l, z};
110 for (z = 1l; z < 3l; ++z) {
111 for (
long y = 0l; y < 4l; y++) {
112 for (
long x = 0l; x < 4l; x++) {
113 if ((x == 0l and y == 0l) or (x == 3l and y == 0l) or (x == 0l and y == 3l) or (x == 3l and y == 3l)) {
116 cellOffsets32Pack[i++] = {x, y, z};
122 cellOffsets32Pack[i++] = {1l, 1l, z};
123 cellOffsets32Pack[i++] = {1l, 2l, z};
124 cellOffsets32Pack[i++] = {2l, 1l, z};
125 cellOffsets32Pack[i++] = {2l, 2l, z};
131 return cellOffsets32Pack;
143template <
class ParticleCell,
class PairwiseFunctor>
144void LCC04Traversal<ParticleCell, PairwiseFunctor>::processBasePack32(std::vector<ParticleCell> &cells,
145 const std::array<long, 3> &base3DIndex) {
147 std::array<long, 3> index{};
148 const std::array<long, 3> signedDims = utils::ArrayUtils::static_cast_copy_array<long>(this->_cellsPerDimension);
150 for (
auto offset32Pack : _cellOffsets32Pack) {
153 for (
int d = 0; d < 3; ++d) {
154 index[d] = base3DIndex[d] + offset32Pack[d];
155 isIn &= (index[d] >= 0l) and (index[d] < _end[d]);
159 const unsigned long ulIndex =
threeToOneD(index, signedDims);
160 _cellHandler.processBaseCell(cells, ulIndex);
172template <
class ParticleCell,
class PairwiseFunctor>
174 auto &cells = *(this->_cells);
176 for (
int color = 0; color < 4; ++color) {
177 traverseSingleColor(cells, color);
186template <
class ParticleCell,
class PairwiseFunctor>
194 std::array<long, 3> startOfThisColor{};
199 startOfThisColor = {-2l, -2l, -2l};
203 startOfThisColor = {0l, 0l, 0l};
208 long correctParity = parity(startOfThisColor[0], startOfThisColor[1], startOfThisColor[2]);
214 const long startX = startOfThisColor[0], endX = _end[0];
215 const long startY = startOfThisColor[1], endY = _end[1];
216 const long startZ = startOfThisColor[2], endZ = _end[2];
221 for (
long z = startZ; z < endZ; z += 4) {
222 for (
long y = startY; y < endY; y += 4) {
223 for (
long x = startX; x < endX; x += 4) {
224 const long par = parity(x, y, z);
226 if (par != correctParity) {
230 const std::array<long, 3> base3DIndex = {x, y, z};
231 processBasePack32(cells, base3DIndex);
#define AUTOPAS_OPENMP(args)
Empty macro to throw away any arguments.
Definition: WrapOpenMP.h:126
This class provides the base for traversals using the c08 base step.
Definition: C08BasedTraversal.h:24
std::array< unsigned long, 3 > _cellsPerDimension
The dimensions of the cellblock.
Definition: CellTraversal.h:55
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
const std::array< double, 3 > _cellLength
cell length in CellBlock3D.
Definition: ColorBasedTraversal.h:116
This class provides the c04 traversal.
Definition: LCC04Traversal.h:29
void setSortingThreshold(size_t sortingThreshold) override
Set the sorting-threshold for traversals that use the CellFunctor If the sum of the number of particl...
Definition: LCC04Traversal.h:71
void traverseParticles() override
Go through one color and search for blocks belonging to the specified color.
Definition: LCC04Traversal.h:173
bool isApplicable() const override
C04 traversals are usable, if cellSizeFactor >= 1.0 and there are at least 3 cells for each dimension...
Definition: LCC04Traversal.h:59
LCC04Traversal(const std::array< unsigned long, 3 > &dims, PairwiseFunctor *pairwiseFunctor, double interactionLength, const std::array< double, 3 > &cellLength, DataLayoutOption dataLayout, bool useNewton3)
Constructor of the c04 traversal.
Definition: LCC04Traversal.h:41
TraversalOption getTraversalType() const override
Return a enum representing the name of the traversal class.
Definition: LCC04Traversal.h:53
Interface for traversals used by the LinkedCell class.
Definition: LCTraversalInterface.h:18
PairwiseFunctor class.
Definition: PairwiseFunctor.h:31
Class for Cells of Particles.
Definition: ParticleCell.h:49
static void exception(const Exception e)
Handle an exception derived by std::exception.
Definition: ExceptionHandler.h:63
constexpr T threeToOneD(T x, T y, T z, const std::array< T, 3 > &dims)
Convert a 3d index to a 1d index.
Definition: ThreeDimensionalMapping.h:29
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32