OpenMPCD
fourierTransformedVelocity.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * Defines CUDA Device code for OpenMPCD::CUDA::MPCFluid::Instrumentation
4  */
5 
6 #ifndef OPENMPCD_CUDA_MPCFLUID_INSTRUMENTATION_DEVICECODE_FOURIERTRANSFORMEDVELOCITY_HPP
7 #define OPENMPCD_CUDA_MPCFLUID_INSTRUMENTATION_DEVICECODE_FOURIERTRANSFORMEDVELOCITY_HPP
8 
9 #include <OpenMPCD/Types.hpp>
10 #include <OpenMPCD/Vector3D.hpp>
11 
12 #include <complex>
13 
14 namespace OpenMPCD
15 {
16 namespace CUDA
17 {
18 namespace MPCFluid
19 {
20 namespace DeviceCode
21 {
22  /**
23  * @page velocityInFourierSpace Velocity in Fourier Space
24  * "Velocity in fourier space" refers to the discrete fourier transformation of the spatial coordinates
25  * of the velocities of a MPC fluid's constituents. The corresponding formula is given by
26  * \f[ \vec{v}\left(\vec{k}, t\right) =
27  * \frac{1}{N} \sum_{i=1}^N \vec{v}_i\left(t\right) \cdot
28  * \exp\left( \mathrm{i} \vec{k} \cdot \vec{r}_i\left(t\right) \right)
29  * \f]
30  * See, for example, "Hydrodnymic correlations in multiparticle collision dynamics" by Chien-Cheng Huang,
31  * Gerhard Gompper, and Roland G. Winkler, published in Physical Review E 86, 056711 (2012), equation (38).
32  */
33 
34  /**
35  * Calculates the velocity in Fourier space, assuming a simple MPC fluid.
36  *
37  * See @ref velocityInFourierSpace
38  *
39  * @param[in] particleCount The number of MPC particles in the fluid.
40  * @param[in] positions The array of MPC fluid particle positions.
41  * @param[in] velocities The array of MPC fluid particle velocities.
42  * @param[in] k The \f$\vec{k}\f$ vector.
43  * @param[out] buffer1 A Device buffer that holds at least
44  * <c>3*numberOfConstituents*sizeof(MPCParticleVelocityType)</c>
45  * bytes.
46  * @param[out] buffer2 A Device buffer that holds at least
47  * <c>3*numberOfConstituents*sizeof(MPCParticleVelocityType)</c>
48  * bytes.
49  */
50  const Vector3D<std::complex<MPCParticleVelocityType> > calculateVelocityInFourierSpace_simpleMPCFluid(
51  const unsigned int particleCount,
52  const MPCParticlePositionType* const positions,
53  const MPCParticleVelocityType* const velocities,
54  const Vector3D<MPCParticlePositionType> k,
55  MPCParticleVelocityType* const buffer1,
56  MPCParticleVelocityType* const buffer2);
57 
58  /**
59  * Device function for calculation of summands of the real and imaginary part of the velocity in Fourier space,
60  * assuming a simple MPC fluid.
61  *
62  * @remark
63  * This function is not intended to be called directly by the user. Instead, call
64  * calculateVelocityInFourierSpace_simpleMPCFluid().
65  *
66  * See @ref velocityInFourierSpace
67  *
68  * @param[in] workUnitOffset The number of particles to skip.
69  * @param[in] positions The device array of MPC fluid particle positions.
70  * @param[in] velocities The device array of MPC fluid particle velocities.
71  * @param[in] k The \f$\vec{k}\f$ vector.
72  * @param[out] realBuffer A Device buffer that holds at least
73  * <c>3*numberOfConstituents*sizeof(MPCParticleVelocityType)</c>
74  * bytes, used to store the real parts of the summands.
75  * @param[out] imaginaryBuffer A Device buffer that holds at least
76  * <c>3*numberOfConstituents*sizeof(MPCParticleVelocityType)</c>
77  * bytes, used to store the imaginary parts of the summands.
78  */
80  const unsigned int workUnitOffset,
81  const MPCParticlePositionType* const positions,
82  const MPCParticleVelocityType* const velocities,
83  const Vector3D<MPCParticlePositionType> k,
84  MPCParticleVelocityType* const realBuffer,
85  MPCParticleVelocityType* const imaginaryBuffer);
86 
87 
88 
89 
90 
91 
92 
93  /**
94  * Calculates the velocity in Fourier space, assuming an MPC fluid consisting of pairs of MPC particles.
95  *
96  * See @ref velocityInFourierSpace
97  *
98  * @param[in] doubletCount The number of MPC particle doublets in the fluid.
99  * @param[in] positions The array of MPC fluid particle positions.
100  * @param[in] velocities The array of MPC fluid particle velocities.
101  * @param[in] k The \f$\vec{k}\f$ vector.
102  * @param[out] buffer1 A Device buffer that holds at least
103  * <c>3*doubletCount*sizeof(MPCParticleVelocityType)</c>
104  * bytes.
105  * @param[out] buffer2 A Device buffer that holds at least
106  * <c>3*doubletCount*sizeof(MPCParticleVelocityType)</c>
107  * bytes.
108  */
109  const Vector3D<std::complex<MPCParticleVelocityType> > calculateVelocityInFourierSpace_doubletMPCFluid(
110  const unsigned int doubletCount,
111  const MPCParticlePositionType* const positions,
112  const MPCParticleVelocityType* const velocities,
113  const Vector3D<MPCParticlePositionType> k,
114  MPCParticleVelocityType* const buffer1,
115  MPCParticleVelocityType* const buffer2);
116 
117  /**
118  * Device function for calculation of summands of the real and imaginary part of the velocity in Fourier space,
119  * assuming an MPC fluid consisting of pairs of MPC particles.
120  *
121  * @remark
122  * This function is not intended to be called directly by the user. Instead, call
123  * calculateVelocityInFourierSpace_doubletMPCFluid().
124  *
125  * See @ref velocityInFourierSpace
126  *
127  * @param[in] workUnitOffset The number of MPC particle doublets to skip.
128  * @param[in] positions The device array of MPC fluid particle positions.
129  * @param[in] velocities The device array of MPC fluid particle velocities.
130  * @param[in] k The \f$\vec{k}\f$ vector.
131  * @param[out] realBuffer A Device buffer that holds at least
132  * <c>3*doubletCount*sizeof(MPCParticleVelocityType)</c>
133  * bytes, used to store the real parts of the summands.
134  * @param[out] imaginaryBuffer A Device buffer that holds at least
135  * <c>3*doubletCount*sizeof(MPCParticleVelocityType)</c>
136  * bytes, used to store the imaginary parts of the summands.
137  */
139  const unsigned int workUnitOffset,
140  const MPCParticlePositionType* const positions,
141  const MPCParticleVelocityType* const velocities,
142  const Vector3D<MPCParticlePositionType> k,
143  MPCParticleVelocityType* const realBuffer,
144  MPCParticleVelocityType* const imaginaryBuffer);
145 
146 
147 
148 
149 
150 
151 
152  /**
153  * Calculates the velocity in Fourier space, assuming an MPC fluid consisting of triplets of MPC particles.
154  *
155  * See @ref velocityInFourierSpace
156  *
157  * @param[in] tripletCount The number of MPC particle triplets in the fluid.
158  * @param[in] positions The array of MPC fluid particle positions.
159  * @param[in] velocities The array of MPC fluid particle velocities.
160  * @param[in] k The \f$\vec{k}\f$ vector.
161  * @param[out] buffer1 A Device buffer that holds at least
162  * <c>3*tripletCount*sizeof(MPCParticleVelocityType)</c>
163  * bytes.
164  * @param[out] buffer2 A Device buffer that holds at least
165  * <c>3*tripletCount*sizeof(MPCParticleVelocityType)</c>
166  * bytes.
167  */
168  const Vector3D<std::complex<MPCParticleVelocityType> > calculateVelocityInFourierSpace_tripletMPCFluid(
169  const unsigned int tripletCount,
170  const MPCParticlePositionType* const positions,
171  const MPCParticleVelocityType* const velocities,
172  const Vector3D<MPCParticlePositionType> k,
173  MPCParticleVelocityType* const buffer1,
174  MPCParticleVelocityType* const buffer2);
175 
176  /**
177  * Device function for calculation of summands of the real and imaginary part of the velocity in Fourier space,
178  * assuming an MPC fluid consisting of triplets of MPC particles.
179  *
180  * @remark
181  * This function is not intended to be called directly by the user. Instead, call
182  * calculateVelocityInFourierSpace_tripletMPCFluid().
183  *
184  * See @ref velocityInFourierSpace
185  *
186  * @param[in] workUnitOffset The number of MPC particle triplets to skip.
187  * @param[in] positions The device array of MPC fluid particle positions.
188  * @param[in] velocities The device array of MPC fluid particle velocities.
189  * @param[in] k The \f$\vec{k}\f$ vector.
190  * @param[out] realBuffer A Device buffer that holds at least
191  * <c>3*tripletCount*sizeof(MPCParticleVelocityType)</c>
192  * bytes, used to store the real parts of the summands.
193  * @param[out] imaginaryBuffer A Device buffer that holds at least
194  * <c>3*tripletCount*sizeof(MPCParticleVelocityType)</c>
195  * bytes, used to store the imaginary parts of the summands.
196  */
198  const unsigned int workUnitOffset,
199  const MPCParticlePositionType* const positions,
200  const MPCParticleVelocityType* const velocities,
201  const Vector3D<MPCParticlePositionType> k,
202  MPCParticleVelocityType* const realBuffer,
203  MPCParticleVelocityType* const imaginaryBuffer);
204 
205 
206 
207 
208 
209  /**
210  * Calculates the velocity in Fourier space, assuming an MPC fluid consisting of chains of MPC particles.
211  *
212  * See @ref velocityInFourierSpace
213  *
214  * @param[in] chainCount The number of MPC particle chains in the fluid.
215  * @param[in] chainLength The number of MPC fluid particles in a chain.
216  * @param[in] positions The array of MPC fluid particle positions.
217  * @param[in] velocities The array of MPC fluid particle velocities.
218  * @param[in] k The \f$\vec{k}\f$ vector.
219  * @param[out] buffer1 A Device buffer that holds at least
220  * <c>3*chainCount*sizeof(MPCParticleVelocityType)</c>
221  * bytes.
222  * @param[out] buffer2 A Device buffer that holds at least
223  * <c>3*chainCount*sizeof(MPCParticleVelocityType)</c>
224  * bytes.
225  */
226  const Vector3D<std::complex<MPCParticleVelocityType> > calculateVelocityInFourierSpace_chainMPCFluid(
227  const unsigned int chainCount,
228  const unsigned int chainLength,
229  const MPCParticlePositionType* const positions,
230  const MPCParticleVelocityType* const velocities,
231  const Vector3D<MPCParticlePositionType> k,
232  MPCParticleVelocityType* const buffer1,
233  MPCParticleVelocityType* const buffer2);
234 
235  /**
236  * Device function for calculation of summands of the real and imaginary part of the velocity in Fourier space,
237  * assuming an MPC fluid consisting of chains of MPC particles.
238  *
239  * @remark
240  * This function is not intended to be called directly by the user. Instead, call
241  * calculateVelocityInFourierSpace_chainMPCFluid().
242  *
243  * See @ref velocityInFourierSpace
244  *
245  * @param[in] workUnitOffset The number of MPC particle chains to skip.
246  * @param[in] chainLength The number of MPC fluid particles in a chain.
247  * @param[in] positions The device array of MPC fluid particle positions.
248  * @param[in] velocities The device array of MPC fluid particle velocities.
249  * @param[in] k The \f$\vec{k}\f$ vector.
250  * @param[out] realBuffer A Device buffer that holds at least
251  * <c>3*tripletCount*sizeof(MPCParticleVelocityType)</c>
252  * bytes, used to store the real parts of the summands.
253  * @param[out] imaginaryBuffer A Device buffer that holds at least
254  * <c>3*tripletCount*sizeof(MPCParticleVelocityType)</c>
255  * bytes, used to store the imaginary parts of the summands.
256  */
258  const unsigned int workUnitOffset,
259  const unsigned int chainLength,
260  const MPCParticlePositionType* const positions,
261  const MPCParticleVelocityType* const velocities,
262  const Vector3D<MPCParticlePositionType> k,
263  MPCParticleVelocityType* const realBuffer,
264  MPCParticleVelocityType* const imaginaryBuffer);
265 
266 
267 
268 
269 
270 
271  /**
272  * Reduces the calculated summands of the velocity in Fourier space.
273  *
274  * @remark
275  * This function is not intended to be called by the user.
276  *
277  * See @ref velocityInFourierSpace
278  *
279  * @param[in] summandCount The number of summands.
280  * @param[in] realBuffer Device buffer holding the real parts of the summands.
281  * @param[in] imaginaryBuffer Device buffer holding the imaginary parts of the summands.
282  *
283  * @return Returns the velocity in Fourier space.
284  */
285  const Vector3D<std::complex<MPCParticleVelocityType> > reduceVelocityInFourierSpaceBuffers(
286  const unsigned int summandCount,
287  MPCParticleVelocityType* const realBuffer,
288  MPCParticleVelocityType* const imaginaryBuffer);
289 } //namespace DeviceCode
290 } //namespace MPCFluid
291 } //namespace CUDA
292 } //namespace OpenMPCD
293 
294 #endif
OpenMPCD::CUDA::MPCFluid::DeviceCode::calculateVelocityInFourierSpace_tripletMPCFluid_single
__global__ void calculateVelocityInFourierSpace_tripletMPCFluid_single(const unsigned int workUnitOffset, const MPCParticlePositionType *const positions, const MPCParticleVelocityType *const velocities, const Vector3D< MPCParticlePositionType > k, MPCParticleVelocityType *const realBuffer, MPCParticleVelocityType *const imaginaryBuffer)
Device function for calculation of summands of the real and imaginary part of the velocity in Fourier...
OpenMPCD::CUDA::MPCFluid::DeviceCode::calculateVelocityInFourierSpace_chainMPCFluid_single
__global__ void calculateVelocityInFourierSpace_chainMPCFluid_single(const unsigned int workUnitOffset, const unsigned int chainLength, const MPCParticlePositionType *const positions, const MPCParticleVelocityType *const velocities, const Vector3D< MPCParticlePositionType > k, MPCParticleVelocityType *const realBuffer, MPCParticleVelocityType *const imaginaryBuffer)
Device function for calculation of summands of the real and imaginary part of the velocity in Fourier...
OpenMPCD::CUDA::MPCFluid::DeviceCode::reduceVelocityInFourierSpaceBuffers
const Vector3D< std::complex< MPCParticleVelocityType > > reduceVelocityInFourierSpaceBuffers(const unsigned int summandCount, MPCParticleVelocityType *const realBuffer, MPCParticleVelocityType *const imaginaryBuffer)
Reduces the calculated summands of the velocity in Fourier space.
Vector3D.hpp
OpenMPCD::CUDA::MPCFluid::DeviceCode::calculateVelocityInFourierSpace_simpleMPCFluid_single
__global__ void calculateVelocityInFourierSpace_simpleMPCFluid_single(const unsigned int workUnitOffset, const MPCParticlePositionType *const positions, const MPCParticleVelocityType *const velocities, const Vector3D< MPCParticlePositionType > k, MPCParticleVelocityType *const realBuffer, MPCParticleVelocityType *const imaginaryBuffer)
Device function for calculation of summands of the real and imaginary part of the velocity in Fourier...
OpenMPCD::CUDA::MPCFluid::DeviceCode::calculateVelocityInFourierSpace_doubletMPCFluid
const Vector3D< std::complex< MPCParticleVelocityType > > calculateVelocityInFourierSpace_doubletMPCFluid(const unsigned int doubletCount, const MPCParticlePositionType *const positions, const MPCParticleVelocityType *const velocities, const Vector3D< MPCParticlePositionType > k, MPCParticleVelocityType *const buffer1, MPCParticleVelocityType *const buffer2)
Calculates the velocity in Fourier space, assuming an MPC fluid consisting of pairs of MPC particles.
Types.hpp
OpenMPCD::CUDA::MPCFluid::DeviceCode::calculateVelocityInFourierSpace_tripletMPCFluid
const Vector3D< std::complex< MPCParticleVelocityType > > calculateVelocityInFourierSpace_tripletMPCFluid(const unsigned int tripletCount, const MPCParticlePositionType *const positions, const MPCParticleVelocityType *const velocities, const Vector3D< MPCParticlePositionType > k, MPCParticleVelocityType *const buffer1, MPCParticleVelocityType *const buffer2)
Calculates the velocity in Fourier space, assuming an MPC fluid consisting of triplets of MPC particl...
OpenMPCD::CUDA::MPCFluid::DeviceCode::calculateVelocityInFourierSpace_simpleMPCFluid
const Vector3D< std::complex< MPCParticleVelocityType > > calculateVelocityInFourierSpace_simpleMPCFluid(const unsigned int particleCount, const MPCParticlePositionType *const positions, const MPCParticleVelocityType *const velocities, const Vector3D< MPCParticlePositionType > k, MPCParticleVelocityType *const buffer1, MPCParticleVelocityType *const buffer2)
Calculates the velocity in Fourier space, assuming a simple MPC fluid.
OpenMPCD::CUDA::MPCFluid::DeviceCode::calculateVelocityInFourierSpace_chainMPCFluid
const Vector3D< std::complex< MPCParticleVelocityType > > calculateVelocityInFourierSpace_chainMPCFluid(const unsigned int chainCount, const unsigned int chainLength, const MPCParticlePositionType *const positions, const MPCParticleVelocityType *const velocities, const Vector3D< MPCParticlePositionType > k, MPCParticleVelocityType *const buffer1, MPCParticleVelocityType *const buffer2)
Calculates the velocity in Fourier space, assuming an MPC fluid consisting of chains of MPC particles...
OpenMPCD::CUDA::MPCFluid::DeviceCode::calculateVelocityInFourierSpace_doubletMPCFluid_single
__global__ void calculateVelocityInFourierSpace_doubletMPCFluid_single(const unsigned int workUnitOffset, const MPCParticlePositionType *const positions, const MPCParticleVelocityType *const velocities, const Vector3D< MPCParticlePositionType > k, MPCParticleVelocityType *const realBuffer, MPCParticleVelocityType *const imaginaryBuffer)
Device function for calculation of summands of the real and imaginary part of the velocity in Fourier...