1- struct DerivativeOperator{T<: Real ,T2,S1,S2<: SVector ,T3,F} <: AbstractDerivativeOperator{T}
1+ struct DerivativeOperator{T<: Real ,N,Wind, T2,S1,S2<: SVector ,T3,F} <: AbstractDerivativeOperator{T}
22 derivative_order :: Int
33 approximation_order :: Int
44 dx :: T2
@@ -11,12 +11,13 @@ struct DerivativeOperator{T<:Real,T2,S1,S2<:SVector,T3,F} <: AbstractDerivativeO
1111 high_boundary_coefs :: S2
1212 coefficients :: T3
1313 coeff_func :: F
14- use_winding :: Bool
1514end
1615
17- function CenteredDifference (derivative_order:: Int ,
16+ struct CenteredDifference{N} end
17+
18+ function CenteredDifference {N} (derivative_order:: Int ,
1819 approximation_order:: Int , dx:: T ,
19- len:: Int , coeff_func= nothing ) where {T<: Real }
20+ len:: Int , coeff_func= nothing ) where {T<: Real ,N }
2021
2122 stencil_length = derivative_order + approximation_order - 1 + (derivative_order+ approximation_order)% 2
2223 boundary_stencil_length = derivative_order + approximation_order
@@ -33,21 +34,21 @@ function CenteredDifference(derivative_order::Int,
3334 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]))
3435
3536 coefficients = coeff_func isa Nothing ? nothing : Vector {T} (undef,len)
36- DerivativeOperator{T,T,typeof (stencil_coefs),
37- typeof (low_boundary_coefs),typeof (coefficients),
38- typeof (coeff_func)}(
37+ DerivativeOperator{T,N, false , T,typeof (stencil_coefs),
38+ typeof (low_boundary_coefs),typeof (coefficients),
39+ typeof (coeff_func)}(
3940 derivative_order, approximation_order, dx, len, stencil_length,
4041 stencil_coefs,
4142 boundary_stencil_length,
4243 boundary_point_count,
4344 low_boundary_coefs,
44- high_boundary_coefs,coefficients,coeff_func, false
45+ high_boundary_coefs,coefficients,coeff_func
4546 )
4647end
4748
48- function CenteredDifference (derivative_order:: Int ,
49+ function CenteredDifference {N} (derivative_order:: Int ,
4950 approximation_order:: Int , dx:: AbstractVector{T} ,
50- len:: Int , coeff_func= nothing ) where {T<: Real }
51+ len:: Int , coeff_func= nothing ) where {T<: Real ,N }
5152
5253 stencil_length = derivative_order + approximation_order - 1 + (derivative_order+ approximation_order)% 2
5354 boundary_stencil_length = derivative_order + approximation_order
@@ -65,9 +66,9 @@ function CenteredDifference(derivative_order::Int,
6566
6667 coefficients = coeff_func isa Nothing ? nothing : Vector {T} (undef,len)
6768
68- DerivativeOperator{T,typeof (dx),typeof (stencil_coefs),
69- typeof (low_boundary_coefs),typeof (coefficients),
70- typeof (coeff_func)}(
69+ DerivativeOperator{T,N, false , typeof (dx),typeof (stencil_coefs),
70+ typeof (low_boundary_coefs),typeof (coefficients),
71+ typeof (coeff_func)}(
7172 derivative_order, approximation_order, dx,
7273 len, stencil_length,
7374 stencil_coefs,
@@ -78,9 +79,11 @@ function CenteredDifference(derivative_order::Int,
7879 )
7980end
8081
81- function UpwindDifference (derivative_order:: Int ,
82+ struct UpwindDifference{N} end
83+
84+ function UpwindDifference {N} (derivative_order:: Int ,
8285 approximation_order:: Int , dx:: T ,
83- len:: Int , coeff_func= nothing ) where {T<: Real }
86+ len:: Int , coeff_func= nothing ) where {T<: Real ,N }
8487
8588 stencil_length = derivative_order + approximation_order - 1 + (derivative_order+ approximation_order)% 2
8689 boundary_stencil_length = derivative_order + approximation_order
@@ -98,21 +101,21 @@ function UpwindDifference(derivative_order::Int,
98101
99102 coefficients = Vector {T} (undef,len)
100103
101- DerivativeOperator{T,T,typeof (stencil_coefs),
102- typeof (low_boundary_coefs),Vector{T},
103- typeof (coeff_func)}(
104+ DerivativeOperator{T,N, true , T,typeof (stencil_coefs),
105+ typeof (low_boundary_coefs),Vector{T},
106+ typeof (coeff_func)}(
104107 derivative_order, approximation_order, dx, len, stencil_length,
105108 stencil_coefs,
106109 boundary_stencil_length,
107110 boundary_point_count,
108111 low_boundary_coefs,
109- high_boundary_coefs,coefficients,coeff_func, true
112+ high_boundary_coefs,coefficients,coeff_func
110113 )
111114end
112115
113- function UpwindDifference (derivative_order:: Int ,
116+ function UpwindDifference {N} (derivative_order:: Int ,
114117 approximation_order:: Int , dx:: AbstractVector{T} ,
115- len:: Int , coeff_func= nothing ) where {T<: Real }
118+ len:: Int , coeff_func= nothing ) where {T<: Real ,N }
116119
117120 stencil_length = derivative_order + approximation_order - 1 + (derivative_order+ approximation_order)% 2
118121 boundary_stencil_length = derivative_order + approximation_order
@@ -130,14 +133,18 @@ function UpwindDifference(derivative_order::Int,
130133
131134 coefficients = Vector {T} (undef,len)
132135
133- DerivativeOperator{T,typeof (dx),typeof (stencil_coefs),
134- typeof (low_boundary_coefs),Vector{T},
135- typeof (coeff_func)}(
136+ DerivativeOperator{T,N, true , typeof (dx),typeof (stencil_coefs),
137+ typeof (low_boundary_coefs),Vector{T},
138+ typeof (coeff_func)}(
136139 derivative_order, approximation_order, dx, len, stencil_length,
137140 stencil_coefs,
138141 boundary_stencil_length,
139142 boundary_point_count,
140143 low_boundary_coefs,
141- high_boundary_coefs,coefficients,coeff_func, true
144+ high_boundary_coefs,coefficients,coeff_func
142145 )
143146end
147+
148+ CenteredDifference (args... ) = CenteredDifference {1} (args... )
149+ UpwindDifference (args... ) = UpwindDifference {1} (args... )
150+ use_winding (A:: DerivativeOperator{T,N,Wind} ) where {T,N,Wind} = Wind
0 commit comments