-
Notifications
You must be signed in to change notification settings - Fork 1
/
poisson_solve9.m
34 lines (29 loc) · 1.38 KB
/
poisson_solve9.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function [A9,b,ucomp,iter] = poisson_solve9(true_u,source,BC,nx,ny,level,uguess)
%%---------------------------------------------------------------
%% True solution: for "Boundary assignement" and "Error analysis"
%%---------------------------------------------------------------
U = util_Poisson.mesh_values(true_u,nx,ny);
%%---------------------------------------------------------------
%% Algebraic System
%%---------------------------------------------------------------
[A9,b] = util_Poisson.algbraic_system9(source,nx,ny,BC);
%%---------------------------------------------------------------
%% Initialization
%%---------------------------------------------------------------
if nargin==7
u0 = uguess;
else
u0 = zeros(size(b));
end
u0 = util_Poisson.set_bdry_values(u0,U,BC);
%%---------------------------------------------------------------
%% Solve
%%---------------------------------------------------------------
[ucomp,iter] = sor_A9(A9,b,u0,level);
%%---------------------------------------------------------------
%% Display Error
%%---------------------------------------------------------------
E8 = norm(U(:)-ucomp(:),inf); E2 = norm(U(:)-ucomp(:),2)/sqrt(nx*ny);
fprintf(' (nx,ny)=(%3d,%3d); iter=%d; (L2,L8)-error = (%.3g , %.3g)\n',...
nx,ny,iter,E2,E8);
end