@@ -31,13 +31,13 @@ struct RobinBC{T, V<:AbstractVector{T}} <: AffineBC{T,V}
3131 cr, ar, br = r
3232 dx_l, dx_r = dx
3333
34- s = calculate_weights (1 , one (T), one (T): convert (T,order+ 1 )) # generate derivative coefficients about the boundary of required approximation order
34+ sl = calculate_weights (1 , one (T), Array ( one (T): convert (T,order+ 1 ) )) # generate derivative coefficients about the boundary of required approximation order
3535
36- a_l = - bl.* s [2 : end ]. / (al .+ bl* s [1 ]. / dx_l)
37- a_r = - br.* s[end : - 1 : 2 ]. / (ar .+ br* s[1 ]. / dx_r)
36+ a_l = - bl.* sl [2 : end ]. / (al .+ bl* sl [1 ]. / dx_l)
37+ a_r = br.* s[end : - 1 : 2 ]. / (ar .- br* s[1 ]. / dx_r) # for other boundary stencil is flippedlr with *opposite sign*
3838
3939 b_l = cl/ (al+ bl* s[1 ]/ dx_l)
40- b_r = cr/ (ar+ br* s[1 ]/ dx_r)
40+ b_r = cr/ (ar- br* s[1 ]/ dx_r)
4141
4242 return new {T, typeof(a_l)} (a_l, b_l, a_r, b_r)
4343 end
@@ -65,13 +65,13 @@ struct GeneralBC{T, V<:AbstractVector{T}} <:AffineBC{T,V}
6565 S_r = zeros (T, (nr- 2 , order+ nr- 2 ))
6666
6767 for i in 1 : (nl- 2 )
68- S_l[i,:] = [transpose (calculate_weights (i, one (T), one (T): convert (T, ( order+ i))) transpose (zeros (T, nl- 2 - i- order))] # am unsure if the length of the dummy_x is correct here
68+ S_l[i,:] = [transpose (calculate_weights (i, one (T), Array ( one (T): convert (T, order+ i) ))) transpose (zeros (T, nl- 2 - i- order))] # am unsure if the length of the dummy_x is correct here
6969 end
7070 for i in 1 : (nr- 2 )
71- S_r[i,:] = [transpose (calculate_weights (i, one (T), one (T): convert (T, order+ i))) transpose (zeros (T, nr- 2 - i- order))]
71+ S_r[i,:] = [transpose (calculate_weights (i, one (T), Array ( one (T): convert (T, order+ i) ))) transpose (zeros (T, nr- 2 - i- order))]
7272 end
7373 s0_l = S_l[:,1 ] ; Sl = S_l[2 : end ,:]
74- s0_r = S_r[:,1 ] ; Sr = S_r[2 : end ,:]
74+ s0_r = - S_r[:,1 ] ; Sr = - S_r[2 : end ,:]
7575
7676 denoml = αl[2 ] .+ αl[3 : end ] ⋅ s0_l
7777 denomr = αr[2 ] .+ αr[3 : end ] ⋅ s0_r
@@ -86,11 +86,11 @@ struct GeneralBC{T, V<:AbstractVector{T}} <:AffineBC{T,V}
8686end
8787
8888# implement Neumann and Dirichlet as special cases of RobinBC
89- NeumannBC ([l :: T , r :: T ], [dx_l,dx_r], order) where T = RobinBC ([zero (T), one (T), l] , [zero (T), one (T), r], [dx_l,dx_r] , order)
90- NeumannBC ([l :: T , r :: T ], [dx_l,dx_r] ) where T = RobinBC ([zero (T), one (T), l] , [zero (T), one (T), r], [dx_l,dx_r] )
89+ NeumannBC (α :: AbstractVector{T} , dx :: AbstractVector{T} , order) where T = RobinBC ([zero (T), one (T), α[ 1 ]] , [zero (T), one (T), α[ 2 ]], dx , order)
90+ NeumannBC (α :: AbstractVector{T} , dx :: AbstractVector{T} ) where T = RobinBC ([zero (T), one (T), α[ 1 ]] , [zero (T), one (T), α[ 2 ]], dx )
9191
92- DirichletBC ([l :: T , r :: T ], [dx_l,dx_r], order) where T = RobinBC ([one (T), zero (T), l] , [one (T), zero (T), r], [dx_l,dx_r] , order)
93- DirichletBC ([l :: T , r :: T ], [dx_l,dx_r] ) where T = RobinBC ([one (T), zero (T), l] , [one (T), zero (T), r], [dx_l,dx_r] )
92+ DirichletBC (α :: AbstractVector{T} , dx :: AbstractVector{T} , order) where T = RobinBC ([one (T), zero (T), α[ 1 ]] , [one (T), zero (T), α[ 2 ]], dx , order)
93+ DirichletBC (α :: AbstractVector{T} , dx :: AbstractVector{T} ) where T = RobinBC ([one (T), zero (T), α[ 1 ]] , [one (T), zero (T), α[ 2 ]], dx )
9494
9595# other acceptable argument signatures
9696RobinBC (al:: T , bl:: T , cl:: T , dx_l:: T , ar:: T , br:: T , cr:: T , dx_r:: T ) where T = RobinBC ([al,bl,cl], [ar, br, cr], [dx_l, dx_r])
@@ -128,7 +128,6 @@ function LinearAlgebra.Array(Q::AffineBC{T,V}, N::Int) where {T,V}
128128end
129129
130130LinearAlgebra. Array (Q:: PeriodicBC{T} , N:: Int ) where T = [transpose (zeros (T, N- 1 )) one (T); Diagonal (ones (T,N)); one (T) transpose (zeros (T, N- 1 ))]
131- # TODO : Concretize DirichletBC
132131
133132
134133function LinearAlgebra. Array (Q:: BoundaryPaddedVector )
0 commit comments