-
Beta Was this translation helpful? Give feedback.
Answered by
navidcy
Mar 24, 2025
Replies: 1 comment 2 replies
-
Hi @dlemasqu! The problem is not with the dealiasing but I do thing that it stems from that line. This MWE: using GeophysicalFlows, Random, GLMakie
n = 128
L = 2π
forcing_wavenumber = 14.0 * 2π/L # the forcing wavenumber, `k_f`, for a spectrum that is a ring in wavenumber space
forcing_bandwidth = 1.5 * 2π/L # the width of the forcing spectrum, `δ_f`
grid = TwoDGrid(nx=n, Lx=L)
K = @. sqrt(grid.Krsq) # a 2D array with the total wavenumber
forcing_spectrum = @. exp(-(K - forcing_wavenumber)^2 / (2 * forcing_bandwidth^2))
forcing_spectrum[grid.Krsq .== 0] .= 0 # ensure forcing has zero domain-average
X, Y = gridpoints(grid)
σy = 0.5
y0 = 0.1
gaussian_mask = @. exp( - (Y - y0)^2 / 2σy^2)
function calcF!(Fh, grid)
randn!(Fh)
@. Fh *= sqrt(forcing_spectrum)
F = irfft(Fh, grid.nx)
@. F *= gaussian_mask
Fh .= rfft(F)
return nothing
end
Fh = zeros(Complex{eltype(grid)}, (grid.nkr, grid.nl))
calcF!(Fh, grid)
heatmap(irfft(Fh, grid.nx))
produces If you wanted to apply the timestepper filter you'd have to do something like: Fh .= prob.timestepper.filter .* rfft(F) without the |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
dlemasqu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @dlemasqu!
The problem is not with the dealiasing but I do thing that it stems from that line.
But the issue is that you have the
@.
at the front which implies that all methods and operations are to be applied element-wise. And thus you are trying to apply therfft
element-wise? I think that's the issue...This MWE: