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
144
144
j = s.x2i[x_]
145
145
shift(::LowerBoundary) =zero(II)
146
-
shift(::UpperBoundary) =-unitindex(N, j)
146
+
shift(::UpperBoundary) =unitindex(N, j)
147
147
for u in s.ū
148
148
ifisequal(operation(u), operation(u_))
149
-
depvarderivbcmaps = [(Differential(x_)^d)(u_) =>half_offset_centered_difference(derivweights.halfoffsetmap[Differential(x_)^d], II+shift(boundary), s, (j,x_), u, ufunc) for d in derivweights.orders[x_]]
149
+
depvarderivbcmaps = [(Differential(x_)^d)(u_) =>half_offset_centered_difference(derivweights.halfoffsetmap[Differential(x_)^d], II-shift(boundary), s, (j,x_), u, ufunc) for d in derivweights.orders[x_]]
150
150
151
-
depvarbcmaps = [u_ =>half_offset_centered_difference(derivweights.interpmap[x_], II+shift(boundary), s, (j,x_), u, ufunc)]
151
+
depvarbcmaps = [u_ =>half_offset_centered_difference(derivweights.interpmap[x_], II-shift(boundary), s, (j,x_), u, ufunc)]
d_orders(x) =reverse(sort(collect(union(differential_order(pde.rhs, x), differential_order(pde.lhs, x), (differential_order(bc.rhs, x) for bc in bcs)..., (differential_order(bc.lhs, x) for bc in bcs)...))))
14
13
15
14
# central_deriv_rules = [(Differential(s)^2)(u) => central_deriv(2,II,j,k) for (j,s) in enumerate(s.x̄), (k,u) in enumerate(s.ū)]
@@ -70,6 +69,8 @@ Get the weights and stencil for the inner half offset centered difference for th
70
69
71
70
Does not discretize so that the weights can be used in a replacement rule
72
71
TODO: consider refactoring this to harmonize with centered difference
72
+
73
+
Each index corresponds to the weights and index for the derivative at index i+1/2
73
74
"""
74
75
functionget_half_offset_weights_and_stencil(D::DerivativeOperator, II::CartesianIndex, s::DiscreteSpace, jx, len =0)
map_symbolic_to_discrete(II::CartesianIndex, s::DiscreteSpace{N,M}) where {N,M} =vcat([s.ū[k] => s.discvars[k][II] for k =1:M], [s.x̄[j] => s.grid[j][II[j]] for j =1:N])
82
82
83
-
# ? How rude is this? Makes Iedge work
84
-
85
83
#TODO: Allow other grids
86
84
#TODO: allow depvar-specific center/edge choice?
87
85
@@ -119,6 +117,7 @@ function DiscreteSpace(domain, depvars, indvars, x̄, discretization::MOLFiniteD
119
117
# Build symbolic variables
120
118
Iaxies =CartesianIndices(((axes(s.second)[1] for s in axies)...,))
121
119
Igrid =CartesianIndices(((axes(g.second)[1] for g in grid)...,))
120
+
Iedges =edges(x̄, Igrid, nspace)
122
121
123
122
depvarsdisc =map(depvars) do u
124
123
if t ===nothing
@@ -132,15 +131,43 @@ function DiscreteSpace(domain, depvars, indvars, x̄, discretization::MOLFiniteD
# Since rules don't test for equivalence of multiplication/ division, we need to do it manually
125
-
rules = [@rule*(~~c, $(Differential(x))(*(~~a, $(Differential(x))(u), ~~b)), ~~d) =>*(~~c,cartesian_nonlinear_laplacian(*(a..., b...), II, derivweights, s, x, u), ~~d) for x in s.x̄, u in s.ū]
124
+
rules =vec([@rule*(~~c, $(Differential(x))(*(~~a, $(Differential(x))(u), ~~b)), ~~d) =>*(~~c,cartesian_nonlinear_laplacian(*(a..., b...), II, derivweights, s, x, u), ~~d) for x in s.x̄, u in s.ū])
126
125
127
-
rules =vcat(rules, [@rule/(*(~~c, $(Differential(x))(*(~~a, $(Differential(x))(u), ~~b)), ~~d), ~f) =>*(~~c,cartesian_nonlinear_laplacian(*(a..., b...), II, derivweights, s, x, u), ~~d)/~f for x in s.x̄, u in s.ū])
126
+
rules =vcat(rules, vec([@rule$(Differential(x))(*(~~a, $(Differential(x))(u), ~~b))=>cartesian_nonlinear_laplacian(*(a..., b...), II, derivweights, s, x, u)for x in s.x̄, u in s.ū]))
128
127
129
-
rules =vcat(rules, [@rule/(*(~~c, $(Differential(x))(/(*(~~a, $(Differential(x))(u), ~~b), ~g)), ~~d), ~f) =>*(~~c,cartesian_nonlinear_laplacian(*(a..., b...)/~g, II, derivweights, s, x, u), ~~d)/~f for x in s.x̄, u in s.ū])
130
-
131
-
rules =vcat(rules, [@rule$(Differential(x))(/(*(~~a, $(Differential(x))(u), ~~b), ~d)) =>cartesian_nonlinear_laplacian(*(a..., b...)/~d, II, derivweights, s, x, u) for x in s.x̄, u in s.ū])
132
-
133
-
rules =vcat(vec(rules), vec([@rule ($(Differential(x))($(Differential(x))(u)/~a)) =>cartesian_nonlinear_laplacian(1/~a, II, derivweights, s, x, u) for x in s.x̄, u in s.ū]))
134
-
135
-
rules =vcat(rules, [@rule/(*(~~c, $(Differential(x))(/($(Differential(x))(u), ~g)), ~~d), ~f) =>*(~~c,cartesian_nonlinear_laplacian(1/~g, II, derivweights, s, x, u), ~~d)/~f for x in s.x̄, u in s.ū])
136
-
137
-
rules =vcat(rules, [@rule*(~~c, $(Differential(x))(/($(Differential(x))(u), ~g)), ~~d) =>*(~~c,cartesian_nonlinear_laplacian(1/~g, II, derivweights, s, x, u), ~~d) for x in s.x̄, u in s.ū])
128
+
rules =vcat(rules, vec([@rule ($(Differential(x))($(Differential(x))(u)/~a)) =>cartesian_nonlinear_laplacian(1/~a, II, derivweights, s, x, u) for x in s.x̄, u in s.ū]))
0 commit comments