Skip to content

Commit

Permalink
fix addition of DerivativeCoefficientRows with different Start values (
Browse files Browse the repository at this point in the history
…#260)

* fix adding DerivativeCoefficientRows with different Start values

* added unit tests for DerivativeCoefficientRow

* move tests to new file

* bump version

---------

Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
  • Loading branch information
Dougal-s and ranocha committed Apr 5, 2024
1 parent b98874b commit 497f972
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 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.59"
version = "0.5.60"

[deps]
ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197"
Expand Down
4 changes: 2 additions & 2 deletions src/SBP_operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ function Base.:+(coef_row1::DerivativeCoefficientRow{T,Start1,Length1}, coef_row
Length = End - Start
row = SVector{Length,T}(ntuple(i -> zero(T), Length))
for i in 1:Length1
j = i-Start1+Start
j = i+Start1-Start
row = Base.setindex(row, row[j] + coef_row1.coef[i], j)
end
for i in 1:Length2
j = i-Start2+Start
j = i+Start2-Start
row = Base.setindex(row, row[j] + coef_row2.coef[i], j)
end
DerivativeCoefficientRow{T,Start,Length}(row)
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const SBP_TEST = get(ENV, "SBP_TEST", "all")

@time @testset "SummationByPartsOperators.jl tests" begin
@time if SBP_TEST == "all" || SBP_TEST == "part1"
@time @testset "Unit Tests" begin include("unit_tests.jl") end
@time @testset "Periodic Operators" begin include("periodic_operators_test.jl") end
@time @testset "Non-Periodic Operators" begin include("SBP_operators_test.jl") end
@time @testset "Dissipation Operators" begin include("dissipation_operators_test.jl") end
Expand Down
23 changes: 23 additions & 0 deletions test/unit_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Test
using SummationByPartsOperators

@testset "DerivativeCoefficientRow" begin
row1 = SummationByPartsOperators.DerivativeCoefficientRow{Rational,1,3}([1,2,3])
row2 = SummationByPartsOperators.DerivativeCoefficientRow{Rational,1,3}([2,4,6])
row3 = SummationByPartsOperators.DerivativeCoefficientRow{Rational,2,3}([2,4,6])

@test -row1 ==
SummationByPartsOperators.DerivativeCoefficientRow{Rational,1,3}([-1,-2,-3])

@test row1 + row2 ==
SummationByPartsOperators.DerivativeCoefficientRow{Rational,1,3}([3,6,9])

@test row1 + row3 ==
SummationByPartsOperators.DerivativeCoefficientRow{Rational,1,4}([1,4,7,6])

@test row1 / 2 ==
SummationByPartsOperators.DerivativeCoefficientRow{Rational,1,3}([1//2, 2//2, 3//2])

@test (row1 + -row3) / 2 ==
SummationByPartsOperators.DerivativeCoefficientRow{Rational,1,4}([1//2, 0, -1//2, -3])
end

2 comments on commit 497f972

@ranocha
Copy link
Owner

@ranocha ranocha commented on 497f972 Apr 5, 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/104291

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.5.60 -m "<description of version>" 497f9728ab0f671dc5284e2e5c2ca808df8e797c
git push origin v0.5.60

Please sign in to comment.