29template <
class ParticleCell,
class PairwiseFunctor>
43 const std::array<double, 3> &cellLength, DataLayoutOption dataLayout,
bool useNewton3)
45 dataLayout, useNewton3),
46 _cellOffsets32Pack(computeOffsets32Pack()),
48 dataLayout, useNewton3),
49 _end(utils::ArrayMath::subScalar(utils::ArrayUtils::static_cast_copy_array<long>(this->
_cellsPerDimension),
54 [[nodiscard]] TraversalOption
getTraversalType()
const override {
return TraversalOption::lc_c04; }
63 const double minLength = *std::min_element(this->
_cellLength.cbegin(), this->_cellLength.cend());
64 const unsigned long minDim = *std::min_element(this->
_cellsPerDimension.cbegin(), this->_cellsPerDimension.cend());
72 void setSortingThreshold(
size_t sortingThreshold)
override { _cellHandler.setSortingThreshold(sortingThreshold); }
75 void traverseSingleColor(std::vector<ParticleCell> &cells,
int color);
77 void processBasePack32(std::vector<ParticleCell> &cells,
const std::array<long, 3> &base3DIndex);
79 constexpr auto computeOffsets32Pack()
const;
81 [[nodiscard]]
constexpr long parity(
long x,
long y,
long z)
const {
return (x + y + z + 24) % 8; }
83 std::array<std::array<long, 3>, 32> _cellOffsets32Pack;
85 LCC08CellHandler<ParticleCell, PairwiseFunctor> _cellHandler;
87 std::array<long, 3> _end;
96template <
class ParticleCell,
class PairwiseFunctor>
97constexpr auto LCC04Traversal<ParticleCell, PairwiseFunctor>::computeOffsets32Pack()
const {
101 std::array<std::array<long, 3>, 32> cellOffsets32Pack = {};
105 cellOffsets32Pack[i++] = {1l, 1l, z};
106 cellOffsets32Pack[i++] = {1l, 2l, z};
107 cellOffsets32Pack[i++] = {2l, 1l, z};
108 cellOffsets32Pack[i++] = {2l, 2l, z};
111 for (z = 1l; z < 3l; ++z) {
112 for (
long y = 0l; y < 4l; y++) {
113 for (
long x = 0l; x < 4l; x++) {
114 if ((x == 0l and y == 0l) or (x == 3l and y == 0l) or (x == 0l and y == 3l) or (x == 3l and y == 3l)) {
117 cellOffsets32Pack[i++] = {x, y, z};
123 cellOffsets32Pack[i++] = {1l, 1l, z};
124 cellOffsets32Pack[i++] = {1l, 2l, z};
125 cellOffsets32Pack[i++] = {2l, 1l, z};
126 cellOffsets32Pack[i++] = {2l, 2l, z};
132 return cellOffsets32Pack;
144template <
class ParticleCell,
class PairwiseFunctor>
145void LCC04Traversal<ParticleCell, PairwiseFunctor>::processBasePack32(std::vector<ParticleCell> &cells,
146 const std::array<long, 3> &base3DIndex) {
148 std::array<long, 3> index{};
149 const std::array<long, 3> signedDims = utils::ArrayUtils::static_cast_copy_array<long>(this->_cellsPerDimension);
151 for (
auto offset32Pack : _cellOffsets32Pack) {
154 for (
int d = 0; d < 3; ++d) {
155 index[d] = base3DIndex[d] + offset32Pack[d];
156 isIn &= (index[d] >= 0l) and (index[d] < _end[d]);
160 const unsigned long ulIndex =
threeToOneD(index, signedDims);
161 _cellHandler.processBaseCell(cells, ulIndex);
173template <
class ParticleCell,
class PairwiseFunctor>
175 auto &cells = *(this->_cells);
177 for (
int color = 0; color < 4; ++color) {
178 traverseSingleColor(cells, color);
187template <
class ParticleCell,
class PairwiseFunctor>
195 std::array<long, 3> startOfThisColor{};
200 startOfThisColor = {-2l, -2l, -2l};
204 startOfThisColor = {0l, 0l, 0l};
209 long correctParity = parity(startOfThisColor[0], startOfThisColor[1], startOfThisColor[2]);
215 const long startX = startOfThisColor[0], endX = _end[0];
216 const long startY = startOfThisColor[1], endY = _end[1];
217 const long startZ = startOfThisColor[2], endZ = _end[2];
222 for (
long z = startZ; z < endZ; z += 4) {
223 for (
long y = startY; y < endY; y += 4) {
224 for (
long x = startX; x < endX; x += 4) {
225 const long par = parity(x, y, z);
227 if (par != correctParity) {
231 const std::array<long, 3> base3DIndex = {x, y, z};
232 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:30
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:72
void traverseParticles() override
Go through one color and search for blocks belonging to the specified color.
Definition: LCC04Traversal.h:174
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:60
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:42
TraversalOption getTraversalType() const override
Return a enum representing the name of the traversal class.
Definition: LCC04Traversal.h:54
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:51
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