28template <
class ParticleCell_T,
class Functor_T>
41 LCC04Traversal(
const std::array<unsigned long, 3> &dims, Functor_T &functor,
double interactionLength,
42 const std::array<double, 3> &cellLength, DataLayoutOption dataLayout,
bool useNewton3)
43 :
C08BasedTraversal<ParticleCell_T, Functor_T>(dims, functor, interactionLength, cellLength, dataLayout,
45 _cellOffsets32Pack(computeOffsets32Pack()),
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());
72 _cellHandler.setAoSSortingThreshold(aosSortingThreshold);
78 _cellHandler.setSoASortingThreshold(soaSortingThreshold);
82 void traverseSingleColor(std::vector<ParticleCell_T> &cells,
int color);
84 void processBasePack32(std::vector<ParticleCell_T> &cells,
const std::array<long, 3> &base3DIndex);
86 static constexpr auto computeOffsets32Pack();
88 [[nodiscard]]
constexpr long parity(
long x,
long y,
long z)
const {
return (x + y + z + 24) % 8; }
90 std::array<std::array<long, 3>, 32> _cellOffsets32Pack;
92 LCC08CellHandler<ParticleCell_T, Functor_T> _cellHandler;
94 std::array<long, 3> _end;
103template <
class ParticleCell_T,
class Functor_T>
104constexpr auto LCC04Traversal<ParticleCell_T, Functor_T>::computeOffsets32Pack() {
105 using std::make_pair;
108 std::array<std::array<long, 3>, 32> cellOffsets32Pack = {};
112 cellOffsets32Pack[i++] = {1l, 1l, z};
113 cellOffsets32Pack[i++] = {1l, 2l, z};
114 cellOffsets32Pack[i++] = {2l, 1l, z};
115 cellOffsets32Pack[i++] = {2l, 2l, z};
118 for (z = 1l; z < 3l; ++z) {
119 for (
long y = 0l; y < 4l; y++) {
120 for (
long x = 0l; x < 4l; x++) {
121 if ((x == 0l and y == 0l) or (x == 3l and y == 0l) or (x == 0l and y == 3l) or (x == 3l and y == 3l)) {
124 cellOffsets32Pack[i++] = {x, y, z};
130 cellOffsets32Pack[i++] = {1l, 1l, z};
131 cellOffsets32Pack[i++] = {1l, 2l, z};
132 cellOffsets32Pack[i++] = {2l, 1l, z};
133 cellOffsets32Pack[i++] = {2l, 2l, z};
139 return cellOffsets32Pack;
151template <
class ParticleCell_T,
class Functor_T>
152void LCC04Traversal<ParticleCell_T, Functor_T>::processBasePack32(std::vector<ParticleCell_T> &cells,
153 const std::array<long, 3> &base3DIndex) {
155 std::array<long, 3> index{};
156 const std::array<long, 3> signedDims = utils::ArrayUtils::static_cast_copy_array<long>(this->_cellsPerDimension);
158 for (
auto offset32Pack : _cellOffsets32Pack) {
161 for (
int d = 0; d < 3; ++d) {
162 index[d] = base3DIndex[d] + offset32Pack[d];
163 isIn &= (index[d] >= 0l) and (index[d] < _end[d]);
167 const unsigned long ulIndex =
threeToOneD(index, signedDims);
168 _cellHandler.processBaseCell(cells, ulIndex);
180template <
class ParticleCell_T,
class Functor_T>
182 auto &cells = *(this->_cells);
184 for (
int color = 0; color < 4; ++color) {
185 traverseSingleColor(cells, color);
194template <
class ParticleCell_T,
class Functor_T>
202 std::array<long, 3> startOfThisColor{};
207 startOfThisColor = {-2l, -2l, -2l};
211 startOfThisColor = {0l, 0l, 0l};
216 long correctParity = parity(startOfThisColor[0], startOfThisColor[1], startOfThisColor[2]);
222 const long startX = startOfThisColor[0], endX = _end[0];
223 const long startY = startOfThisColor[1], endY = _end[1];
224 const long startZ = startOfThisColor[2], endZ = _end[2];
229 for (
long z = startZ; z < endZ; z += 4) {
230 for (
long y = startY; y < endY; y += 4) {
231 for (
long x = startX; x < endX; x += 4) {
232 const long par = parity(x, y, z);
234 if (par != correctParity) {
238 const std::array<long, 3> base3DIndex = {x, y, z};
239 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:63
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 setSoASortingThreshold(size_t soaSortingThreshold) override
Set the SoA sorting-threshold for traversals that use the CellFunctor.
Definition: LCC04Traversal.h:77
LCC04Traversal(const std::array< unsigned long, 3 > &dims, Functor_T &functor, double interactionLength, const std::array< double, 3 > &cellLength, DataLayoutOption dataLayout, bool useNewton3)
Constructor of the c04 traversal.
Definition: LCC04Traversal.h:41
void setAoSSortingThreshold(size_t aosSortingThreshold) override
Set the aos-sorting-threshold for traversals that use the CellFunctor If the sum of the number of par...
Definition: LCC04Traversal.h:71
bool isApplicableToDomain() const override
C04 traversals are usable, if cellSizeFactor >= 1.0 and there are at least 3 cells for each dimension...
Definition: LCC04Traversal.h:59
TraversalOption getTraversalType() const override
Return a enum representing the name of the traversal class.
Definition: LCC04Traversal.h:53
void traverseParticles() override
Go through one color and search for blocks belonging to the specified color.
Definition: LCC04Traversal.h:181
Interface for traversals used by the LinkedCell class.
Definition: LCTraversalInterface.h:18
static void exception(const Exception e)
Handle an exception derived by std::exception.
Definition: ExceptionHandler.h:64
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:34