2 * Copyright 1993-2013 NVIDIA Corporation. All rights reserved.
4 * Please refer to the NVIDIA end user license agreement (EULA) associated
5 * with this source code for terms and conditions that govern your use of
6 * this software. Any use, reproduction, disclosure, or distribution of
7 * this software and related documentation outside the terms of the EULA
8 * is strictly prohibited.
11 #ifndef __STABLEFLUIDS_KERNELS_CUH_
12 #define __STABLEFLUIDS_KERNELS_CUH_
14 // Vector data type used to velocity and force fields
17 void setupTexture(int x, int y);
18 void bindTexture(void);
19 void unbindTexture(void);
20 void updateTexture(cData *data, size_t w, size_t h, size_t pitch);
21 void deleteTexture(void);
23 // This method adds constant force vectors to the velocity field
24 // stored in 'v' according to v(x,t+1) = v(x,t) + dt * f.
26 addForces_k(cData *v, int dx, int dy, int spx, int spy, float fx, float fy, int r, size_t pitch);
28 // This method performs the velocity advection step, where we
29 // trace velocity vectors back in time to update each grid cell.
30 // That is, v(x,t+1) = v(p(x,-dt),t). Here we perform bilinear
31 // interpolation in the velocity space.
33 advectVelocity_k(cData *v, float *vx, float *vy,
34 int dx, int pdx, int dy, float dt, int lb);
36 // This method performs velocity diffusion and forces mass conservation
37 // in the frequency domain. The inputs 'vx' and 'vy' are complex-valued
38 // arrays holding the Fourier coefficients of the velocity field in
39 // X and Y. Diffusion in this space takes a simple form described as:
40 // v(k,t) = v(k,t) / (1 + visc * dt * k^2), where visc is the viscosity,
41 // and k is the wavenumber. The projection step forces the Fourier
42 // velocity vectors to be orthogonal to the wave wave vectors for each
43 // wavenumber: v(k,t) = v(k,t) - ((k dot v(k,t) * k) / k^2.
45 diffuseProject_k(cData *vx, cData *vy, int dx, int dy, float dt,
48 // This method updates the velocity field 'v' using the two complex
49 // arrays from the previous step: 'vx' and 'vy'. Here we scale the
50 // real components by 1/(dx*dy) to account for an unnormalized FFT.
52 updateVelocity_k(cData *v, float *vx, float *vy,
53 int dx, int pdx, int dy, int lb, size_t pitch);
55 // This method updates the particles by moving particle positions
56 // according to the velocity field and time step. That is, for each
57 // particle: p(t+1) = p(t) + dt * v(p(t)).
59 advectParticles_k(cData *part, cData *v, int dx, int dy,
60 float dt, int lb, size_t pitch);