Skip to content

Commit

Permalink
fft threads?
Browse files Browse the repository at this point in the history
  • Loading branch information
AshtonSBradley committed Apr 18, 2024
1 parent 3063eee commit 517ba49
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
PaddedViews = "5432bcbf-9aad-5242-b902-cca2824c8663"
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
TensorCast = "02d47bb6-7ce6-556a-be16-bb1710789e2b"
Tullio = "bc48ee85-29a4-5162-ae0b-a64e1601d4bc"
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"

Expand All @@ -20,7 +19,6 @@ JLD2 = "0.4"
PaddedViews = "0.5"
QuadGK = "2"
SpecialFunctions = "1, 1.3, 1.4, 2"
TensorCast = "0.4"
Tullio = "0.2, 0.3"
UnPack = "1, 1.0"
julia = "1.8, 1.9, 1.10"
11 changes: 7 additions & 4 deletions src/QuantumFluidSpectra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ module QuantumFluidSpectra
using Tullio
using Hwloc
using FFTW
FFTW.set_num_threads(num_physical_cores())
using SpecialFunctions
using PaddedViews
using UnPack
using TensorCast
FFTW.set_num_threads(8)

# fallback since fast_hypot is 2 argument only
@fastmath hypot(x::Float64, y::Float64, z::Float64)=sqrt(x^2+y^2+z^2)
Expand All @@ -31,8 +30,12 @@ export log10range, convolve
export xk_arrays, fft_differentials
export gradient, velocity, current
export energydecomp, helmholtz, kinetic_density
export incompressible_spectrum, compressible_spectrum, qpressure_spectrum
export incompressible_density, compressible_density, qpressure_density
export incompressible_spectrum,
compressible_spectrum,
qpressure_spectrum
export incompressible_density,
compressible_density,
qpressure_density
export ic_density, iq_density, cq_density
export density_spectrum, trap_spectrum

Expand Down
15 changes: 8 additions & 7 deletions src/analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ Returned fields `Wi`, `Wc` are tuples of cartesian components of incompressible
"""
function helmholtz(wx, wy, kx, ky)
wxk = fft(wx); wyk = fft(wy)
@cast kw[i,j] := (kx[i] * wxk[i,j] + ky[j] * wyk[i,j])/ (kx[i]^2+ky[j]^2)
@cast wxkc[i,j] := kw[i,j] * kx[i]
@cast wykc[i,j] := kw[i,j] * ky[j]
kw = @. (kx * wxk + ky' * wyk)/ (kx^2+ky'^2)
wxkc = @. kw*kx
wykc = @. kw*ky'
wxkc[1] = zero(wxkc[1]); wykc[1] = zero(wykc[1])
wxki = @. wxk - wxkc
wyki = @. wyk - wykc
Expand All @@ -121,10 +121,11 @@ end

function helmholtz(wx, wy, wz, kx, ky, kz)
wxk = fft(wx); wyk = fft(wy); wzk = fft(wz)
@cast kw[i,j,k] := (kx[i] * wxk[i,j,k] + ky[j] * wyk[i,j,k] + kz[k] * wzk[i,j,k])/ (kx[i]^2 + ky[j]^2 + kz[k]^2)
@cast wxkc[i,j,k] := kw[i,j,k] * kx[i]
@cast wykc[i,j,k] := kw[i,j,k] * ky[j]
@cast wzkc[i,j,k] := kw[i,j,k] * kz[k]
kzr = reshape(kz,1,1,length(kz))
kw = @. (kx * wxk + ky' * wyk + kzr * wzk)/ (kx^2 + ky'^2 + kzr^2)
wxkc = @. kw * kx
wykc = @. kw * ky'
wzkc = @. kw * kzr
wxkc[1] = zero(wxkc[1]); wykc[1] = zero(wykc[1]); wzkc[1] = zero(wzkc[1])
wxki = @. wxk - wxkc
wyki = @. wyk - wykc
Expand Down

0 comments on commit 517ba49

Please sign in to comment.