9 namespace ImplementationDetails
14 const unsigned int boxSizeX,
15 const unsigned int boxSizeY,
16 const unsigned int boxSizeZ)
18 const FP x = position.
getX();
19 const FP y = position.
getY();
20 const FP z = position.
getZ();
22 const unsigned int cellX =
static_cast<unsigned int>(x);
23 const unsigned int cellY =
static_cast<unsigned int>(y);
24 const unsigned int cellZ =
static_cast<unsigned int>(z);
26 const unsigned int index =
27 cellZ * boxSizeX * boxSizeY +
37 const unsigned int particleID,
44 unsigned int*
const collisionCellIndices,
45 const unsigned int boxSizeX,
46 const unsigned int boxSizeY,
47 const unsigned int boxSizeZ)
53 positions, particleID);
64 boxSizeX, boxSizeY, boxSizeZ,
67 velocities[3 * particleID + 0] += velocityCorrection;
68 velocityCorrections[particleID] = velocityCorrection;
70 collisionCellIndices[particleID] =
75 const unsigned int particleCount,
77 const unsigned int*
const collisionCellIndices,
79 FP*
const collisionCellMasses,
80 const FP particleMass)
82 for(
unsigned int particleID = 0; particleID < particleCount; ++particleID)
84 const unsigned int collisionCellIndex = collisionCellIndices[particleID];
87 particleVelocity(velocities, particleID);
89 cellMomentum(collisionCellMomenta, collisionCellIndex);
94 cellMomentum += particleVelocity * particleMass;
95 collisionCellMasses[collisionCellIndex] += particleMass;
103 const unsigned int collisionCellIndex,
107 collisionCellMomentum(collisionCellMomenta, collisionCellIndex);
109 return collisionCellMomentum;
114 const unsigned int collisionCellIndex,
116 const FP*
const collisionCellMasses)
119 collisionCellMomentum(collisionCellMomenta, collisionCellIndex);
121 const FP collisionCellMass = collisionCellMasses[collisionCellIndex];
124 collisionCellMomentum / collisionCellMass;
132 const unsigned int particleCount,
134 const FP particleMass,
135 const unsigned int*
const collisionCellIndices,
137 const FP*
const collisionCellMasses,
139 const FP collisionAngle,
140 FP*
const collisionCellFrameInternalKineticEnergies,
141 unsigned int*
const collisionCellParticleCounts)
143 for(
unsigned int particleID = 0; particleID < particleCount; ++particleID)
145 const unsigned int collisionCellIndex =
146 collisionCellIndices[particleID];
149 particleVelocity(velocities, particleID);
153 collisionCellIndex, collisionCellMomenta, collisionCellMasses);
156 particleVelocity - collisionCellVelocity;
159 rotationAxis(collisionCellRotationAxes, collisionCellIndex);
163 rotationAxis, collisionAngle);
170 collisionCellFrameInternalKineticEnergies[collisionCellIndex] +=
172 collisionCellParticleCounts[collisionCellIndex] += 1;
177 const unsigned int particleCount,
179 const unsigned int*
const collisionCellIndices,
181 const FP*
const collisionCellMasses,
182 const FP*
const collisionCellVelocityScalings)
184 for(
unsigned int particleID = 0; particleID < particleCount; ++particleID)
186 const unsigned int collisionCellIndex = collisionCellIndices[particleID];
189 particleVelocity(velocities, particleID);
193 std::isfinite(collisionCellVelocityScalings[collisionCellIndex]));
196 collisionCellVelocityScalings[collisionCellIndex];
200 collisionCellIndex, collisionCellMomenta, collisionCellMasses);
207 const unsigned int particleCount,
211 for(
unsigned int particleID = 0; particleID < particleCount; ++particleID)
216 velocities[3 * particleID + 0] -= velocityCorrections[particleID];
OPENMPCD_CUDA_HOST_AND_DEVICE bool isFinite() const
Returns whether all components are finite, i.e.
Represents a vector whose data is stored elsewhere.
const OPENMPCD_CUDA_HOST_AND_DEVICE Vector3D getRotatedAroundNormalizedAxis(const Vector3D &axis, const T angle) const
Returns this vector, but rotated about the given axis by the given angle.
OPENMPCD_CUDA_HOST_AND_DEVICE T getZ() const
Returns the z coordinate.
OPENMPCD_CUDA_HOST_AND_DEVICE T getX() const
Returns the x coordinate.
#define OPENMPCD_DEBUG_ASSERT(assertion)
Asserts that the given expression evaluates to true, but only if OPENMPCD_DEBUG is defined.
FP MPCParticlePositionType
The data type for the positions of MPC particles.
OPENMPCD_CUDA_HOST_AND_DEVICE T getY() const
Returns the y coordinate.
Vector3D< MPCParticleVelocityType > getCollisionCellCenterOfMassMomentum(const unsigned int collisionCellIndex, const MPCParticleVelocityType *const collisionCellMomenta)
Returns the center-of-mass momentum of a collision cell.
unsigned int getCollisionCellIndex(const Vector3D< MPCParticlePositionType > &position, const unsigned int boxSizeX, const unsigned int boxSizeY, const unsigned int boxSizeZ)
Returns the collision cell index for the given position.
void collisionCellStochasticRotationStep1(const unsigned int particleCount, MPCParticleVelocityType *const velocities, const FP particleMass, const unsigned int *const collisionCellIndices, const MPCParticleVelocityType *const collisionCellMomenta, const FP *const collisionCellMasses, const MPCParticlePositionType *const collisionCellRotationAxes, const FP collisionAngle, FP *const collisionCellFrameInternalKineticEnergies, unsigned int *const collisionCellParticleCounts)
Applies the first step of the SRD rotation to the given particles.
double FP
Default floating point type.
FP MPCParticleVelocityType
The data type for the velocities of MPC particles.
void undoLeesEdwardsVelocityCorrections(const unsigned int particleCount, MPCParticleVelocityType *const velocities, const MPCParticleVelocityType *const velocityCorrections)
Undoes the velocity corrections applied by sortIntoCollisionCellsLeesEdwards.
void collisionCellContributions(const unsigned int particleCount, const MPCParticleVelocityType *const velocities, const unsigned int *const collisionCellIndices, MPCParticleVelocityType *const collisionCellMomenta, FP *const collisionCellMasses, const FP particleMass)
Computes the collision cell mass and momentum contributions by the given particles.
const __device__ Vector3D< MPCParticlePositionType > getImageUnderLeesEdwardsBoundaryConditions(const FP mpcTime, const Vector3D< MPCParticlePositionType > &position, MPCParticleVelocityType &velocityCorrection)
Returns the image of the given particle position under Lees-Edwards boundary conditions.
void sortIntoCollisionCellsLeesEdwards(const unsigned int particleID, const MPCParticlePositionType *const gridShift_, const FP shearRate, const FP mpcTime, const MPCParticlePositionType *const positions, MPCParticleVelocityType *const velocities, MPCParticleVelocityType *const velocityCorrections, unsigned int *const collisionCellIndices, const unsigned int boxSizeX, const unsigned int boxSizeY, const unsigned int boxSizeZ)
Sorts the given particle into the collision cells, temporarily applying Lees-Edwards boundary conditi...
Vector3D< MPCParticleVelocityType > getCollisionCellCenterOfMassVelocity(const unsigned int collisionCellIndex, const MPCParticleVelocityType *const collisionCellMomenta, const FP *const collisionCellMasses)
Returns the center-of-mass velocity of a collision cell.
void collisionCellStochasticRotationStep2(const unsigned int particleCount, MPCParticleVelocityType *const velocities, const unsigned int *const collisionCellIndices, const MPCParticleVelocityType *const collisionCellMomenta, const FP *const collisionCellMasses, const FP *const collisionCellVelocityScalings)
Applies the first step of the SRD rotation to the given particles.
OPENMPCD_CUDA_HOST_AND_DEVICE bool isFinite() const
Returns whether all components are finite, i.e.
OPENMPCD_CUDA_HOST_AND_DEVICE RealType getMagnitudeSquared() const
Returns the square of the magnitude of this vector.