Skip to content

Commit 1d090cd

Browse files
committed
more fixes
1 parent e79b9fe commit 1d090cd

File tree

5 files changed

+68
-13
lines changed

5 files changed

+68
-13
lines changed

Manifest.toml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ git-tree-sha1 = "265b06e2b1f6a216e0e8f183d28e4d354eab3220"
3131
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
3232
version = "3.2.1"
3333

34+
[[ArrayLayouts]]
35+
deps = ["FillArrays", "LinearAlgebra", "SparseArrays"]
36+
git-tree-sha1 = "e1ba79094cae97b688fb42d31cbbfd63a69706e4"
37+
uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
38+
version = "0.7.8"
39+
3440
[[Artifacts]]
3541
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
3642

@@ -39,6 +45,12 @@ git-tree-sha1 = "45bb6705d93be619b81451bb2006b7ee5d4e4453"
3945
uuid = "15f4f7f2-30c1-5605-9d31-71845cf9641f"
4046
version = "0.2.0"
4147

48+
[[BandedMatrices]]
49+
deps = ["ArrayLayouts", "FillArrays", "LinearAlgebra", "Random", "SparseArrays"]
50+
git-tree-sha1 = "ce68f8c2162062733f9b4c9e3700d5efc4a8ec47"
51+
uuid = "aae01518-5342-5314-be14-df237901396f"
52+
version = "0.16.11"
53+
4254
[[BangBang]]
4355
deps = ["Compat", "ConstructionBase", "Future", "InitialValues", "LinearAlgebra", "Requires", "Setfield", "Tables", "ZygoteRules"]
4456
git-tree-sha1 = "0ad226aa72d8671f20d0316e03028f0ba1624307"
@@ -64,6 +76,18 @@ git-tree-sha1 = "bc1317f71de8dce26ea67fcdf7eccc0d0693b75b"
6476
uuid = "62783981-4cbd-42fc-bca8-16325de8dc4b"
6577
version = "0.1.1"
6678

79+
[[BlockArrays]]
80+
deps = ["ArrayLayouts", "FillArrays", "LinearAlgebra"]
81+
git-tree-sha1 = "5524e27323cf4c4505699c3fb008c3f772269945"
82+
uuid = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
83+
version = "0.16.9"
84+
85+
[[BlockBandedMatrices]]
86+
deps = ["ArrayLayouts", "BandedMatrices", "BlockArrays", "FillArrays", "LinearAlgebra", "MatrixFactorizations", "SparseArrays", "Statistics"]
87+
git-tree-sha1 = "b1db5b5daca19070297580e1c5b5095e7ada6792"
88+
uuid = "ffab5731-97b5-5995-9138-79e8c1846df0"
89+
version = "0.11.1"
90+
6791
[[CPUSummary]]
6892
deps = ["Hwloc", "IfElse", "Static"]
6993
git-tree-sha1 = "87b0c9c6ee0124d6c1f4ce8cb035dcaf9f90b803"
@@ -206,6 +230,12 @@ git-tree-sha1 = "0aa2d003ec9efe2a93f93ae722de05a870ffc0b2"
206230
uuid = "c894b116-72e5-5b58-be3c-e6d8d4ac2b12"
207231
version = "8.0.0"
208232

233+
[[DiffEqOperators]]
234+
deps = ["BandedMatrices", "BlockBandedMatrices", "DiffEqBase", "DomainSets", "ForwardDiff", "LazyArrays", "LazyBandedMatrices", "LinearAlgebra", "LoopVectorization", "NNlib", "NonlinearSolve", "Requires", "RuntimeGeneratedFunctions", "SciMLBase", "SparseArrays", "SparseDiffTools", "StaticArrays", "SuiteSparse"]
235+
git-tree-sha1 = "8e7e2b9da87481294bcfcb7c7cf9e46832f843d7"
236+
uuid = "9fdde737-9c7f-55bf-ade8-46b3f136cc48"
237+
version = "4.38.0"
238+
209239
[[DiffResults]]
210240
deps = ["StaticArrays"]
211241
git-tree-sha1 = "c18e98cba888c6c25d1c3b048e4b3380ca956805"
@@ -429,6 +459,18 @@ git-tree-sha1 = "83b56449c39342a47f3fcdb3bc782bd6d66e1d97"
429459
uuid = "10f19ff3-798f-405d-979b-55457f8fc047"
430460
version = "0.1.4"
431461

462+
[[LazyArrays]]
463+
deps = ["ArrayLayouts", "FillArrays", "LinearAlgebra", "MacroTools", "MatrixFactorizations", "SparseArrays", "StaticArrays"]
464+
git-tree-sha1 = "6dfb5dc9426e0cb7e237a71aa78c6b8c3e78a7fc"
465+
uuid = "5078a376-72f3-5289-bfd5-ec5146d43c02"
466+
version = "0.22.4"
467+
468+
[[LazyBandedMatrices]]
469+
deps = ["ArrayLayouts", "BandedMatrices", "BlockArrays", "BlockBandedMatrices", "FillArrays", "LazyArrays", "LinearAlgebra", "MatrixFactorizations", "SparseArrays", "StaticArrays"]
470+
git-tree-sha1 = "8f4c427f6b505294dfefd343c8373b8c74e09973"
471+
uuid = "d7e5e226-e90b-4449-9968-0f923699bf6f"
472+
version = "0.7.6"
473+
432474
[[LibCURL]]
433475
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
434476
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
@@ -488,6 +530,12 @@ version = "0.1.6"
488530
deps = ["Base64"]
489531
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
490532

