Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Commit 473d512

Browse files
committed
tests passing
1 parent e5a3da2 commit 473d512

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/derivative_operators/derivative_operator.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,10 @@ function CompleteHalfCenteredDifference(derivative_order::Int,
220220
left_boundary_x = 1:(boundary_stencil_length)
221221
right_boundary_x = reverse(-boundary_stencil_length:-1)
222222

223+
boundary_point_count = div(centered_stencil_length,2) # -1 due to the ghost point
223224
# ? Is fornberg valid when taking an x0 outside of the stencil i.e at the boundary?
224-
xoffset = 1.5:boundary_stencil_length-0.5
225+
xoffset = range(1.5, length=boundary_point_count, step = 1.0)
225226

226-
boundary_point_count = div(centered_stencil_length,2) # -1 due to the ghost point
227227
# Because it's a N x (N+2) operator, the last stencil on the sides are the [b,0,x,x,x,x] stencils, not the [0,x,x,x,x,x] stencils, since we're never solving for the derivative at the boundary point.
228228
#deriv_spots = (-div(stencil_length,2)+1) : -1 # unused
229229
L_boundary_deriv_spots = xoffset[1:div(centered_stencil_length,2)]

test/DerivativeOperators/derivative_operators_interface.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,34 @@ end
144144
@test BandedMatrix(L) correct
145145
end
146146

147+
@testset "Correctness of Uniform Stencils, Complete" begin
148+
weights = []
149+
150+
push!(weights, ([-0.5,0,0.5], [1.,-2.,1.], [-1/2,1.,0.,-1.,1/2]))
151+
push!(weights, ([1/12, -2/3,0,2/3,-1/12], [-1/12,4/3,-5/2,4/3,-1/12], [1/8,-1.,13/8,0.,-13/8,1.,-1/8]))
152+
153+
for d in 1:3
154+
for (i,a) in enumerate([2,4])
155+
D = CompleteCenteredDifference(d,a,1.0)
156+
157+
@test all(isapprox.(D.stencil_coefs, weights[i][d], atol=1e-10))
158+
end
159+
end
160+
end
161+
162+
@testset "Correctness of Uniform Stencils, Complete Half" begin
163+
weights = (([.5, .5], [-1/16, 9/16, 9/16, -1/16]),
164+
([-1., 1.], [1/24, -9/8, 9/8, -1/24]))
165+
for (i,a) in enumerate([2,4])
166+
for d in 0:1
167+
D = CompleteHalfCenteredDifference(d,a,1.0)
168+
@test all(D.stencil_coefs .≈ weights[d+1][i])
169+
end
170+
end
171+
172+
end
173+
174+
147175
@testset "Correctness of Non-Uniform Stencils" begin
148176
x = [0., 0.08, 0.1, 0.15, 0.19, 0.26, 0.29]
149177
nx = length(x)

0 commit comments

Comments
 (0)