@@ -27,7 +27,7 @@ Returns a time-stepper type defined by the prefix 'stepper', timestep dt
2727solution sol (used to construct variables with identical type and size as
2828the solution vector), and grid g.
2929"""
30- function autoconstructtimestepper (stepper, dt, sol,
30+ function autoconstructtimestepper (stepper, dt, sol,
3131 g:: AbstractGrid = ZeroDGrid (1 ))
3232 fullsteppername = Symbol (stepper, :TimeStepper )
3333 if stepper ∈ filteredsteppers
4848
4949
5050"""
51- @createarrays T dims a b c
51+ @createarrays T dims a b c
5252
5353Create arrays of all zeros with element type T, size dims, and global names
5454a, b, c (for example). An arbitrary number of arrays may be created.
5555"""
5656macro createarrays (T, dims, vars... )
5757 expr = Expr (:block )
58- append! (expr. args,
58+ append! (expr. args,
5959 [:( $ (esc (var)) = zeros ($ (esc (T)), $ (esc (dims))); ) for var in vars])
6060 expr
6161end
6565This function returns an expression that defines a Composite Type
6666of the AbstractVars variety.
6767"""
68- function structvarsexpr (name, physfields, transfields; soldims= 2 , vardims= 2 ,
69- parent= :AbstractVars )
70-
71- physexprs = [:( $ fld:: Array{Float64,$vardims} )
68+ function structvarsexpr (name, physfields, transfields; soldims= 2 , vardims= 2 ,
69+ parent= :AbstractVars )
70+
71+ physexprs = [:( $ fld:: Array{Float64,$vardims} )
7272 for fld in physfields]
73- transexprs = [:( $ fld:: Array{Complex{Float64},$vardims} )
73+ transexprs = [:( $ fld:: Array{Complex{Float64},$vardims} )
7474 for fld in transfields]
7575
7676 if parent != nothing
@@ -88,7 +88,7 @@ function structvarsexpr(name, physfields, transfields; soldims=2, vardims=2,
8888 end
8989 end
9090 end
91-
91+
9292 expr
9393end
9494
@@ -101,10 +101,10 @@ Return the fftwavenumber vector with length n and domain size L.
101101fftwavenums (n:: Int ; L= 1 ) = 2 π/ L* cat (1 , 0 : n/ 2 , - n/ 2 + 1 : - 1 )
102102
103103
104- """
104+ """
105105 rms(q)
106106
107- Return the root-mean-square of an array.
107+ Return the root-mean-square of an array.
108108"""
109109rms (q) = sqrt (mean (q.^ 2 ))
110110
@@ -152,7 +152,7 @@ function peaked_isotropic_spectrum(nx::Int, npeak::Real; ord=4.0, rms=1.0,
152152end
153153
154154
155- """
155+ """
156156 lambdipole(Ue, R, g; center=(x0, y0))
157157
158158Return a 2D vorticity field corresponding to the Lamb Dipole with
@@ -170,7 +170,8 @@ function lambdipole(Ue::Real, R::Real, g::TwoDGrid; center=(nothing, nothing))
170170 end
171171
172172 # Wavenumber corresponding to radius R and the first bessel func zero.
173- k = 3.8317 / R
173+ # k = 3.8317 / R
174+ k = 3.8317059702075123156 / R
174175 q0 = - 2 * Ue* k/ SpecialFunctions. besselj (0 , k* R)
175176
176177 r = sqrt .((g. X- xc). ^ 2.0 + (g. Y- yc). ^ 2.0 )
@@ -183,12 +184,12 @@ function lambdipole(Ue::Real, R::Real, g::TwoDGrid; center=(nothing, nothing))
183184end
184185
185186
186- """
187+ """
187188 gaussianvortex(q0, R, G; center=(x0, y0))
188189
189190Return a vorticity field with magnitude q0, radius R, and center at
190191center[1], center[2] on a TwoDGrid g corresponding to a 'Gaussian vortex' with
191- Gaussian streamfunction.
192+ Gaussian streamfunction.
192193"""
193194function gaussianvortex (q0:: Real , R:: Real , g:: TwoDGrid ;
194195 center= (nothing , nothing ))
@@ -206,11 +207,11 @@ function gaussianvortex(q0::Real, R::Real, g::TwoDGrid;
206207end
207208
208209
209- """
210+ """
210211 rmsrand(g, rmsval)
211212
212213Return an array of random numbers on a TwoDGrid normalized to have a
213- specifed rms value.
214+ specifed rms value.
214215"""
215216function rmsrand (g:: TwoDGrid , rmsval:: Real )
216217 q = rand (g. nx, g. ny)
@@ -219,7 +220,7 @@ function rmsrand(g::TwoDGrid, rmsval::Real)
219220end
220221
221222
222- """
223+ """
223224 parsevalsum2(uh, g)
224225
225226Calculate ∫u = Σ|uh|² on a 2D grid, where uh is the Fourier transform of u.
@@ -231,27 +232,27 @@ function parsevalsum2(uh, g::TwoDGrid)
231232
232233 if size (uh)[1 ] == g. nkr # uh is conjugate symmetric
233234 U = sum (abs2, uh[1 , :]) # k=0 modes
234- U += 2 * sum (abs2, uh[2 : end , :]) # sum k>0 modes twice
235+ U += 2 * sum (abs2, uh[2 : end , :]) # sum k>0 modes twice
235236 else # count every mode once
236237 U = sum (abs2, uh)
237238 end
238239
239240 norm* U
240241end
241242
242- """
243+ """
243244 parsevalsum(uh, g)
244245
245- Calculate real(Σ uh) on a 2D grid. Accounts for DFT normalization,
246- grid resolution, and whether or not uh is in a conjugate-symmetric form to
246+ Calculate real(Σ uh) on a 2D grid. Accounts for DFT normalization,
247+ grid resolution, and whether or not uh is in a conjugate-symmetric form to
247248save memory.
248- """
249+ """
249250function parsevalsum (uh, g:: TwoDGrid )
250251 norm = g. Lx* g. Ly/ (g. nx^ 2 * g. ny^ 2 ) # weird normalization for dft
251252
252253 if size (uh)[1 ] == g. nkr # uh is conjugate symmetric
253254 U = sum (uh[1 , :]) # k=0 modes
254- U += 2 * sum (uh[2 : end , :]) # sum k>0 modes twice
255+ U += 2 * sum (uh[2 : end , :]) # sum k>0 modes twice
255256 else # count every mode once
256257 U = sum (uh)
257258 end
@@ -298,13 +299,13 @@ end
298299"""
299300 radialspectrum(ah, g; nr=nothing, nθ=nothing, refinement=4)
300301
301- Returns aρ = ∫ ah(ρ,θ) ρ dρ dθ, the radial spectrum of ah known on the
302- Cartesian wavenumber grid (k,l).
302+ Returns aρ = ∫ ah(ρ,θ) ρ dρ dθ, the radial spectrum of ah known on the
303+ Cartesian wavenumber grid (k,l).
303304
304- aρ is found by intepolating ah onto a polar wavenumber grid (ρ,θ), and
305- then integrating over θ to find aρ. The default resolution (n,m) for the
306- polar wave number grid is n=refinement*maximum(nk,nl),
307- m=refinement*maximum(nk,nl), where refinement=4 by default. If
305+ aρ is found by intepolating ah onto a polar wavenumber grid (ρ,θ), and
306+ then integrating over θ to find aρ. The default resolution (n,m) for the
307+ polar wave number grid is n=refinement*maximum(nk,nl),
308+ m=refinement*maximum(nk,nl), where refinement=4 by default. If
308309ah is in conjugate symmetric form only the upper half plane in θ is
309310represented on the polar grid.
310311
@@ -319,7 +320,7 @@ function radialspectrum(ah, g::TwoDGrid; n=nothing, m=nothing, refinement=4)
319320 θ = linspace (- π/ 2 , π/ 2 , m) # θ-grid from k=0 to max(kr)
320321 ahsh = fftshift (ah, 2 ) # shifted ah
321322 ksh = linspace (0 , g. nkr- 1 , g. nkr)* 2 π/ g. Lx
322- else # ordinary form
323+ else # ordinary form
323324 θ = linspace (0 , 2 π, m) # θ grid
324325 ahsh = fftshift (ah, [1 , 2 ]) # shifted ah
325326 ksh = linspace (- g. nk/ 2 + 1 , g. nk/ 2 , g. nk)* 2 π/ g. Lx
@@ -348,7 +349,7 @@ function radialspectrum(ah, g::TwoDGrid; n=nothing, m=nothing, refinement=4)
348349 end
349350 ahρ[1 ] = ah[1 , 1 ] # zeroth mode
350351
351- ρ, ahρ
352+ ρ, ahρ
352353end
353354
354355# Moments and cumulants
0 commit comments