DiffEqOperators.jl icon indicating copy to clipboard operation
DiffEqOperators.jl copied to clipboard

Unexpected concretization of Laplace operator

Open fabiopierella opened this issue 4 years ago • 3 comments

Congrats for the great work you are doing in the DiffEqOperators package. I was trying to create a 2D Laplacian matrix, but I can’t seem to manage to be able to concretize it to the right Array.

MWE (Win10, julia 1.6, DiffEqOperators 4.29.0)


n = 10

Lxx = CenteredDifference{1}(2,2,1.,n) 
Lyy = CenteredDifference{2}(2,2,1.,n) 
D = Lxx + Lyy

Mxx = Array(D.ops[1], (n,n))
Myy = Array(D.ops[2], (n,n))

D = Lxx + Lyy

heatmap(Array(D, (n,n)))

Image I get: mwe

Image I'd expect: reference

fabiopierella avatar Oct 22 '21 13:10 fabiopierella

Thanks for the issue. Peculiar. Looks like an indexing issue.

ChrisRackauckas avatar Oct 22 '21 19:10 ChrisRackauckas

I find that the problem is that D has the wrong size. Lxx and Lyy have different sizes, and D inherits the size of Lxx. Instead, both Lxx and Lyy should be zero-extended to have the same size.

eschnett avatar Jan 12 '22 18:01 eschnett

My comment above was wrong. I was confused about the matrix sizes.

The plot looks correct to me. The matrix you are plotting has size (n, n+2) because ghost points have been added. If you plot either Mxx or Myy separately, you see that they are correct. If you were to omit the ghost points then you would see the diagonal structure you expect.

eschnett avatar Jan 13 '22 19:01 eschnett