Skip to content

Commit

Permalink
add FilteredLSRK54TimeStepper
Browse files Browse the repository at this point in the history
  • Loading branch information
navidcy committed Oct 18, 2023
1 parent a26ed3a commit c6fa3c1
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/timesteppers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,33 @@ function LSRK54TimeStepper(equation::Equation, dev::Device=CPU())
return LSRK54TimeStepper(S², RHS, Tuple(A), Tuple(B), Tuple(C))
end

"""
struct FilteredRK4TimeStepper{T,Tf} <: AbstractTimeStepper{T}
A 4th-order Runge-Kutta timestepper with spectral filtering. See [`RK4TimeStepper`](@ref).
"""
struct FilteredLSRK54TimeStepper{T,V} <: 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

Expand All @@ -373,6 +400,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

0 comments on commit c6fa3c1

Please sign in to comment.