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

Commit 363bfba

Browse files
committed
Fixed stencil generation
1 parent cf55682 commit 363bfba

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/derivative_operators/BC_operators.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
abstract type AbstractBC{T} end
22

3-
# Robin, General, and in general Neumann and Dirichlet BCs are all affine opeartors, meaning that they take the form Qx = Qax + Qb.
3+
"""
4+
Robin, General, and in general Neumann and Dirichlet BCs are all affine opeartors, meaning that they take the form Qx = Qax + Qb.
5+
"""
46
abstract type AffineBC{T,V} <: AbstractBC{T} end
57

68
struct PeriodicBC{T} <: AbstractBC{T}
79

810
end
911

1012
"""
13+
The variables in l are [al, bl, cl], and correspond to a BC of the form al*u(0) + bl*u'(0) = cl
14+
1115
Implements a robin boundary condition operator Q that acts on a vector to give an extended vector as a result
1216
Referring to (https://github.com/JuliaDiffEq/DiffEqOperators.jl/files/3267835/ghost_node.pdf)
1317
14-
the variables in correspond to al*u(0) + bl*u'(0) = cl
15-
1618
Write vector b̄₁ as a vertical concatanation with b0 and the rest of the elements of b̄ ₁, denoted b̄`₁, the same with ū into u0 and ū`. b̄`₁ = b̄`_2 = fill(β/Δx, length(stencil)-1)
1719
Pull out the product of u0 and b0 from the dot product. The stencil used to approximate u` is denoted s. b0 = α+(β/Δx)*s[1]
1820
Rearrange terms to find a general formula for u0:= -b̄`₁̇⋅ū`/b0 + γ/b0, which is dependent on ū` the robin coefficients and Δx.
@@ -29,7 +31,7 @@ struct RobinBC{T, V<:AbstractVector{T}} <: AffineBC{T,V}
2931
cr, ar, br = r
3032
dx_l, dx_r = dx
3133

32-
s = calculate_weights(1, zero(T), zero(T):convert(T,order)) #generate derivative coefficients about the boundary of required approximation order
34+
s = calculate_weights(1, one(T), one(T):convert(T,order+1)) #generate derivative coefficients about the boundary of required approximation order
3335

3436
a_l = -bl.*s[2:end]./(al .+ bl*s[1]./dx_l)
3537
a_r = -br.*s[end:-1:2]./(ar .+ br*s[1]./dx_r)
@@ -63,10 +65,10 @@ struct GeneralBC{T, V<:AbstractVector{T}} <:AffineBC{T,V}
6365
S_r = zeros(T, (nr-2, order+nr-2))
6466

6567
for i in 1:(nl-2)
66-
S_l[i,:] = [transpose(calculate_weights(i, zero(T), zero(T):convert(T, (order+i))) transpose(zeros(T, nl-2-i))] #am unsure if the length of the dummy_x is correct here
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
6769
end
6870
for i in 1:(nr-2)
69-
S_r[i,:] = [transpose(calculate_weights(i, zero(T), zero(T):convert(T, order+i))) transpose(zeros(T, nr-2-i))]
71+
S_r[i,:] = [transpose(calculate_weights(i, one(T), one(T):convert(T, order+i))) transpose(zeros(T, nr-2-i-order))]
7072
end
7173
s0_l = S_l[:,1] ; Sl = S_l[2:end,:]
7274
s0_r = S_r[:,1] ; Sr = S_r[2:end,:]

0 commit comments

Comments
 (0)