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
# * Assume that the BC is in terms of an explicit expression, not containing references to variables other than u_ at the boundary
118
-
for u ins.vars
117
+
for u inū
119
118
ifisequal(operation(u), operation(u_))
120
119
# What to replace derivatives at the boundary with
121
-
depvarderivbcmaps = [(Differential(x)^d)(u_) =>central_difference(derivweights.map[Differential(x_)^d], II, s, (s.x2i[x_], x_), u, ufunc) for d in derivweights.orders[x_]]
120
+
depvarderivbcmaps = [(Differential(x_)^d)(u_) =>central_difference(derivweights.map[Differential(x_)^d], II, s, (s.x2i[x_], x_), u, ufunc) for d in derivweights.orders[x_]]
122
121
# ? Does this need to be done for all variables at the boundary?
123
122
depvarbcmaps = [u_ => s.discvars[u][II]]
124
123
break
@@ -136,8 +135,6 @@ end
136
135
137
136
functiongenerate_bc_rules(II, derivweights, s::DiscreteSpace{N,M,G}, bc, u_, x_, boundary::AbstractTruncatingBoundary) where {N, M, G<:EdgeAlignedGrid}
# depvarbcmaps will dictate what to replace the variable terms with in the bcs
147
144
# replace u(t,0) with u₁, etc
148
145
# * Assume that the BC is in terms of an explicit expression, not containing references to variables other than u_ at the boundary
149
-
for u ins.vars
146
+
for u inū
150
147
ifisequal(operation(u), operation(u_))
151
-
depvarderivbcmaps = [(Differential(x)^d)(u_) =>half_offset_centered_difference(derivweights.halfoffsetmap[Differential(x_)^d], II, s, offset(boundary), (s.x2i[x_],x_), u, ufunc) for d in derivweights.orders[x_]]
148
+
depvarderivbcmaps = [(Differential(x_)^d)(u_) =>half_offset_centered_difference(derivweights.halfoffsetmap[Differential(x_)^d], II, s, (s.x2i[x_],x_), u, ufunc) for d in derivweights.orders[x_]]
152
149
153
-
depvarbcmaps = [u_ =>half_offset_centered_difference(derivweights.interpmap[x_], II, s, offset(boundary), (s.x2i[x_],x_), u, ufunc)]
150
+
depvarbcmaps = [u_ =>half_offset_centered_difference(derivweights.interpmap[x_], II, s, (s.x2i[x_],x_), u, ufunc)]
Inner function for `get_half_offset_weights_and_stencil` (see below).
6
+
"""
7
+
function_get_weights_and_stencil(D, I)
8
+
# k => i of itap -
9
+
# offset is important due to boundary proximity
10
+
# The low boundary coeffs has a heirarchy of coefficients following: number of indices from boundary -> which half offset point does it correspond to -> weights
11
+
if I <= (D.boundary_point_count)
12
+
println("low boundary")
13
+
weights = D.low_boundary_coefs[I]
14
+
offset =1- I
15
+
Itap = [I + (i+offset) for i in0:(D.boundary_stencil_length-1)]
16
+
elseif I > (20- D.boundary_point_count)
17
+
println("high boundary")
18
+
19
+
weights = D.high_boundary_coefs[20-I+1]
20
+
offset =20- I
21
+
Itap = [I + (i+offset) for i in (-D.boundary_stencil_length+1):1:0]
22
+
else
23
+
println("interior")
24
+
25
+
weights = D.stencil_coefs
26
+
Itap = [I + i for i in (1-div(D.stencil_length,2)):(div(D.stencil_length,2))]
# Hardcoded to centered difference, generate weights for each differential
21
21
#TODO: Add handling for upwinding
22
-
for x in s.nottime
22
+
for x in s.x̄
23
23
push!(orders, x =>d_orders(x))
24
24
#TODO: Only generate weights for derivatives that are actually used and avoid redundant calculations
25
25
rs = [(Differential(x)^d) =>CompleteCenteredDifference(d, approx_order, s.dxs[x] ) for d inlast(orders).second]
@@ -60,51 +60,39 @@ function central_difference(D, II, s, jx, u, ufunc)
60
60
returndot(weights, ufunc(u, Itap, x))
61
61
end
62
62
63
+
63
64
"""
64
-
Inner function for `get_half_offset_weights_and_stencil` (see below).
65
+
Get the weights and stencil for the inner half offset centered difference for the nonlinear laplacian for a given index and differentiating variable.
66
+
67
+
Does not discretize so that the weights can be used in a replacement rule
68
+
TODO: consider refactoring this to harmonize with centered difference
65
69
"""
66
-
function_get_weights_and_stencil(D, II, I1, s, k, j, x)
67
-
# k => i of itap -
70
+
functionget_half_offset_weights_and_stencil(D, II, s, jx)
71
+
j, x = jx
72
+
# unit index in direction of the derivative
73
+
I1 =unitindices(nparams(s))[j]
68
74
# offset is important due to boundary proximity
69
-
# The low boundary coeffs has a heirarchy of coefficients following: number of indices from boundary -> which half offset point does it correspond to -> weights
70
-
if II[j] <=(D.boundary_point_count-1)
71
-
weights = D.low_boundary_coefs[II[j]][k]
75
+
76
+
if II[j] <= D.boundary_point_count
77
+
weights = D.low_boundary_coefs[II[j]]
72
78
offset =1- II[j]
73
79
Itap = [II + (i+offset)*I1 for i in0:(D.boundary_stencil_length-1)]
0 commit comments