Skip to content

Commit

Permalink
fix 5-arg mul! with empty lower coefficients of periodic operators (#212
Browse files Browse the repository at this point in the history
)

* fix 5-arg mul! with empty lower coefficients of periodic operators

* bump version
  • Loading branch information
ranocha committed Aug 17, 2023
1 parent 13e6343 commit 498d6fe
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SummationByPartsOperators"
uuid = "9f78cca6-572e-554e-b819-917d2f1cf240"
author = ["Hendrik Ranocha"]
version = "0.5.44"
version = "0.5.45"

[deps]
ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197"
Expand Down
12 changes: 8 additions & 4 deletions src/periodic_operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,15 @@ end

ex_upper = :( nothing )
for i in (UpperOffset-1):-1:0
ex = :( lower_coef[$LowerOffset]*u[end-$(i+LowerOffset)] )
for j in LowerOffset-1:-1:1
ex = :( $ex + lower_coef[$j]*u[end-$(j+i)] )
if LowerOffset > 0
ex = :( lower_coef[$LowerOffset]*u[end-$(i+LowerOffset)] )
for j in LowerOffset-1:-1:1
ex = :( $ex + lower_coef[$j]*u[end-$(j+i)] )
end
ex = :( $ex + central_coef*u[end-$i] )
else
ex = :( central_coef*u[end-$i] )
end
ex = :( $ex + central_coef*u[end-$i] )
for j in 1:UpperOffset
if i-j < 0
ex = :( $ex + upper_coef[$j]*u[$(j-i)] )
Expand Down
23 changes: 23 additions & 0 deletions test/upwind_operators_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,26 @@ end
derivative_operator(Mattsson2017(:plus ), 1, acc_order, xmin, xmax, N)
)
end

@testset "Empty lower/upper coefficients" begin
D = upwind_operators(periodic_derivative_operator, accuracy_order = 2,
xmin = 0.0, xmax = 1.0, N = 10)
x = grid(D)
u = @. sinpi(2 * x)

du = zero(u)
@test_nowarn mul!(du, D.minus, u)
@test du D.minus * u
@test_nowarn mul!(du, D.minus, u, 2.0)
@test du 2 * D.minus * u
@test_nowarn mul!(du, D.minus, u, 2.0, 3.0)
@test du 8 * D.minus * u # 5 = 2 + 3 * 2

du = zero(u)
@test_nowarn mul!(du, D.plus, u)
@test du D.plus * u
@test_nowarn mul!(du, D.plus, u, 2.0)
@test du 2 * D.plus * u
@test_nowarn mul!(du, D.plus, u, 2.0, 3.0)
@test du 8 * D.plus * u # 5 = 2 + 3 * 2
end

2 comments on commit 498d6fe

@ranocha
Copy link
Owner 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/89818

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.5.45 -m "<description of version>" 498d6fea4e3ccdcf83bd1e3c616f9590db556a30
git push origin v0.5.45

Please sign in to comment.