Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Commit 311a367

Browse files
neater way to generate stencil
1 parent 45f79f2 commit 311a367

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

src/MOLFiniteDifference/MOL_discretization.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ function SciMLBase.symbolic_discretize(pdesys::ModelingToolkit.PDESystem,discret
107107
# Create a stencil in the required dimension centered around 0
108108
# e.g. (-1,0,1) for 2nd order, (-2,-1,0,1,2) for 4th order, etc
109109
order = discretization.centered_order
110-
stencil_indices(j) = [1:ifelse(l==j,order+1,1) for l in 1:nspace]
111-
stencil_shift(j) = [ifelse(l==j,order÷2+1,1) for l in 1:nspace]
112-
stencil(j) = CartesianIndices(Tuple(stencil_indices(j))) .- CartesianIndex(stencil_shift(j)...)
110+
stencil(j) = CartesianIndices(Tuple(map(x -> -x:x, (1:nspace.==j) * (order÷2))))
113111

114112
# TODO: Generalize central difference handling to allow higher even order derivatives
115113
# The central neighbour indices should add the stencil to II, unless II is too close

0 commit comments

Comments
 (0)