AutoPas  3.0.0
Loading...
Searching...
No Matches
ParticleCellHelpers.h
Go to the documentation of this file.
1
7#pragma once
9
10namespace autopas::internal {
24template <class CellType>
25static bool checkParticleInCellAndUpdateByIDAndPosition(CellType &cell, const typename CellType::ParticleType &particle,
26 double absError) {
27 using namespace autopas::utils::ArrayMath::literals;
28 for (auto &p : cell) {
29 if (p.getID() == particle.getID()) {
30 auto distanceVec = p.getR() - particle.getR();
31 auto distanceSqr = autopas::utils::ArrayMath::dot(distanceVec, distanceVec);
32 if (distanceSqr < absError * absError) {
33 p = particle;
34 // found the particle, returning.
35 return true;
36 }
37 }
38 }
39 return false;
40}
41} // namespace autopas::internal
This namespace is used for implementation specifics.
Definition: CellFunctor.h:21
static bool checkParticleInCellAndUpdateByIDAndPosition(CellType &cell, const typename CellType::ParticleType &particle, double absError)
Updates a found particle within cellI to the values of particleI.
Definition: ParticleCellHelpers.h:25
constexpr T dot(const std::array< T, SIZE > &a, const std::array< T, SIZE > &b)
Generates the dot product of two arrays.
Definition: ArrayMath.h:233
CellType
The ParticleCell Type as an Enum.
Definition: ParticleCell.h:19