Skip to content

Commit 497f972

Browse files
Dougal-sranocha
andauthored
fix addition of DerivativeCoefficientRows with different Start values (#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 <[email protected]>
1 parent b98874b commit 497f972

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SummationByPartsOperators"
22
uuid = "9f78cca6-572e-554e-b819-917d2f1cf240"
33
author = ["Hendrik Ranocha"]
4-
version = "0.5.59"
4+
version = "0.5.60"
55

66
[deps]
77
ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197"

src/SBP_operators.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ function Base.:+(coef_row1::DerivativeCoefficientRow{T,Start1,Length1}, coef_row
141141
Length = End - Start
142142
row = SVector{Length,T}(ntuple(i -> zero(T), Length))
143143
for i in 1:Length1
144-
j = i-Start1+Start
144+
j = i+Start1-Start
145145
row = Base.setindex(row, row[j] + coef_row1.coef[i], j)
146146
end
147147
for i in 1:Length2
148-
j = i-Start2+Start
148+
j = i+Start2-Start
149149
row = Base.setindex(row, row[j] + coef_row2.coef[i], j)
150150
end
151151
DerivativeCoefficientRow{T,Start,Length}(row)

test/runtests.jl

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const SBP_TEST = get(ENV, "SBP_TEST", "all")
44

55
@time @testset "SummationByPartsOperators.jl tests" begin
66
@time if SBP_TEST == "all" || SBP_TEST == "part1"
7+
@time @testset "Unit Tests" begin include("unit_tests.jl") end
78
@time @testset "Periodic Operators" begin include("periodic_operators_test.jl") end
89
@time @testset "Non-Periodic Operators" begin include("SBP_operators_test.jl") end
910
@time @testset "Dissipation Operators" begin include("dissipation_operators_test.jl") end

test/unit_tests.jl

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Test
2+
using SummationByPartsOperators
3+
4+
@testset "DerivativeCoefficientRow" begin
5+
row1 = SummationByPartsOperators.DerivativeCoefficientRow{Rational,1,3}([1,2,3])
6+
row2 = SummationByPartsOperators.DerivativeCoefficientRow{Rational,1,3}([2,4,6])
7+
row3 = SummationByPartsOperators.DerivativeCoefficientRow{Rational,2,3}([2,4,6])
8+
9+
@test -row1 ==
10+
SummationByPartsOperators.DerivativeCoefficientRow{Rational,1,3}([-1,-2,-3])
11+
12+
@test row1 + row2 ==
13+
SummationByPartsOperators.DerivativeCoefficientRow{Rational,1,3}([3,6,9])
14+
15+
@test row1 + row3 ==
16+
SummationByPartsOperators.DerivativeCoefficientRow{Rational,1,4}([1,4,7,6])
17+
18+
@test row1 / 2 ==
19+
SummationByPartsOperators.DerivativeCoefficientRow{Rational,1,3}([1//2, 2//2, 3//2])
20+
21+
@test (row1 + -row3) / 2 ==
22+
SummationByPartsOperators.DerivativeCoefficientRow{Rational,1,4}([1//2, 0, -1//2, -3])
23+
end

0 commit comments

Comments
 (0)