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
# depvarbcmaps will dictate what to replace the variable terms with in the bcs
105
+
# replace u(t,0) with u₁, etc
106
+
ufunc(v, I, x) = s.discvars[v][I]
107
+
102
108
for u in s.vars
103
-
if u isa Sym &&isequal(operation(u), operation(bcdepvar))
104
-
push!(out, u)
109
+
ifisequal(operation(u), operation(u_))
110
+
# What to replace derivatives at the boundary with
111
+
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_]]
112
+
# ? Does this need to be done for all variables at the boundary?
# depvarbcmaps will dictate what to replace the variable terms with in the bcs
130
+
# replace u(t,0) with u₁, etc
131
+
for u in s.vars
132
+
ifisequal(operation(u), operation(u_))
133
+
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_]]
134
+
135
+
depvarbcmaps = [u_ =>half_offset_centered_difference(derivweights.interpmap[x_], II, s, offset(boundary), (s.x2i[x_],x_), u, ufunc)]
# ufunc is a function that returns the correct discretization indexed at Itap, it is designed this way to allow for central differences of arbitrary expressions which may be needed in some schemes
35
+
"""
36
+
Performs a centered difference in `x` centered at index `II` of `u`
37
+
ufunc is a function that returns the correct discretization indexed at Itap, it is designed this way to allow for central differences of arbitrary expressions which may be needed in some schemes
38
+
"""
36
39
functioncentral_difference(D, II, s, jx, u, ufunc)
37
40
j, x = jx
38
41
# unit index in direction of the derivative
@@ -88,10 +91,9 @@ TODO: consider refactoring this to harmonize with centered difference
88
91
functionget_half_offset_weights_and_stencil(D, II, s, offset, jx)
89
92
j, x = jx
90
93
I1 =unitindices(nparams(s))[j]
91
-
92
94
# Shift the current index to the correct offset
93
-
II_prime = II + offset*I1
94
-
95
+
II_prime = II +Int(offset-0.5)*I1
96
+
@assertall(i->0<i<=length(s,x), II_prime) "Index out of bounds"
@@ -42,17 +42,28 @@ params(s::DiscreteSpace{N,M}) where {N,M}= s.params
42
42
grid_idxs(s::DiscreteSpace) =CartesianIndices(((axes(g)[1] for g in s.grid)...,))
43
43
edge_idxs(s::DiscreteSpace{N}) where {N} =reduce(vcat, [[vcat([Colon() for j =1:i-1], 1, [Colon() for j = i+1:N]), vcat([Colon() for j =1:i-1], length(s.axies[i]), [Colon() for j = i+1:N])] for i =1:N])
44
44
45
-
axiesvals(s::DiscreteSpace{N}) where {N} =map(y -> [s.nottime[i]=> s.axies[s.nottime[i]][y.I[i]] fori =1:N], s.Iaxies)
46
-
gridvals(s::DiscreteSpace{N}) where {N} =map(y -> [s.nottime[i]=> s.grid[s.nottime[i]][y.I[i]] fori =1:N], s.Igrid)
45
+
axiesvals(s::DiscreteSpace{N}, I) where {N} =[x=> s.axies[x][I[j]] for(j,x) inenumerate(s.nottime)]
46
+
gridvals(s::DiscreteSpace{N}, I) where {N} =[x=> s.grid[x][I[j]] for(j,x) inenumerate(s.nottime)]
47
47
48
48
## Boundary methods ##
49
49
edgevals(s::DiscreteSpace{N}) where {N} =reduce(vcat, [get_edgevals(s.nottime, s.axies, i) for i =1:N])
50
-
edgevars(s::DiscreteSpace) = [[d[e...] for e in s.Iedge]fordin s.discvars]
[@rule ($(Differential(x))($(Differential(x))(u)/~a)) =>cartesian_nonlinear_laplacian(1/~a, II, derivweights, s, x, u) for x in s.nottime, u in s.vars]))
0 commit comments