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

Commit a2fbeab

Browse files
Merge pull request #513 from xtalax/completedifferences
Added complete upwind differences
2 parents a39305c + 5f697dc commit a2fbeab

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

src/derivative_operators/derivative_operator.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ function UpwindDifference{N}(derivative_order::Int,
324324
)
325325
end
326326

327+
327328
# TODO implement the non-uniform grid
328329
function UpwindDifference{N}(derivative_order::Int,
329330
approximation_order::Int, dx::AbstractVector{T},
@@ -407,20 +408,20 @@ function CompleteUpwindDifference(derivative_order::Int,
407408
high_boundary_x = 0.0:-1.0:-(boundary_stencil_length-1.0)
408409
R_boundary_deriv_spots = 0.0:-1.0:-(boundary_stencil_length-2.0)
409410
_high_boundary_coefs = SVector{boundary_stencil_length, T}[convert(SVector{boundary_stencil_length, T}, ((-1/dx)^derivative_order) * calculate_weights(derivative_order, oneunit(T)*x0, high_boundary_x)) for x0 in R_boundary_deriv_spots]
410-
high_boundary_coefs = convert(SVector{boundary_point_count + offside},_high_boundary_coefs)
411+
high_boundary_coefs = convert(SVector{boundary_point_count + offside},reverse(_high_boundary_coefs))
411412

412-
coefficients = fill!(Vector{T}(undef,len),0)
413+
coefficients = nothing
413414

414415

415-
DerivativeOperator{T,N,true,T,typeof(stencil_coefs),
416-
typeof(low_boundary_coefs),typeof(high_boundary_coefs),Vector{T},
417-
typeof(coeff_func)}(
418-
derivative_order, approximation_order, dx, len, stencil_length,
416+
DerivativeOperator{T,Nothing,true,T,typeof(stencil_coefs),
417+
typeof(low_boundary_coefs),typeof(high_boundary_coefs),Nothing,
418+
Nothing}(
419+
derivative_order, approximation_order, dx, 1, stencil_length,
419420
stencil_coefs,
420421
boundary_stencil_length,
421422
boundary_point_count,
422423
low_boundary_coefs,
423-
high_boundary_coefs,offside,coefficients,coeff_func
424+
high_boundary_coefs,offside,coefficients,nothing
424425
)
425426
end
426427

test/DerivativeOperators/derivative_operators_interface.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,25 @@ end
171171

172172
end
173173

174+
@testset "Correctness of Uniform Upwind Stencils" begin
175+
weights = (
176+
(
177+
[-1.0, 1.0],
178+
[-1., 3., -3., 1.]
179+
),
180+
(
181+
[-3/2, 2., -1/2],
182+
[-5/2, 9., -12., 7., -3/2]
183+
)
184+
)
185+
for (i,a) in enumerate(1:2)
186+
for (j,d) in enumerate([1,3])
187+
D = CompleteUpwindDifference(d,a,1.0,0)
188+
@test all(isapprox.(D.stencil_coefs, weights[i][j], atol=1e-10))
189+
end
190+
end
191+
end
192+
174193

175194
@testset "Correctness of Non-Uniform Stencils" begin
176195
x = [0., 0.08, 0.1, 0.15, 0.19, 0.26, 0.29]

0 commit comments

Comments
 (0)