-
Notifications
You must be signed in to change notification settings - Fork 1
/
poisson_solve5.m
35 lines (30 loc) · 1.43 KB
/
poisson_solve5.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
35
function [A5,b,ucomp,iter] = poisson_solve5(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
%%---------------------------------------------------------------
[A5,b] = util_Poisson.algbraic_system5(source,nx,ny,BC);
% [A5,b] = util_Poisson.set_Dirichlet(A5,b,BC,U);
%%---------------------------------------------------------------
%% 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_A5(A5,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