533+
[[MatrixFactorizations]]
534+
deps = ["ArrayLayouts", "LinearAlgebra", "Printf", "Random"]
535+
git-tree-sha1 = "1a0358d0283b84c3ccf9537843e3583c3b896c59"
536+
uuid = "a3b82374-2e81-5b9e-98ce-41277c0e4c87"
537+
version = "0.8.5"
538+
491539
[[MbedTLS_jll]]
492540
deps = ["Artifacts", "Libdl"]
493541
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
@@ -551,6 +599,12 @@ git-tree-sha1 = "019f12e9a1a7880459d0173c182e6a99365d7ac1"
551599
uuid = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
552600
version = "4.5.1"
553601

602+
[[NNlib]]
603+
deps = ["Adapt", "ChainRulesCore", "Compat", "LinearAlgebra", "Pkg", "Requires", "Statistics"]
604+
git-tree-sha1 = "afcfd88042cc5a62743c98ca311668ff5c03148a"
605+
uuid = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
606+
version = "0.7.32"
607+
554608
[[NaNMath]]
555609
git-tree-sha1 = "bfe47e760d60b82b66b61d2d44128b62e3a369fb"
556610
uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"

src/MethodOfLines.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module MethodOfLines
44
using DiffEqBase
55
using DiffEqOperators
66
using ModelingToolkit
7+
using ModelingToolkit: operation, istree, arguments, variable
78
using SymbolicUtils, Symbolics
89
import DomainSets
910

src/discretization/MOL_discretization.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ end
1212
# Constructors. If no order is specified, both upwind and centered differences will be 2nd order
1313
function MOLFiniteDifference(dxs, time=nothing; upwind_order = 1, centered_order = 2, grid_align=center_align)
1414

15-
if discretization.centered_order % 2 != 0
16-
throw(ArgumentError("Discretization centered_order must be even, given $(discretization.centered_order)"))
15+
if centered_order % 2 != 0
16+
warn("Discretization centered_order must be even, rounding up to $(centered_order+1)")
1717
end
18-
return MOLFiniteDifference(dxs, time, approx_order, grid_align)
18+
return MOLFiniteDifference(dxs, time, centered_order, grid_align)
1919
end
2020

2121
function SciMLBase.symbolic_discretize(pdesys::PDESystem, discretization::MethodOfLines.MOLFiniteDifference)
@@ -66,10 +66,10 @@ function SciMLBase.symbolic_discretize(pdesys::PDESystem, discretization::Method
6666
nottime = first(allnottime)
6767
@assert length(allindvars) == 1
6868
indvars = first(allindvars)
69-
nspace = length(nottime)
70-
71-
s = DiscreteSpace(pdesys.domain, depvars, indvars, nottime, discretization)
72-
69+
70+
# Get the grid
71+
s = DiscreteSpace(domain, depvars, indvars, nottime, discretization)
72+
7373
derivweights = DifferentialDiscretizer(pde, s, discretization)
7474

7575
interior = s.Igrid[[2:(length(grid[x])-1) for x in s.nottime]]

src/discretization/discretize_vars.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ function DiscreteSpace(domain, depvars, indvars, nottime, discretization)
7373
if grid_align == center_align
7474
grid = axies
7575
elseif grid_align == edge_align
76-
# boundary conditions implementation assumes centered_order=2
77-
@assert discretization.centered_order == 2
7876
# construct grid including ghost nodes beyond outer edges
7977
# e.g. space 0:dx:1 goes to grid -dx/2:dx:1+dx/2
8078
grid = map(nottime) do x

src/discretization/generate_finite_difference_rules.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function spherical_diffusion(innerexpr, II, derivweights, s, r, u)
120120
if substitute(r, _rsubs(r, II)) 0
121121
D_2_u = central_difference(D_2, II, s, (s.x2i(r), r), u, ufunc_u)
122122
return 3exprhere*D_2_u # See appendix B of the paper
123-
123+
end
124124
D_1_u = central_difference(D_1, II, s, (s.x2i[r], r), u, ufunc_u)
125125
# See scheme 1 in appendix A of the paper
126126

@@ -186,20 +186,22 @@ function generate_finite_difference_rules(II, s, pde, derivweights)
186186

187187
rhs_arg = istree(pde.rhs) && (SymbolicUtils.operation(pde.rhs) == +) ? SymbolicUtils.arguments(pde.rhs) : [pde.rhs]
188188
lhs_arg = istree(pde.lhs) && (SymbolicUtils.operation(pde.lhs) == +) ? SymbolicUtils.arguments(pde.lhs) : [pde.lhs]
189+
#These have to be done seperately to ensure that the spherical rules are applied first.
189190
nonlinlap_rules = []
190191
for t in vcat(lhs_arg,rhs_arg)
191-
for r in cartesian_deriv_rules
192+
for r in spherical_deriv_rules
192193
if r(t) !== nothing
193194
push!(nonlinlap_rules, t => r(t))
194195
end
195196
end
196-
for r in spherical_deriv_rules
197+
end
198+
for t in vcat(lhs_arg,rhs_arg)
199+
for r in cartesian_deriv_rules
197200
if r(t) !== nothing
198201
push!(nonlinlap_rules, t => r(t))
199202
end
200203
end
201204
end
202-
203205
rules = vcat(vec(nonlinlap_rules),
204206
vec(central_deriv_rules_cartesian),
205207
vec(central_deriv_rules_spherical),

0 commit comments

Comments
 (0)