initial entry

This commit is contained in:
vhenson 1996-10-16 21:58:33 +00:00
parent 8e4fa67295
commit f115d514b7
4 changed files with 130 additions and 0 deletions

View File

@ -0,0 +1,28 @@
%function A = lapmake(Nx,Ny)
%
% Makes standard 5-pt Laplacian matrix on grid with with Nx intervals
% in x direction and Ny intervals in y direction
function A = lapmake(Nx,Ny)
dx=1/Nx;
dx2=dx*dx;
dy=1/Ny;
dy2=dy*dy;
dig=2/dx2+2/dy2;
xoff=-1/dx2;
yoff=-1/dy2;
Nx1=Nx-1;
C = toeplitz([dig xoff zeros(1,Nx-3)]);
B = yoff*eye(Nx1);
A = [C B zeros(Nx-1,(Ny-3)*Nx1)];
for j=2:Ny-2,
A = [A;[zeros(Nx1,(j-2)*Nx1) B C B zeros(Nx1,(Ny-4-(j-2))*Nx1)]];
end
A = [A; zeros(Nx-1,(Ny-3)*Nx1) B C];

View File

@ -0,0 +1,37 @@
function L = lapmake9(Nx,Ny,stncl)
%function L = lapmake9(Nx,Ny,stncl)
%
% Makes Laplacian matrix based on 9-pt input stencil (3x3 matrix)
% using Nx nodes in x-direction and Ny nodes in y-direction
%
% Form is | B C |
% | A B C |
% | A B C |
% | . . . |
% | A B C|
% | A B|
%
% where A, B, and C are tridiagonal matrices.
B = diag(stncl(2,2)*ones(Nx,1));
B = B + diag(stncl(2,3)*ones(Nx-1,1),1);
B = B + diag(stncl(2,1)*ones(Nx-1,1),-1);
C = diag(stncl(1,2)*ones(Nx,1));
C = C + diag(stncl(1,3)*ones(Nx-1,1),1);
C = C + diag(stncl(1,1)*ones(Nx-1,1),-1);
A = diag(stncl(3,2)*ones(Nx,1));
A = A + diag(stncl(3,3)*ones(Nx-1,1),1);
A = A + diag(stncl(3,1)*ones(Nx-1,1),-1);
L = [B C zeros(Nx,(Ny-2)*Nx)];
for j=2:Ny-1,
L = [L;[zeros(Nx,(j-2)*Nx) A B C zeros(Nx,(Ny-3-(j-2))*Nx)]];
end
L = [L; zeros(Nx,(Ny-2)*Nx) A B];

View File

@ -0,0 +1,28 @@
%function A = lapmake(Nx,Ny)
%
% Makes standard 5-pt Laplacian matrix on grid with with Nx intervals
% in x direction and Ny intervals in y direction
function A = lapmake(Nx,Ny)
dx=1/Nx;
dx2=dx*dx;
dy=1/Ny;
dy2=dy*dy;
dig=2/dx2+2/dy2;
xoff=-1/dx2;
yoff=-1/dy2;
Nx1=Nx-1;
C = toeplitz([dig xoff zeros(1,Nx-3)]);
B = yoff*eye(Nx1);
A = [C B zeros(Nx-1,(Ny-3)*Nx1)];
for j=2:Ny-2,
A = [A;[zeros(Nx1,(j-2)*Nx1) B C B zeros(Nx1,(Ny-4-(j-2))*Nx1)]];
end
A = [A; zeros(Nx-1,(Ny-3)*Nx1) B C];

View File

@ -0,0 +1,37 @@
function L = lapmake9(Nx,Ny,stncl)
%function L = lapmake9(Nx,Ny,stncl)
%
% Makes Laplacian matrix based on 9-pt input stencil (3x3 matrix)
% using Nx nodes in x-direction and Ny nodes in y-direction
%
% Form is | B C |
% | A B C |
% | A B C |
% | . . . |
% | A B C|
% | A B|
%
% where A, B, and C are tridiagonal matrices.
B = diag(stncl(2,2)*ones(Nx,1));
B = B + diag(stncl(2,3)*ones(Nx-1,1),1);
B = B + diag(stncl(2,1)*ones(Nx-1,1),-1);
C = diag(stncl(1,2)*ones(Nx,1));
C = C + diag(stncl(1,3)*ones(Nx-1,1),1);
C = C + diag(stncl(1,1)*ones(Nx-1,1),-1);
A = diag(stncl(3,2)*ones(Nx,1));
A = A + diag(stncl(3,3)*ones(Nx-1,1),1);
A = A + diag(stncl(3,1)*ones(Nx-1,1),-1);
L = [B C zeros(Nx,(Ny-2)*Nx)];
for j=2:Ny-1,
L = [L;[zeros(Nx,(j-2)*Nx) A B C zeros(Nx,(Ny-3-(j-2))*Nx)]];
end
L = [L; zeros(Nx,(Ny-2)*Nx) A B];