OpenMPCD
CUDA/DeviceCode/NormalMode.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * Declares functionality in the `OpenMPCD::CUDA::DeviceCode::NormalMode`
4  * namespace.
5  */
6 
7 #ifndef OPENMPCD_CUDA_DEVICECODE_NORMALMODE_HPP
8 #define OPENMPCD_CUDA_DEVICECODE_NORMALMODE_HPP
9 
10 #include <OpenMPCD/CUDA/Macros.hpp>
11 #include <OpenMPCD/Vector3D.hpp>
12 
13 namespace OpenMPCD
14 {
15 namespace CUDA
16 {
17 namespace DeviceCode
18 {
19 
20 /**
21  * Namespace for CUDA Device functionality related to normal modes.
22  *
23  * @see OpenMPCD::NormalMode
24  */
25 namespace NormalMode
26 {
27 
28 /**
29  * Calculates a normal coordinate.
30  *
31  * @see OpenMPCD::NormalMode
32  *
33  * @tparam T The underlying floating-point data type.
34  *
35  * @param[in] i
36  * The index of the normal coordinate to compute, which must lie in
37  * the range `[0, N]`.
38  * @param[in] vectors
39  * The input vectors to use. Must be a non-`nullptr` Device pointer
40  * pointing to at least `N` instances.
41  * @param[in] N
42  * The number of input coordinate vectors, which must not be `0`.
43  * @param[in] shift
44  * The shift parameter \f$ S \f$.
45  */
46 template<typename T>
48 const Vector3D<T> computeNormalCoordinate(
49  const unsigned int i, const Vector3D<T>* const vectors,
50  const std::size_t N, const T shift = 0);
51 
52 /**
53  * Calculates a normal coordinate.
54  *
55  * @see OpenMPCD::NormalMode
56  *
57  * @tparam T The underlying floating-point data type.
58  *
59  * @param[in] i
60  * The index of the normal coordinate to compute, which must lie in
61  * the range `[0, N]`.
62  * @param[in] vectors
63  * The input vectors to use. Must be a non-`nullptr` Device pointer
64  * pointing to at least `3 * N` instances, which will be interpreted
65  * as `N` three-dimensional vectors, with the first three instances
66  * belonging to the first vector, and so forth.
67  * @param[in] N
68  * The number of input coordinate vectors, which must not be `0`.
69  * @param[in] shift
70  * The shift parameter \f$ S \f$.
71  */
72 template<typename T>
74 const Vector3D<T> computeNormalCoordinate(
75  const unsigned int i, const T* const vectors, const std::size_t N,
76  const T shift = 0);
77 
78 /**
79  * Calculates all normal coordinates for the given array of vectors.
80  *
81  * @see OpenMPCD::NormalMode
82  *
83  * @tparam T The underlying floating-point data type.
84  *
85  * @param[in] vectors
86  * The input vectors to use. Must be a non-`nullptr` Device pointer
87  * pointing to at least `3 * N` instances, which will be interpreted
88  * as `N` three-dimensional vectors, with the first three instances
89  * belonging to the first vector, and so forth.
90  * @param[in] N
91  * The number of input coordinate vectors, which must not be `0`.
92  * @param[out] result
93  * Buffer to store the results into. Must be a non-`nullptr` Device
94  * pointer pointing to at least `3 * (N + 1)` instances. The first
95  * three instances will be set to the three coordinates of the
96  * normal mode with index `0`, i.e. \f$ \vec{q}_0 \f$, and so forth
97  * for all normal modes up to and including \f$ \vec{q}_N \f$, where
98  * \f$ N \f$ is the function parameter `N`.
99  * @param[in] shift
100  * The shift parameter \f$ S \f$.
101  */
102 template<typename T>
105  const T* const vectors, const std::size_t N, T* const result,
106  const T shift = 0);
107 
108 /**
109  * Calculates all normal coordinates for a number of polymer chains stored
110  * contiguously in memory.
111  *
112  * @see OpenMPCD::NormalMode
113  *
114  * @tparam T The underlying floating-point data type.
115  *
116  * @param[in] workUnitOffset
117  * The number of chains to skip.
118  * @param[in] chainLength
119  * The number of particles in a chain, which must be greater than
120  * `0`.
121  * @param[in] chainCount
122  * The number of chains present.
123  * @param[in] positions
124  * The Device array of particle positions.
125  * It is assumed that first, the `x`, `y`, and `z` coordinates of
126  * the first chain's first particle are stored, followed by the
127  * first chain's second particle, and so forth, up to the first
128  * chain's last particle. After that, the second chain's particles
129  * follow in a similar fashion.
130  * @param[out] normalModeCoordinates
131  * A Device buffer that holds at least
132  * `3 * chainCount * (chainLength + 1)` elements, where the
133  * calculated normal mode coordinates will be saved.
134  * First, the normal mode coordinates of the first chain will be
135  * saved (starting with the `x`, `y`, and `z` coordinate of the
136  * normal mode `0`, followed by mode `1`, up to and including mode
137  * `N`), followed by the second chain, and so forth.
138  * @param[in] shift
139  * The shift parameter \f$ S \f$.
140  */
141 template<typename T>
142 __global__ void computeNormalCoordinates(
143  const unsigned int workUnitOffset,
144  const unsigned int chainLength,
145  const unsigned int chainCount,
146  const T* const positions,
147  T* const normalModeCoordinates,
148  const T shift = 0);
149 
150 } //namespace NormalMode
151 } //namespace DeviceCode
152 } //namespace CUDA
153 } //namespace OpenMPCD
154 
155 
157 
158 #endif //OPENMPCD_CUDA_DEVICECODE_NORMALMODE_HPP
OpenMPCD::CUDA::DeviceCode::NormalMode::computeNormalCoordinates
OPENMPCD_CUDA_DEVICE void computeNormalCoordinates(const T *const vectors, const std::size_t N, T *const result, const T shift)
Calculates all normal coordinates for the given array of vectors.
Definition: CUDA/DeviceCode/ImplementationDetails/NormalMode.hpp:79
NormalMode.hpp
OPENMPCD_CUDA_DEVICE
#define OPENMPCD_CUDA_DEVICE
Denotes a function to be callable from a CUDA Device.
Definition: Macros.hpp:25
Vector3D.hpp
OpenMPCD::CUDA::DeviceCode::NormalMode::computeNormalCoordinate
const OPENMPCD_CUDA_DEVICE Vector3D< T > computeNormalCoordinate(const unsigned int i, const Vector3D< T > *const vectors, const std::size_t N, const T shift)
Calculates a normal coordinate.
Definition: CUDA/DeviceCode/ImplementationDetails/NormalMode.hpp:28
Macros.hpp