You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 19, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: src/derivative_operators/BC_operators.jl
+19-17Lines changed: 19 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
abstract type AbstractBC{T} end
2
2
3
-
# robin, general, and in general neumann BCs are all affine. neumann0 is not however; is a specialization needed?
3
+
# robin, general, and in general neumann BCs are all affine opeartors, meaning that they take the form Qx = Qax + Qb. neumann0 is not however; is a specialization needed?
4
4
abstract type AffineBC{T,V} <:AbstractBC{T}end
5
5
6
6
struct DirichletBC{T} <:AbstractBC{T}
@@ -36,16 +36,14 @@ end
36
36
37
37
the variables in correspond to al*u(0) + bl*u'(0) = cl
38
38
39
-
40
-
Write vector b̄_1 as a vertical concatanation with b0 and the rest of the elements of b̄_1, denoted b̄`_1, the same with ū into u0 and ū`. b̄` = fill(β/Δx, length(stencil)-1)
39
+
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)
41
40
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]
42
-
Rearrange terms to find a general formula for u0:= -b̄`_1̇⋅ū`/b0 + γ/b0, which is dependent on ū` the robin coefficients and Δx.
43
-
The non identity part of Qa is qa:= -b`_1/b0 = -β.*s[2:end]/(α+β*s[1]/Δx). The constant part is Qb = γ/(α+β*s[1]/Δx)
44
-
do the same at the other boundary (amounts to a flip in s with the right boundary coeffs)
41
+
Rearrange terms to find a general formula for u0:= -b̄`₁̇⋅ū`/b0 + γ/b0, which is dependent on ū` the robin coefficients and Δx.
42
+
The non identity part of Qa is qa:= -b`₁/b0 = -β.*s[2:end]/(α+β*s[1]/Δx). The constant part is Qb = γ/(α+β*s[1]/Δx)
43
+
do the same at the other boundary (amounts to a flip of s[2:end], with the other set of boundary coeffs)
45
44
"""
46
45
47
46
# For condition, the variables correspond to al*u(0) + bl*u'(0) = cl
s =calculate_weights(1, zero(T), zero(T):order) #generate derivative coefficients about the boundary of required approximation order
57
+
s =calculate_weights(1, zero(T), zero(T):convert(T,order)) #generate derivative coefficients about the boundary of required approximation order
60
58
61
59
a_l =-bl.*s[2:end]./(al .+ bl*s[1]./dx_l)
62
60
a_r =-br.*s[end:-1:2]./(ar .+ br*s[1]./dx_r)
@@ -71,7 +69,11 @@ end
71
69
"""
72
70
Implements a generalization of the Robin boundary condition, where α is a vector of coefficients.
73
71
Represents a condition of the form α[1] + α[2]u[0] + α[3]u'[0] + α[4]u''[0]+... = 0
74
-
Implemented in an analogous way to the RobinBC
72
+
Implemented in a similar way to the RobinBC (see above).
73
+
74
+
This time there are multiple stencils for multiple derivative orders - these can be written as a matrix S.
75
+
All components that multiply u(0) are factored out, turns out to only involve the first colum of S, s̄0. The rest of S is denoted S`. the coeff of u(0) is s̄0⋅ᾱ[3:end] + α[2].
76
+
the remaining components turn out to be ᾱ[3:end]⋅(S`ū`) or equivalantly (transpose(ᾱ[3:end])*S`)⋅ū`. Rearranging, a stencil q_a to be dotted with ū` upon extension can readily be found, along with a constant component q_b
75
77
"""
76
78
#If you know a more correct name for this kind of BC, please post an issue/PR
S_l[i,:] = [transpose(calculate_weights(i, zero(T), zero(T):(order+i))) transpose(zeros(T, nl-2-i))] #am unsure if the length of the dummy_x is correct here
92
+
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
NeumannBC(l::T, dx_l::T, r::T, dx_r::T) where T =NeumannBC(l, r, [dx_l,dx_r])
115
117
NeumannBC(l::T, dx_l::T, r::T, dx_r::T, order::T) where T =NeumannBC(l, r, [dx_l,dx_r], order)
118
+
116
119
# this is 'boundary padded vector' as opposed to 'boundary padded array' to distinguish it from the n dimensional implementation that will eventually be neeeded
0 commit comments