-
Notifications
You must be signed in to change notification settings - Fork 5
Use d_prototype
when solving PDSProblem
s
#99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
SKopecz
wants to merge
4
commits into
main
Choose a base branch
from
sk/d_prototype
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4502d9e
All (SSP)MPRK algorithms use to initialize destruction vectors when …
SKopecz e2059d3
bug fix: undefined DType
SKopecz 25a2f9c
Updated doc strings mentioning p_prototype or d_prototype
SKopecz 2bf3d06
Added test to check types of prototypes in caches
SKopecz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1263,6 +1263,84 @@ end | |
end | ||
end | ||
|
||
# Here we check that the types of p_prototype and d_prototype actually | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we should also keep this test (without the d_prototype parts) ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes 👍 |
||
# define the types of the Ps and Ds inside the algorithm caches. | ||
# We test sparse, tridiagonal and dense matrices as well as sparse and | ||
# dense vectors | ||
@testset "Prototype type check" begin | ||
#prod and dest functions | ||
prod_inner! = (P, u, p, t) -> begin | ||
fill!(P, zero(eltype(P))) | ||
for i in 1:(length(u) - 1) | ||
P[i, i + 1] = i * u[i] | ||
end | ||
return nothing | ||
end | ||
prod_sparse! = (P, u, p, t) -> begin | ||
@test P isa SparseMatrixCSC | ||
prod_inner!(P, u, p, t) | ||
return nothing | ||
end | ||
prod_tridiagonal! = (P, u, p, t) -> begin | ||
@test P isa Tridiagonal | ||
prod_inner!(P, u, p, t) | ||
return nothing | ||
end | ||
prod_dense! = (P, u, p, t) -> begin | ||
@test P isa Matrix | ||
prod_inner!(P, u, p, t) | ||
return nothing | ||
end | ||
dest_sparse! = (D, u, p, t) -> begin | ||
@test D isa SparseVector | ||
fill!(D, zero(eltype(D))) | ||
end | ||
dest_dense! = (D, u, p, t) -> begin | ||
@test D isa Vector | ||
fill!(D, zero(eltype(D))) | ||
end | ||
#prototypes | ||
P_tridiagonal = Tridiagonal([0.1, 0.2, 0.3], | ||
[0.0, 0.0, 0.0, 0.0], | ||
[0.4, 0.5, 0.6]) | ||
P_dense = Matrix(P_tridiagonal) | ||
P_sparse = sparse(P_tridiagonal) | ||
D_sparse = spzeros(4) | ||
D_dense = Vector(D_sparse) | ||
# problem definition | ||
u0 = [1.0, 1.5, 2.0, 2.5] | ||
tspan = (0.0, 1.0) | ||
dt = 0.5 | ||
## conservative PDS | ||
prob_default = ConservativePDSProblem(prod_dense!, u0, tspan) | ||
prob_tridiagonal = ConservativePDSProblem(prod_tridiagonal!, u0, tspan; | ||
p_prototype = P_tridiagonal) | ||
prob_dense = ConservativePDSProblem(prod_dense!, u0, tspan; | ||
p_prototype = P_dense) | ||
prob_sparse = ConservativePDSProblem(prod_sparse!, u0, tspan; | ||
p_prototype = P_sparse) | ||
## nonconservative PDS | ||
prob_default2 = PDSProblem(prod_dense!, dest_dense!, u0, tspan) | ||
prob_tridiagonal2 = PDSProblem(prod_tridiagonal!, dest_dense!, u0, tspan; | ||
p_prototype = P_tridiagonal) | ||
prob_dense2 = PDSProblem(prod_dense!, dest_dense!, u0, tspan; | ||
p_prototype = P_dense, | ||
d_prototype = D_dense) | ||
prob_sparse2 = PDSProblem(prod_sparse!, dest_sparse!, u0, tspan; | ||
p_prototype = P_sparse, | ||
d_prototype = D_sparse) | ||
for alg in (MPE(), MPRK22(0.5), MPRK22(1.0), MPRK43I(1.0, 0.5), | ||
MPRK43I(0.5, 0.75), | ||
MPRK43II(2.0 / 3.0), MPRK43II(0.5), SSPMPRK22(0.5, 1.0), | ||
SSPMPRK43()) | ||
for prob in (prob_default, prob_tridiagonal, prob_dense, prob_sparse, | ||
prob_default2, | ||
prob_tridiagonal2, prob_dense2, prob_sparse2) | ||
solve(prob, alg; dt, adaptive = false) | ||
end | ||
end | ||
end | ||
|
||
# Here we check the convergence order of pth-order schemes for which | ||
# no interpolation of order p is available | ||
@testset "Convergence tests (conservative)" begin | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should definitely merge these documentation clarifications!