Skip to content
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

fix addition of DerivativeCoefficientRows with different Start values #260

Merged
merged 5 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading