We are looking into the use of DiffEqOperators for time-independent problems. We are considering the Poisson equation on the unit interval and unit square.
First a 1D implementation was made to figure out how to use it.
DiffEqOperators provides several functions to construct finite difference approximations of a differential equation. The ‘matrix’ Ah is built up in two steps:
- Construct the finite difference approximation using CenteredDifference or UpwindDifference
- Construct the boundary conditions using one of several available functions for different types (e.g. DirichletBC for the Dirichlet boundary condition).
The complete Ah ‘matrix’ is then constructed by multiplying the result of these two steps. For example,
A = CenteredDifference(ord, ord_approx, h, N)
bc = Dirichlet0BC(Float64)
Ah = A * bc
The word ‘matrix’ is between quotation marks because DiffEqOperators does not really return a matrix but an abstract operator. This operator can then be concretized when required. DiffEqOperators also provides an implementation of \ for solving the differential equation constructed using the operators.
u = (A * bc) \ f;
u = vcat(0, u, 0)
Next the same was tried in 2D
Dxx = CenteredDifference{1}(ord, ord_approx, h, N); Dyy = CenteredDifference{2}(ord, ord_approx, h, N); bc = Dirichlet0BC(Float64)
Qx,Qy = MultiDimBC(bc, size(F))
Axx = Dxx * Qx; Ayy = Dyy * Qy; A =Axx+Ayy;
u = A \ f;
This, however, resulted in the error message
MethodError: Cannot `convert` an object of type
GhostDerivativeOperator{Float64, DerivativeOperator{Float64, 1, false, Float64, StaticArrays.SVector{3, Float64}, StaticArrays.SVector{0, Stati
cArrays.SVector{4, Float64}}, StaticArrays.SVector{0, StaticArrays.SVector{4, Float64}}, Vector{Float64}, Int64}, MultiDimDirectionalBC{Float64,
RobinBC{Float64, Vector{Float64}}, 1, 2, 1}} to an object of type
AbstractMatrix
Please advice. Thx!