A GPU-accelerated pseudo-spectral code for direct numerical simulation of homogeneous isotropic turbulence (HIT). Solves the incompressible Navier-Stokes equations on a 3D periodic domain using pseudo-spectral methods with cuFFT for GPU-accelerated FFTs.
Compile only once with 'make speckle'. Then, to run, say ./run.sh
Edit parameters by adjusting values in the file speckle.input.
| File | Description |
|---|---|
types.h |
Precision typedef (real_t = double), complex type alias (complex_t), TWO_PI constant, CHECK_CUDA and CHECK_CUFFT error macros |
mesh.h/cu |
Grid class — domain geometry, grid spacing, and wavenumber arrays (d_kx, d_ky, d_kz) allocated on device. Designed with local sizes and offsets for future MPI pencil decomposition |
field.h/cu |
Field class — device memory for one scalar velocity component in both physical space (d_phys, real) and spectral space (d_spec, complex). Includes phys_idx and spec_idx helpers callable from host and device |
fft.h/cu |
FFT class — wraps cuFFT cufftPlan3d for 3D R2C (forward) and C2R (inverse) transforms. Inverse transform includes 1/N^3 normalization |
kernels/spectral_ops.cu |
Spectral-space kernels: de-aliasing (2/3 rule), pressure projection, ik multiply for derivatives, viscous term |
kernels/physics_ops.cu |
Physical-space kernels: nonlinear advection term (u·∇u) |
kernels/diagnostics.cu |
Diagnostic kernels: turbulent kinetic energy (TKE), energy spectrum E(k) |
solver/solver.h/cu |
Solver class — Taylor-Green vortex initialization, RK4 time stepping, main run loop |
io/writer.h/cpp |
Output: TKE time series and energy spectrum to file |
| File | Description |
|---|---|
math_test.cu |
Validation tests — currently includes FFT roundtrip test (confirmed max error ~4e-16) |
ml course/cme213/nvhpc/24.1
make clean && makesrun -p gpu-turing ./math_test- FFT roundtrip: max error 4.4e-16 (machine precision)
- Pressure projection: k·u_hat = 0
- TGV initialization: TKE matches analytical value
- Early-time TKE decay: matches Taylor-Green analytical solution
- Energy spectrum: Kolmogorov k^(-5/3) scaling