53 const size_t idx,
const TData weight,
const TData *
NEK_RESTRICT velocity,
54 const TData *
NEK_RESTRICT gradient,
const size_t uOffset,
55 const size_t vOffset, [[maybe_unused]]
const size_t wOffset,
56 const size_t dudyOffset, [[maybe_unused]]
const size_t dudzOffset,
57 const size_t dvdxOffset, [[maybe_unused]]
const size_t dvdzOffset,
58 [[maybe_unused]]
const size_t dwdxOffset,
59 [[maybe_unused]]
const size_t dwdyOffset, TData *vals)
61 if constexpr (NDIM == 2)
63 const TData velocitySquared =
64 velocity[uOffset + idx] * velocity[uOffset + idx] +
65 velocity[vOffset + idx] * velocity[vOffset + idx];
67 gradient[dvdxOffset + idx] - gradient[dudyOffset + idx];
69 vals[0] = weight * velocitySquared;
70 vals[1] = weight * (curl * curl);
72 else if constexpr (NDIM == 3)
74 const TData velocitySquared =
75 velocity[uOffset + idx] * velocity[uOffset + idx] +
76 velocity[vOffset + idx] * velocity[vOffset + idx] +
77 velocity[wOffset + idx] * velocity[wOffset + idx];
79 gradient[dwdyOffset + idx] - gradient[dvdzOffset + idx];
81 gradient[dudzOffset + idx] - gradient[dwdxOffset + idx];
83 gradient[dvdxOffset + idx] - gradient[dudyOffset + idx];
85 vals[0] = weight * velocitySquared;
86 vals[1] = weight * (curlX * curlX + curlY * curlY + curlZ * curlZ);
113 const unsigned int velocityComponent0,
114 const unsigned int velocityComponent1,
115 const unsigned int velocityComponent2,
116 const TData *metric,
const TData *planeWeights,
117 const TData *velocity,
const TData *gradient,
118 TData *result,
const unsigned int streamID)
120 static_assert(NDIM == 2 || NDIM == 3,
121 "EnergyOp supports only dimensions 2 and 3.");
124 const size_t compSize = nPlanes * planeSize;
129 const size_t uOffset = velocityComponent0 * compSize;
130 const size_t vOffset = velocityComponent1 * compSize;
131 const size_t wOffset = velocityComponent2 * compSize;
132 const size_t dudyOffset = (velocityComponent0 * NDIM + 1) * compSize;
133 const size_t dudzOffset = (velocityComponent0 * NDIM + 2) * compSize;
134 const size_t dvdxOffset = (velocityComponent1 * NDIM + 0) * compSize;
135 const size_t dvdzOffset = (velocityComponent1 * NDIM + 2) * compSize;
136 const size_t dwdxOffset = (velocityComponent2 * NDIM + 0) * compSize;
137 const size_t dwdyOffset = (velocityComponent2 * NDIM + 1) * compSize;
139 Nektar::parallel_reduce<ExecSpace, false, Nektar::ReduceSum<TData>, 3>(
142 EnergyKernel<NDIM>(idx, metric[idx], velocity, gradient,
143 uOffset, vOffset, wOffset, dudyOffset,
144 dudzOffset, dvdxOffset, dvdzOffset,
145 dwdxOffset, dwdyOffset, vals);
154 const size_t uOffset = velocityComponent0 * compSize;
155 const size_t vOffset = velocityComponent1 * compSize;
156 const size_t wOffset = velocityComponent2 * compSize;
157 const size_t dudyOffset = (velocityComponent0 * NDIM + 1) * compSize;
158 const size_t dudzOffset = (velocityComponent0 * NDIM + 2) * compSize;
159 const size_t dvdxOffset = (velocityComponent1 * NDIM + 0) * compSize;
160 const size_t dvdzOffset = (velocityComponent1 * NDIM + 2) * compSize;
161 const size_t dwdxOffset = (velocityComponent2 * NDIM + 0) * compSize;
162 const size_t dwdyOffset = (velocityComponent2 * NDIM + 1) * compSize;
164 Nektar::parallel_reduce<ExecSpace, false, Nektar::ReduceSum<TData>, 3>(
167 const size_t plane = idx / planeSize;
169 metric[idx - plane * planeSize] * planeWeights[plane];
170 EnergyKernel<NDIM>(idx, weight, velocity, gradient, uOffset,
171 vOffset, wOffset, dudyOffset, dudzOffset,
172 dvdxOffset, dvdzOffset, dwdxOffset,
void EnergyKernelLauncher(const size_t planeSize, const unsigned int nPlanes, const unsigned int velocityComponent0, const unsigned int velocityComponent1, const unsigned int velocityComponent2, const TData *metric, const TData *planeWeights, const TData *velocity, const TData *gradient, TData *result, const unsigned int streamID)
Add the integrals of the squared velocity and vorticity magnitudes and the volume of one block to res...
NEK_HOSTDEVICE_INLINE void EnergyKernel(const size_t idx, const TData weight, const TData *NEK_RESTRICT velocity, const TData *NEK_RESTRICT gradient, const size_t uOffset, const size_t vOffset, const size_t wOffset, const size_t dudyOffset, const size_t dudzOffset, const size_t dvdxOffset, const size_t dvdzOffset, const size_t dwdxOffset, const size_t dwdyOffset, TData *vals)
Write the squared velocity and vorticity magnitudes at storage index idx, and the volume it stands fo...