Closed KonradScheffler closed 5 months ago
From memory I think it just adds a [1, -2, 1]
in each dimension, so a central -4
in 2D, a -6
in 3D, and so on.
Do you have a MWE where it does not produce the classical stencil?
Yeah, the general structure looks like this, but when i build a classical 2D-5 point stencil by using the kronecker sum (klick) my laplacian with hom. dirichlet b.c. looks slightly different in the outer regions:
A=ones(3,3) n1,n1=size(A) S = spdiagm(n1,n1,-1=>ones(n1-1),0=>-2ones(n1),1=>ones(n1-1)) P = spdiagm(n2,n2,-1=>ones(n2-1),0=>-2ones(n2),1=>ones(n2-1)) Δ = kron(S,I(n1)) + kron(I(n2),P)
produces
but your code produces:
Is the difference due to other boundary conditions?
Yes I think so!
I'll close this but feel free to reopen if you think I did not answer your question!
Hey,
I can not really follow which kind of stencil the code is producing for the laplacian. Could you elaborate a bit on this matter? It seems to stick to the horizontal neighbors, but is not producing a classical 5-point stencil in 2D/ 7-point stencil in 3D?
Best, Konrad