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
We aren't catching derivatives within more complex equational structures Expected behavior
These should just work, the reason is we are doing rudimentary custom recursive term splitting rather than using the excellent tools for this in SymbolicUtils.
See the comments in this this rulegen:
@inlinefunctiongenerate_winding_rules(II::CartesianIndex, s::DiscreteSpace, depvars, derivweights::DifferentialDiscretizer, bcmap, indexmap, terms; skip = [])
wind_ufunc(v, I, x) = s.discvars[v][I]
# for all independent variables and dependant variables
rules =safe_vcat(#Catch multiplicationreduce(safe_vcat, [reduce(safe_vcat, [[@rule*(~~a, $(Differential(x)^d)(u), ~~b) =>upwind_difference(*(~a..., ~b...), d, Idx(II, s, u, indexmap), s, filter_interfaces(bcmap[operation(u)][x]), depvars, derivweights, (x2i(s, u, x), x), u, wind_ufunc, indexmap) for d in (
let orders = derivweights.orders[x]
setdiff(orders[isodd.(orders)], skip)
end
)] for x inivs(u, s)], init = []) for u in depvars], init = []),
#Catch division and multiplication, see issue #1reduce(safe_vcat, [reduce(safe_vcat, [[@rule/(*(~~a, $(Differential(x)^d)(u), ~~b), ~c) =>upwind_difference(*(~a..., ~b...) /~c, d, Idx(II, s, u, indexmap), s, filter_interfaces(bcmap[operation(u)][x]), depvars, derivweights, (x2i(s, u, x), x), u, wind_ufunc, indexmap) for d in (
let orders = derivweights.orders[x]
setdiff(orders[isodd.(orders)], skip)
end
)] for x inivs(u, s)], init = []) for u in depvars], init = [])
)
#### This is redundant, we just want to return the rules as a vectorfor t in terms
for r in rules
ifr(t) !==nothingpush!(wind_rules, t =>r(t))
endendend## Here we are just generating some extra pairs, instead we should add @rule to all pure pair constructsreturnsafe_vcat(wind_rules, vec(mapreduce(safe_vcat, depvars, init = []) do u
mapreduce(safe_vcat, ivs(u, s), init = []) do x
j =x2i(s, u, x)
let orders =setdiff(derivweights.orders[x], skip)
oddorders = orders[isodd.(orders)]
# for all odd ordersiflength(oddorders) >0map(oddorders) do d
(Differential(x)^d)(u) =>upwind_difference(d, Idx(II, s, u, indexmap), s, filter_interfaces(bcmap[operation(u)][x]), derivweights, (j, x), u, wind_ufunc, true)
endelse
[]
endendendend))
end
What we want is to take all the derivative and integral rules in their current order, including the boundaryvalmaps and instead call them with a derivative rewriter chain. We wrap the rules in a deriv_rewriter = SymbolicUtils.Prewalk(SymbolicUtils.Chain(deriv_rules)). We call this rewriter with the equation's lhs/rhs, and only after that substitute the varmaps as usual. This will recursively apply the rules, top to bottom, left to right.
We can get rid of split_terms and the term argument to the rulegens.
The text was updated successfully, but these errors were encountered:
Describe the bug 🐞
We aren't catching derivatives within more complex equational structures
Expected behavior
These should just work, the reason is we are doing rudimentary custom recursive term splitting rather than using the excellent tools for this in SymbolicUtils.
See the comments in this this rulegen:
What we want is to take all the derivative and integral rules in their current order, including the boundaryvalmaps and instead call them with a derivative rewriter chain. We wrap the rules in a
deriv_rewriter = SymbolicUtils.Prewalk(SymbolicUtils.Chain(deriv_rules))
. We call this rewriter with the equation's lhs/rhs, and only after that substitute the varmaps as usual. This will recursively apply the rules, top to bottom, left to right.We can get rid of split_terms and the term argument to the rulegens.
The text was updated successfully, but these errors were encountered: