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

Commit 119fb1d

Browse files
MOL discretization start
1 parent a680382 commit 119fb1d

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
1111
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
1212
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1313
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
14+
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
1415
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1516
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1617
SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"

src/DiffEqOperators.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ include("derivative_operators/concretization.jl")
3333
include("derivative_operators/ghost_derivative_operator.jl")
3434
include("derivative_operators/derivative_operator_functions.jl")
3535

36-
3736
### Composite Operators
3837
include("composite_operators.jl")
3938

39+
include("MOL_discretization.jl")
40+
4041
# The (u,p,t) and (du,u,p,t) interface
4142
for T in [DiffEqScaledOperator, DiffEqOperatorCombination, DiffEqOperatorComposition]
4243
(L::T)(u,p,t) = (update_coefficients!(L,u,p,t); L * u)
@@ -50,6 +51,6 @@ export AbstractDerivativeOperator, DerivativeOperator,
5051
export DirichletBC, Dirichlet0BC, NeumannBC, Neumann0BC, RobinBC, GeneralBC, MultiDimBC, PeriodicBC,
5152
MultiDimDirectionalBC, ComposedMultiDimBC,
5253
compose, decompose, perpsize
53-
5454
export GhostDerivativeOperator
55+
export MOLFiniteDifference
5556
end # module

src/MOL_discretization.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
struct MOLFiniteDifference{T} <: DiffEqBase.AbstractDiscretization
2+
dxs::T
3+
order::Int
4+
end
5+
MOLFiniteDifference(args...;order=2) = MOLFiniteDifference(args,order)
6+
7+
function discretize(pdesys::PDESystem,discretization::MOLFiniteDifference)
8+
tdomain = pdesys.domain[1].domain
9+
domain = pdesys.domain[2].domain
10+
@assert domain isa IntervalDomain
11+
len = domain.upper - domain.lower
12+
dx = discretization.dxs[1]
13+
interior = domain.lower+dx:dx:domain.upper-dx
14+
X = domain.lower:dx:domain.upper
15+
L = CenteredDifference(2,2,dx,Int(len/dx)-2)
16+
Q = DiffEqOperators.DirichletBC([0.0,0.0],[1.0,1.0])
17+
function f(du,u,p,t)
18+
mul!(du,L,Array(Q*u))
19+
end
20+
u0 = @. - interior * (interior - 1) * sin(interior)
21+
PDEProblem(ODEProblem(f,u0,(tdomain.lower,tdomain.upper),nothing),Q,X)
22+
end

0 commit comments

Comments
 (0)