Skip to content

Commit dd4a349

Browse files
authored
Merge pull request #360 from FourierFlows/ncc-ap/filteredLSRK54
Add `FilteredLSRK54TimeStepper` + upgrades to Documenter v1
2 parents a26ed3a + 0d544c8 commit dd4a349

File tree

6 files changed

+60
-15
lines changed

6 files changed

+60
-15
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = ["Gregory L. Wagner <wagner.greg@gmail.com>", "Navid C. Constantinou <
66
description = "Tools for building fast, hackable, pseudospectral partial differential equation solvers on periodic domains."
77
documentation = "https://fourierflows.github.io/FourierFlowsDocumentation/stable/"
88
repository = "https://github.com/FourierFlows/FourierFlows.jl"
9-
version = "0.10.3"
9+
version = "0.10.4"
1010

1111
[deps]
1212
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"

docs/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
99

1010
[compat]
1111
CairoMakie = "0.10"
12+
Documenter = "1"
13+
DocumenterCitations = "1.1"
1214
Literate = "≥2.9.0"

docs/make.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,16 @@ pages = [
6262
"References" => "references.md",
6363
]
6464

65-
makedocs(bib, sitename = "FourierFlows.jl",
66-
authors = "Gregory L. Wagner and Navid C. Constantinou and contributors",
67-
modules = [FourierFlows],
68-
format = format,
69-
pages = pages,
70-
doctest = false,
71-
strict = :doctest,
72-
clean = true,
73-
checkdocs = :exports)
65+
makedocs(sitename = "FourierFlows.jl",
66+
authors = "Gregory L. Wagner, Navid C. Constantinou, and contributors",
67+
modules = [FourierFlows],
68+
format = format,
69+
pages = pages,
70+
plugins = [bib],
71+
doctest = true,
72+
warnonly = [:cross_references],
73+
clean = true,
74+
checkdocs = :exports)
7475

7576
@info "Cleaning up temporary .jld2 and .nc files created by doctests or literated examples..."
7677

src/FourierFlows.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export
5252
RK4TimeStepper,
5353
FilteredRK4TimeStepper,
5454
LSRK54TimeStepper,
55+
FilteredLSRK54TimeStepper,
5556
ETDRK4TimeStepper,
5657
FilteredETDRK4TimeStepper,
5758
AB3TimeStepper,

src/timesteppers.jl

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ function stepforward!(prob::Problem, diags, nsteps::Int)
3434
return nothing
3535
end
3636

37-
const fullyexplicitsteppers= [
37+
const fullyexplicitsteppers = [
3838
:ForwardEuler,
3939
:RK4,
4040
:AB3,
41+
:LSRK54,
4142
:FilteredForwardEuler,
4243
:FilteredRK4,
4344
:FilteredAB3,
44-
:LSRK54
45+
:FilteredLSRK54
4546
]
4647

4748
isexplicit(stepper) = any(Symbol(stepper) .== fullyexplicitsteppers)
@@ -75,6 +76,7 @@ end
7576
# * RK4
7677
# * Filtered RK4
7778
# * LSRK54
79+
# * Filtered LSRK54
7880
# * ETDRK4
7981
# * Filtered ETDRK4
8082
# * AB3
@@ -350,15 +352,43 @@ function LSRK54TimeStepper(equation::Equation, dev::Device=CPU())
350352
return LSRK54TimeStepper(S², RHS, Tuple(A), Tuple(B), Tuple(C))
351353
end
352354

355+
"""
356+
struct FilteredLSRK54TimeStepper{T,V,Tf} <: AbstractTimeStepper{T}
357+
358+
A 4th-order 5-stages low-storage Runge-Kutta timestepper with spectral filtering.
359+
See [`LSRK54TimeStepper`](@ref).
360+
"""
361+
struct FilteredLSRK54TimeStepper{T,V,Tf} <: AbstractTimeStepper{T}
362+
:: T
363+
RHS :: T
364+
A :: V
365+
B :: V
366+
C :: V
367+
filter :: Tf
368+
end
369+
370+
"""
371+
FilteredRK4TimeStepper(equation::Equation, dev::Device=CPU(); filterkwargs...)
372+
373+
Construct a 4th-order 5-stages 2-storage Runge-Kutta timestepper with spectral filtering
374+
for `equation` on device `dev`.
375+
"""
376+
function FilteredLSRK54TimeStepper(equation::Equation, dev::Device=CPU(); filterkwargs...)
377+
ts = LSRK54TimeStepper(equation, dev)
378+
filter = makefilter(equation; filterkwargs...)
379+
380+
return FilteredLSRK54TimeStepper(getfield.(Ref(ts), fieldnames(typeof(ts)))..., filter)
381+
end
382+
353383
function LSRK54update!(sol, clock, ts, equation, vars, params, grid, t, dt)
354384
@. ts.= 0
355385

356386
for i = 1:5
357-
equation.calcN!(ts.RHS, sol, t + ts.C[i] * dt , clock, vars, params, grid)
387+
@inbounds equation.calcN!(ts.RHS, sol, t + ts.C[i] * dt , clock, vars, params, grid)
358388
addlinearterm!(ts.RHS, equation.L, sol)
359389

360-
@. ts.= ts.A[i] * ts.+ dt * ts.RHS
361-
@. sol += ts.B[i] * ts.
390+
@. ts.= @inbounds ts.A[i] * ts.+ dt * ts.RHS
391+
@. sol += @inbounds ts.B[i] * ts.
362392
end
363393

364394
return nothing
@@ -373,6 +403,16 @@ function stepforward!(sol, clock, ts::LSRK54TimeStepper, equation, vars, params,
373403
return nothing
374404
end
375405

406+
function stepforward!(sol, clock, ts::FilteredLSRK54TimeStepper, equation, vars, params, grid)
407+
LSRK54update!(sol, clock, ts, equation, vars, params, grid, clock.t, clock.dt)
408+
@. sol *= ts.filter
409+
410+
clock.t += clock.dt
411+
clock.step += 1
412+
413+
return nothing
414+
end
415+
376416
# --
377417
# ETDRK4
378418
# --

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const steppers = [
3131
"AB3",
3232
"FilteredForwardEuler",
3333
"FilteredRK4",
34+
"FilteredLSRK54",
3435
"FilteredETDRK4",
3536
"FilteredAB3"
3637
]

0 commit comments

Comments
 (0)