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
117
-
for u in ū
117
+
for u ins.ū
118
118
ifisequal(operation(u), operation(u_))
119
119
# What to replace derivatives at the boundary with
120
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_]]
# depvarbcmaps will dictate what to replace the variable terms with in the bcs
144
144
# replace u(t,0) with u₁, etc
145
145
# * Assume that the BC is in terms of an explicit expression, not containing references to variables other than u_ at the boundary
146
-
for u in ū
146
+
147
+
for u in s.ū
147
148
ifisequal(operation(u), operation(u_))
148
149
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_]]
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
14
15
-
# central_deriv_rules = [(Differential(s)^2)(u) => central_deriv(2,II,j,k) for (j,s) in enumerate(s.x̄), (k,u) in enumerate(ū)]
15
+
# 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.ū)]
Iinterior(s::DiscreteSpace) = s.Igrid[[2:(length(s, x)-1) for x in s.x̄]...]
79
80
80
-
map_symbolic_to_discrete(II::CartesianIndex, s::DiscreteSpace{N,M}) where {N,M} =vcat([ū[k] => s.discvars[k][II] for k =1:M], [s.x̄[j] => s.grid[j][II[j]] for j =1:N])
81
+
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])
81
82
82
83
# ? How rude is this? Makes Iedge work
83
84
@@ -141,5 +142,5 @@ end
141
142
142
143
143
144
144
-
#varmap(s::DiscreteSpace{N,M}) where {N,M} = [ū[i] => i for i = 1:M]
145
+
#varmap(s::DiscreteSpace{N,M}) where {N,M} = [s.ū[i] => i for i = 1:M]
Copy file name to clipboardExpand all lines: src/discretization/generate_finite_difference_rules.jl
+27-29Lines changed: 27 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -3,15 +3,8 @@
3
3
4
4
Interpolate gridpoints by taking the average of the values of the discrete points, or if the offset is outside the grid, extrapolate the value with dx.
functioncartesian_nonlinear_laplacian(expr, II, derivweights, s, x, u)
45
38
# Based on the paper https://web.mit.edu/braatzgroup/analysis_of_finite_difference_discretization_schemes_for_diffusion_in_spheres_with_variable_diffusivity.pdf
46
39
# See scheme 1, namely the term without the 1/r dependence. See also #354 and #371 in DiffEqOperators, the previous home of this package.
40
+
41
+
jx = j, x = (s.x2i[x], x)
42
+
@assert II[j] !=1"The nonlinear laplacian is only defined on the interior of the grid, it is unsupported in boundary conditions."
43
+
@assert II[j] !=length(s, x) "The nonlinear laplacian is only defined on the interior of the grid, it is unsupported in boundary conditions."
# Get the outer weights and stencil. clip() essentially removes a point from either end of the grid, for this reason this function is only defined on the interior, not in bcs
returnreduce(vcat, [[(Differential(x)^d)(u) =>central_difference(derivweights.map[Differential(x)^d], II, s, (j,x), u, central_ufunc) for d in derivweights.orders[x], u in ū] for (j,x) inenumerate(s.x̄)])
126
+
returnreduce(vcat, [[(Differential(x)^d)(u) =>central_difference(derivweights.map[Differential(x)^d], II, s, (j,x), u, central_ufunc) for d in derivweights.orders[x], u ins.ū] for (j,x) inenumerate(s.x̄)])
cartesian_deriv_rules = [@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 ū]
140
+
cartesian_deriv_rules = [@rule*(~~c, $(Differential(x))(*(~~a, $(Differential(x))(u), ~~b)), ~~d) =>cartesian_nonlinear_laplacian(*(a..., b...), II, derivweights, s, x, u) for x in s.x̄, u ins.ū]
0 commit comments