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

Commit ab62f84

Browse files
committed
Right stencils are mirror images of left ones after all...
1 parent 83b9d74 commit ab62f84

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/derivative_operators/convolutions.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function convolve_BC_right!(x_temp::AbstractVector{T}, x::AbstractVector{T}, A::
8383
slen = length(A.stencil_coefs)
8484
L = A.stencil_length
8585
else
86-
cur_stencil = stencil[end-i+1]
86+
cur_stencil = stencil[i]
8787
slen = length(cur_stencil)
8888
end
8989

@@ -96,7 +96,7 @@ function convolve_BC_right!(x_temp::AbstractVector{T}, x::AbstractVector{T}, A::
9696
xtempi += cur_coeff * cur_stencil[idx] * x[N-L+idx]
9797
end
9898
# @show xtempi*(1/(A.dx^A.derivative_order))
99-
x_temp[end-i+1] = xtempi
99+
x_temp[end-_bpc+i] = xtempi
100100
end
101101
end
102102

@@ -206,7 +206,7 @@ function convolve_BC_right!(x_temp::AbstractVector{T}, _x::BoundaryPaddedVector,
206206
cur_stencil = A.stencil_coefs
207207
slen = length(A.stencil_coefs)
208208
else
209-
cur_stencil = stencil[end-i+1]
209+
cur_stencil = stencil[i]
210210
slen = length(cur_stencil)
211211
end
212212

@@ -222,6 +222,6 @@ function convolve_BC_right!(x_temp::AbstractVector{T}, _x::BoundaryPaddedVector,
222222
# xtempi += cur_coeff * cur_stencil[idx] * _x.u[end-L+idx+1]
223223
# end
224224

225-
x_temp[N-i+1] = xtempi
225+
x_temp[end-_bpc+i] = xtempi
226226
end
227227
end

src/derivative_operators/derivative_operator.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function CenteredDifference{N}(derivative_order::Int,
3838
low_boundary_coefs = convert(SVector{boundary_point_count},_low_boundary_coefs)
3939

4040
_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, reverse(right_boundary_x))) for x0 in R_boundary_deriv_spots]
41-
high_boundary_coefs = convert(SVector{boundary_point_count},_high_boundary_coefs)
41+
high_boundary_coefs = convert(SVector{boundary_point_count},reverse(_high_boundary_coefs))
4242

4343
coefficients = coeff_func isa Nothing ? nothing : Vector{T}(undef,len)
4444
DerivativeOperator{T,N,false,T,typeof(stencil_coefs),

test/bc_coeff_compositions.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ function fourth_deriv_approx_stencil(N)
66
A[1,1:8] = [3.5 -56/3 42.5 -54.0 251/6 -20.0 5.5 -2/3]
77
A[2,1:8] = [2/3 -11/6 0.0 31/6 -22/3 4.5 -4/3 1/6]
88

9-
A[N-1,N-5:end] = reverse([3.5 -56/3 42.5 -54.0 251/6 -20.0 5.5 -2/3], dims=2)
10-
A[N,N-5:end] = reverse([2/3 -11/6 0.0 31/6 -22/3 4.5 -4/3 1/6], dims=2)
9+
A[N-1,N-5:end] = reverse([2/3 -11/6 0.0 31/6 -22/3 4.5 -4/3 1/6], dims=2)
10+
A[N,N-5:end] = reverse([3.5 -56/3 42.5 -54.0 251/6 -20.0 5.5 -2/3], dims=2)
1111

1212
for i in 3:N-2
1313
A[i,i-2:i+4] = [-1/6 2.0 -13/2 28/3 -13/2 2.0 -1/6]

test/derivative_operators_interface.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ function fourth_deriv_approx_stencil(N)
1111
A[1,1:8] = [3.5 -56/3 42.5 -54.0 251/6 -20.0 5.5 -2/3]
1212
A[2,1:8] = [2/3 -11/6 0.0 31/6 -22/3 4.5 -4/3 1/6]
1313

14-
A[N-1,N-5:end] = reverse([3.5 -56/3 42.5 -54.0 251/6 -20.0 5.5 -2/3], dims=2)
15-
A[N,N-5:end] = reverse([2/3 -11/6 0.0 31/6 -22/3 4.5 -4/3 1/6], dims=2)
14+
A[N-1,N-5:end] = reverse([2/3 -11/6 0.0 31/6 -22/3 4.5 -4/3 1/6], dims=2)
15+
A[N,N-5:end] = reverse([3.5 -56/3 42.5 -54.0 251/6 -20.0 5.5 -2/3], dims=2)
1616

1717
for i in 3:N-2
1818
A[i,i-2:i+4] = [-1/6 2.0 -13/2 28/3 -13/2 2.0 -1/6]

0 commit comments

Comments
 (0)