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

Commit bd857c3

Browse files
committed
added error message
1 parent aa3ed39 commit bd857c3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/derivative_operators/derivative_operator.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct CenteredDifference{N} end
2020
function CenteredDifference{N}(derivative_order::Int,
2121
approximation_order::Int, dx::T,
2222
len::Int, coeff_func=nothing) where {T<:Real,N}
23-
23+
@assert approximation_order>1 "approximation_order must be greater than 1."
2424
stencil_length = derivative_order + approximation_order - 1 + (derivative_order+approximation_order)%2
2525
boundary_stencil_length = derivative_order + approximation_order
2626
dummy_x = -div(stencil_length,2) : div(stencil_length,2)
@@ -30,8 +30,8 @@ function CenteredDifference{N}(derivative_order::Int,
3030
deriv_spots = (-div(stencil_length,2)+1) : -1
3131
boundary_deriv_spots = boundary_x[2:div(stencil_length,2)]
3232

33-
stencil_coefs = convert(SVector{stencil_length, T}, calculate_weights(derivative_order, zero(T), dummy_x))
34-
_low_boundary_coefs = SVector{boundary_stencil_length, T}[convert(SVector{boundary_stencil_length, T}, calculate_weights(derivative_order, oneunit(T)*x0, boundary_x)) for x0 in boundary_deriv_spots]
33+
stencil_coefs = convert(SVector{stencil_length, T}, (1/dx^derivative_order) * calculate_weights(derivative_order, zero(T), dummy_x))
34+
_low_boundary_coefs = SVector{boundary_stencil_length, T}[convert(SVector{boundary_stencil_length, T}, (1/dx^derivative_order) * calculate_weights(derivative_order, oneunit(T)*x0, boundary_x)) for x0 in boundary_deriv_spots]
3535
low_boundary_coefs = convert(SVector{boundary_point_count},_low_boundary_coefs)
3636
high_boundary_coefs = convert(SVector{boundary_point_count},reverse(SVector{boundary_stencil_length, T}[reverse(low_boundary_coefs[i]) for i in 1:boundary_point_count]))
3737

0 commit comments

Comments
 (0)