Skip to content

Commit

Permalink
Merge pull request #360 from FourierFlows/ncc-ap/filteredLSRK54
Browse files Browse the repository at this point in the history
Add `FilteredLSRK54TimeStepper` + upgrades to Documenter v1
  • Loading branch information
navidcy committed Oct 19, 2023
2 parents a26ed3a + 0d544c8 commit dd4a349
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Gregory L. Wagner <[email protected]>", "Navid C. Constantinou <
description = "Tools for building fast, hackable, pseudospectral partial differential equation solvers on periodic domains."
documentation = "https://fourierflows.github.io/FourierFlowsDocumentation/stable/"
repository = "https://github.com/FourierFlows/FourierFlows.jl"
version = "0.10.3"
version = "0.10.4"

[deps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Expand Down
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[compat]
CairoMakie = "0.10"
Documenter = "1"
DocumenterCitations = "1.1"
Literate = "≥2.9.0"
19 changes: 10 additions & 9 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,16 @@ pages = [
"References" => "references.md",
]

makedocs(bib, sitename = "FourierFlows.jl",
authors = "Gregory L. Wagner and Navid C. Constantinou and contributors",
modules = [FourierFlows],
format = format,
pages = pages,
doctest = false,
strict = :doctest,
clean = true,
checkdocs = :exports)
makedocs(sitename = "FourierFlows.jl",
authors = "Gregory L. Wagner, Navid C. Constantinou, and contributors",
modules = [FourierFlows],
format = format,
pages = pages,
plugins = [bib],
doctest = true,
warnonly = [:cross_references],
clean = true,
checkdocs = :exports)

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

Expand Down
1 change: 1 addition & 0 deletions src/FourierFlows.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export
RK4TimeStepper,
FilteredRK4TimeStepper,
LSRK54TimeStepper,
FilteredLSRK54TimeStepper,
ETDRK4TimeStepper,
FilteredETDRK4TimeStepper,
AB3TimeStepper,
Expand Down
50 changes: 45 additions & 5 deletions src/timesteppers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ function stepforward!(prob::Problem, diags, nsteps::Int)
return nothing
end

const fullyexplicitsteppers= [
const fullyexplicitsteppers = [
:ForwardEuler,
:RK4,
:AB3,
:LSRK54,
:FilteredForwardEuler,
:FilteredRK4,
:FilteredAB3,
:LSRK54
:FilteredLSRK54
]

isexplicit(stepper) = any(Symbol(stepper) .== fullyexplicitsteppers)
Expand Down Expand Up @@ -75,6 +76,7 @@ end
# * RK4
# * Filtered RK4
# * LSRK54
# * Filtered LSRK54
# * ETDRK4
# * Filtered ETDRK4
# * AB3
Expand Down Expand Up @@ -350,15 +352,43 @@ function LSRK54TimeStepper(equation::Equation, dev::Device=CPU())
return LSRK54TimeStepper(S², RHS, Tuple(A), Tuple(B), Tuple(C))
end

"""
struct FilteredLSRK54TimeStepper{T,V,Tf} <: AbstractTimeStepper{T}
A 4th-order 5-stages low-storage Runge-Kutta timestepper with spectral filtering.
See [`LSRK54TimeStepper`](@ref).
"""
struct FilteredLSRK54TimeStepper{T,V,Tf} <: AbstractTimeStepper{T}
:: T
RHS :: T
A :: V
B :: V
C :: V
filter :: Tf
end

"""
FilteredRK4TimeStepper(equation::Equation, dev::Device=CPU(); filterkwargs...)
Construct a 4th-order 5-stages 2-storage Runge-Kutta timestepper with spectral filtering
for `equation` on device `dev`.
"""
function FilteredLSRK54TimeStepper(equation::Equation, dev::Device=CPU(); filterkwargs...)
ts = LSRK54TimeStepper(equation, dev)
filter = makefilter(equation; filterkwargs...)

return FilteredLSRK54TimeStepper(getfield.(Ref(ts), fieldnames(typeof(ts)))..., filter)
end

function LSRK54update!(sol, clock, ts, equation, vars, params, grid, t, dt)
@. ts.= 0

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

@. ts.= ts.A[i] * ts.+ dt * ts.RHS
@. sol += ts.B[i] * ts.
@. ts.= @inbounds ts.A[i] * ts.+ dt * ts.RHS
@. sol += @inbounds ts.B[i] * ts.
end

return nothing
Expand All @@ -373,6 +403,16 @@ function stepforward!(sol, clock, ts::LSRK54TimeStepper, equation, vars, params,
return nothing
end

function stepforward!(sol, clock, ts::FilteredLSRK54TimeStepper, equation, vars, params, grid)
LSRK54update!(sol, clock, ts, equation, vars, params, grid, clock.t, clock.dt)
@. sol *= ts.filter

clock.t += clock.dt
clock.step += 1

return nothing
end

# --
# ETDRK4
# --
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const steppers = [
"AB3",
"FilteredForwardEuler",
"FilteredRK4",
"FilteredLSRK54",
"FilteredETDRK4",
"FilteredAB3"
]
Expand Down

2 comments on commit dd4a349

@navidcy
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/93721

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.4 -m "<description of version>" dd4a349c414ae2d854bc54ae292f8437db694b1e
git push origin v0.10.4

Please sign in to comment.