Skip to content

Commit

Permalink
Merge pull request #86 from SKopecz/SK/SSPMPRK
Browse files Browse the repository at this point in the history
SSPMPRK schemes and small_constant as algorithm field
  • Loading branch information
SKopecz authored Jul 3, 2024
2 parents 0091819 + bd6cdca commit cb10cfd
Show file tree
Hide file tree
Showing 6 changed files with 1,475 additions and 229 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PositiveIntegrators"
uuid = "d1b20bf0-b083-4985-a874-dc5121669aa5"
authors = ["Stefan Kopecz, Hendrik Ranocha, and contributors"]
version = "0.1.14"
version = "0.1.15"

[deps]
FastBroadcast = "7034ab61-46d4-4ed7-9d0f-46aef9175898"
Expand Down
6 changes: 6 additions & 0 deletions src/PositiveIntegrators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export PDSFunction, PDSProblem
export ConservativePDSFunction, ConservativePDSProblem

export MPE, MPRK22, MPRK43I, MPRK43II
export SSPMPRK22, SSPMPRK43

export prob_pds_linmod, prob_pds_linmod_inplace, prob_pds_nonlinmod,
prob_pds_robertson, prob_pds_brusselator, prob_pds_sir,
Expand All @@ -61,6 +62,11 @@ include("proddest.jl")
# modified Patankar-Runge-Kutta (MPRK) methods
include("mprk.jl")

# modified Patankar-Runge-Kutta based on the SSP formulation of RK methods (SSPMPRK)
include("sspmprk.jl")

include("interpolation.jl")

# predefined PDS problems
include("PDSProblemLibrary.jl")

Expand Down
86 changes: 86 additions & 0 deletions src/interpolation.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Linear interpolations
@muladd @inline function linear_interpolant(Θ, dt, u0, u1, idxs::Nothing, T::Type{Val{0}})
Θm1 = (1 - Θ)
@.. broadcast=false Θm1 * u0+Θ * u1
end

@muladd @inline function linear_interpolant(Θ, dt, u0, u1, idxs, T::Type{Val{0}})
Θm1 = (1 - Θ)
@.. broadcast=false Θm1 * u0[idxs]+Θ * u1[idxs]
end

@muladd @inline function linear_interpolant!(out, Θ, dt, u0, u1, idxs::Nothing,
T::Type{Val{0}})
Θm1 = (1 - Θ)
@.. broadcast=false out=Θm1 * u0 + Θ * u1
out
end

@muladd @inline function linear_interpolant!(out, Θ, dt, u0, u1, idxs, T::Type{Val{0}})
Θm1 = (1 - Θ)
@views @.. broadcast=false out=Θm1 * u0[idxs] + Θ * u1[idxs]
out
end

@inline function linear_interpolant(Θ, dt, u0, u1, idxs::Nothing, T::Type{Val{1}})
@.. broadcast=false (u1 - u0)/dt
end

@inline function linear_interpolant(Θ, dt, u0, u1, idxs, T::Type{Val{1}})
@.. broadcast=false (u1[idxs] - u0[idxs])/dt
end

@inline function linear_interpolant!(out, Θ, dt, u0, u1, idxs::Nothing, T::Type{Val{1}})
@.. broadcast=false out=(u1 - u0) / dt
out
end

@inline function linear_interpolant!(out, Θ, dt, u0, u1, idxs, T::Type{Val{1}})
@views @.. broadcast=false out=(u1[idxs] - u0[idxs]) / dt
out
end

#######################################################################################
# interpolation specializations
const MPRKCaches = Union{MPEConstantCache, MPECache, MPEConservativeCache,
MPRK22ConstantCache, MPRK22Cache, MPRK22ConservativeCache,
MPRK43ConstantCache, MPRK43Cache, MPRK43ConservativeCache,
SSPMPRK22ConstantCache, SSPMPRK22Cache, SSPMPRK22ConservativeCache,
SSPMPRK43ConstantCache, SSPMPRK43Cache, SSPMPRK43ConservativeCache}

function interp_summary(::Type{cacheType},
dense::Bool) where {cacheType <: MPRKCaches}
"1st order linear"
end

function _ode_interpolant(Θ, dt, u0, u1, k,
cache::MPRKCaches,
idxs, # Optionally specialize for ::Nothing and others
T::Type{Val{0}},
differential_vars::Nothing)
linear_interpolant(Θ, dt, u0, u1, idxs, T)
end

function _ode_interpolant!(out, Θ, dt, u0, u1, k,
cache::MPRKCaches,
idxs, # Optionally specialize for ::Nothing and others
T::Type{Val{0}},
differential_vars::Nothing)
linear_interpolant!(out, Θ, dt, u0, u1, idxs, T)
end

function _ode_interpolant(Θ, dt, u0, u1, k,
cache::MPRKCaches,
idxs, # Optionally specialize for ::Nothing and others
T::Type{Val{1}},
differential_vars::Nothing)
linear_interpolant(Θ, dt, u0, u1, idxs, T)
end

function _ode_interpolant!(out, Θ, dt, u0, u1, k,
cache::MPRKCaches,
idxs, # Optionally specialize for ::Nothing and others
T::Type{Val{1}},
differential_vars::Nothing)
linear_interpolant!(out, Θ, dt, u0, u1, idxs, T)
end
Loading

2 comments on commit cb10cfd

@ranocha
Copy link
Collaborator

@ranocha ranocha commented on cb10cfd Jul 3, 2024

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/110331

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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.1.15 -m "<description of version>" cb10cfd274be9591838eb8ab7010fc61a6f80e7f
git push origin v0.1.15

Please sign in to comment.