Skip to content

Commit f17430c

Browse files
committed
adds test_plan_flows_fftrfft()
1 parent 02518a9 commit f17430c

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,11 @@ for dev in devices
9595
@test testgridpoints(dev, g₃)
9696
@test testdealias(g₃)
9797
@test testmakefilter(dev, g₃)
98+
@test test_plan_flows_fftrfft(dev)
9899

99100
# Test typed grids
100101
T = Float32
102+
@test test_plan_flows_fftrfft(dev, T=T)
101103
@test testtypedonedgrid(dev, nx, Lx; T=T)
102104
@test testtypedtwodgrid(dev, nx, Lx, ny, Ly; T=T)
103105
@test testtypedthreedgrid(dev, nx, Lx, ny, Ly, nz, Lz; T=T)

test/test_grid.jl

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,35 @@ function testtypedthreedgrid(dev::Device, nx, Lx, ny=nx, Ly=Lx, nz=nx, Lz=Lx; T=
123123
typeof(gr.dx)==T && typeof(gr.dy)==T && typeof(gr.dz)==T && typeof(gr.x[1])==T && typeof(gr.y[1])==T && typeof(gr.z[1])==T && typeof(gr.Lx)==T && typeof(gr.Ly)==T && typeof(gr.Lz)==T && eltype(gr) == T
124124
end
125125

126-
function testmakefilter(dev::Device, g::AbstractGrid{T}) where T
126+
function testmakefilter(dev::Device, g::AbstractGrid)
127+
T = eltype(g)
127128
filter = FourierFlows.makefilter(g)
128129
G = typeof(g)
129130
nofilter = G<:OneDGrid ? filter[@. g.kr*g.dx/π < 0.65] : ( G<:TwoDGrid ? filter[@. sqrt((g.kr*g.dx/π)^2 + (g.l*g.dy/π)^2) < 0.65] : filter[@. sqrt((g.kr*g.dx/π)^2 + (g.l*g.dy/π)^2 + (g.m*g.dz/π)^2) < 0.65] )
130131
fullfilter = G<:OneDGrid ? filter[@. g.kr*g.dx/π > 0.999] : ( G<:TwoDGrid ? filter[@. sqrt((g.kr*g.dx/π)^2 + (g.l*g.dy/π)^2) > 0.999] : filter[@. sqrt((g.kr*g.dx/π)^2 + (g.l*g.dy/π)^2 + (g.m*g.dz/π)^2) > 0.999] )
131132
nofilter== zeros(dev, T, size(nofilter)) .+ 1 && isapprox(fullfilter, zeros(dev, T, size(fullfilter)), atol=1e-12)
132133
end
134+
135+
function test_plan_flows_fftrfft(::CPU; T=Float64)
136+
A = ArrayType(CPU())
137+
return ( typeof(FourierFlows.plan_flows_fft(A(rand(Complex{T}, (4,))))) == FFTW.cFFTWPlan{Complex{T},-1,false,1} &&
138+
typeof(FourierFlows.plan_flows_fft(A(rand(Complex{T}, (4, 6))))) == FFTW.cFFTWPlan{Complex{T},-1,false,2} &&
139+
typeof(FourierFlows.plan_flows_fft(A(rand(Complex{T}, (4, 6, 8))))) == FFTW.cFFTWPlan{Complex{T},-1,false,3} &&
140+
FourierFlows.plan_flows_fft(A(rand(Complex{T}, (4, 6, 8))), [1, 2]).region == [1, 2] &&
141+
typeof(FourierFlows.plan_flows_rfft(A(rand(T, (4,))))) == FFTW.rFFTWPlan{T,-1,false,1} &&
142+
typeof(FourierFlows.plan_flows_rfft(A(rand(T, (4, 6))))) == FFTW.rFFTWPlan{T,-1,false,2} &&
143+
typeof(FourierFlows.plan_flows_rfft(A(rand(T, (4, 6, 8))))) == FFTW.rFFTWPlan{T,-1,false,3} &&
144+
FourierFlows.plan_flows_rfft(A(rand(T, (4, 6, 8))), [1, 2]).region == [1, 2] )
145+
end
146+
147+
function test_plan_flows_fftrfft(::GPU; T=Float64)
148+
A = ArrayType(GPU())
149+
return ( typeof(FourierFlows.plan_flows_fft(A(rand(Complex{T}, (4,))))) == CuArrays.CUFFT.cCuFFTPlan{Complex{T},-1,false,1} &&
150+
typeof(FourierFlows.plan_flows_fft(A(rand(Complex{T}, (4, 6))))) == CuArrays.CUFFT.cCuFFTPlan{Complex{T},-1,false,2} &&
151+
typeof(FourierFlows.plan_flows_fft(A(rand(Complex{T}, (4, 6, 8))))) == CuArrays.CUFFT.cCuFFTPlan{Complex{T},-1,false,3} &&
152+
FourierFlows.plan_flows_fft(A(rand(Complex{T}, (4, 6, 8))), [1, 2]).region == [1, 2] &&
153+
typeof(FourierFlows.plan_flows_rfft(A(rand(T, (4,))))) == CuArrays.CUFFT.rCuFFTPlan{T,-1,false,1} &&
154+
typeof(FourierFlows.plan_flows_rfft(A(rand(T, (4, 6))))) == CuArrays.CUFFT.rCuFFTPlan{T,-1,false,2} &&
155+
typeof(FourierFlows.plan_flows_rfft(A(rand(T, (4, 6, 8))))) == CuArrays.CUFFT.rCuFFTPlan{T,-1,false,3} &&
156+
FourierFlows.plan_flows_rfft(A(rand(T, (4, 6, 8))), [1, 2]).region == [1, 2] )
157+
end

0 commit comments

Comments
 (0)