Skip to content

Commit

Permalink
Update names in files and correct date
Browse files Browse the repository at this point in the history
  • Loading branch information
NEStock committed Oct 6, 2020
1 parent 9b446b9 commit 6387f89
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 30 deletions.
2 changes: 1 addition & 1 deletion basis_functions_weighted_HL_p2.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
% function for the ith node in triangle T.
%
% Author: Nicole Stock
% Date: Spring 2020
% Date: Fall 2020

[~,triangles] = size(t);
basis = zeros(6,6,triangles);
Expand Down
2 changes: 1 addition & 1 deletion create_b_HL_p2.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
% b - vector such that stiffness_matrix * b = solution.
%
% Author: Nicole Stock
% Date: Spring 2020
% Date: Fall 2020

[~,triangles] = size(t);
[~,nodes] = size(p);
Expand Down
5 changes: 3 additions & 2 deletions errors_exact_weighted_HL_p2.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [err,grad_err,max_err] = errors_exact_weighted_p2(p,t,p2,t2,basis,u_h,n,u,grad_u_r,grad_u_z)
function [err,grad_err,max_err] = errors_exact_weighted_HL_p2(p,t,p2,t2,basis,u_h,n,u,grad_u_r,grad_u_z)

% ERRORS_EXACT_WEIGHTED_p2 - Calculate the errors of our solution u_h
% compared to the exact solution u.
Expand All @@ -24,7 +24,8 @@
% max_err - max error
%
% Author: Nicole Stock
% Date: Spring 2020
% Date: Fall 2020

addpath('data')

[~,triangles] = size(t);
Expand Down
4 changes: 2 additions & 2 deletions errors_no_exact_weighted_HL_p2.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [err,grad_err,max_err] = errors_no_exact_weighted_p2(p,t,p2,t2,basis,u_h_km1,u_h_k,n)
function [err,grad_err,max_err] = errors_no_exact_weighted_HL_p2(p,t,p2,t2,basis,u_h_km1,u_h_k,n)
% ERRORS_NO_EXACT_WEIGHTED_p2 - Calculate the errors of our solution u_h_km1
% compared to the approximate solution for the next mesh level (u_h_k).
%
Expand All @@ -23,7 +23,7 @@
% max_err - max error
%
% Author: Nicole Stock
% Date: Spring 2020
% Date: Fall 2020

[~,triangles] = size(t);
[~,nodes] = size(p);
Expand Down
2 changes: 1 addition & 1 deletion stiffness_matrix_weighted_HL_p2.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
% stiffness_matrix - stiffness matrix
%
% Author: Nicole Stock
% Date: Spring 2020
% Date: Fall 2020

[~,triangles] = size(t);
[~,nodes] = size(p);
Expand Down
21 changes: 11 additions & 10 deletions weighted_HL_k_0_p2.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function [err,grad_err,max_err] = weighted_HL_k_0(u,grad_u_r,grad_u_z,gd,sf,ns,mesh_level,n)
%WEIGHTED_HL_K_0 Weighted Hodge Laplacian with k = 0.
function [err,grad_err,max_err] = weighted_HL_k_0_p2(u,grad_u_r,grad_u_z,gd,sf,ns,mesh_level,n)
%WEIGHTED_HL_K_0_P2 Weighted Hodge Laplacian with k = 0.
%
% Syntax:
% [err,grad_err,max_err] =
Expand All @@ -25,13 +25,14 @@
% n = 1;
% pdepoly([0,1,1,0], [0,0,1,1]);
% (OR) [gd,sf,ns] = get_gd_sf_ns([0,1,1,0],[0,0,1,1]);
% [err,grad_err,max_err] = weighted_HL_k_0(u,grad_u_r,grad_u_z,gd,sf,ns,mesh,n)
% [err,grad_err,max_err] = weighted_HL_k_0_p2(u,grad_u_r,grad_u_z,gd,sf,ns,mesh,n)
% Dependencies:
% basis_functions_weighted_p2.m
% basis_functions_weighted_HL_p2.m
% create_b_HL_p2.m
% display_errors.m
% errors_no_exact_weighted_p2.m
% errors_no_exact_weighted_HL_p2.m
% prolongation_matrix.m
% stiffness_matrix_weighted_p2.m
% stiffness_matrix_weighted_HL_p2.m
%
% Note:
% prolongation_matrix.m not working yet. Thus errors are wrong.
Expand Down Expand Up @@ -86,7 +87,7 @@

% Solve
[basis,Qh] = solve(p,p2,e,t,t2,u,grad_u_r,grad_u_z,n);
[err(i),grad_err(i),max_err(i)] = errors_no_exact_weighted_p2(p,t,p2,t2,basis,Qh_extended,Qh,n);
[err(i),grad_err(i),max_err(i)] = errors_no_exact_weighted_HL_p2(p,t,p2,t2,basis,Qh_extended,Qh,n);
end

display_errors(err,grad_err,max_err)
Expand All @@ -98,10 +99,10 @@

% subfunction
function [basis,Qh] = solve(p,p2,e,t,t2,u,grad_u_r,grad_u_z,n)
basis = basis_functions_weighted_p2(p,t,p2,t2);
S = stiffness_matrix_weighted_p2(p,t,p2,t2,basis,n);
basis = basis_functions_weighted_HL_p2(p,t,p2,t2);
S = stiffness_matrix_weighted_HL_p2(p,t,p2,t2,basis,n);
disp(S);
b = create_b_p2(p,t,p2,t2,basis,u,grad_u_r,grad_u_z,n);
b = create_b_HL_p2(p,t,p2,t2,basis,u,grad_u_r,grad_u_z,n);
disp(b);
Qh = S\b;
disp(Qh);
Expand Down
28 changes: 15 additions & 13 deletions weighted_HL_k_0_p2_e.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function [err,grad_err,max_err] = weighted_HL_k_0_e(f,grad_f_r,grad_f_z,gd,sf,ns,mesh_level,n,u,grad_u_r,grad_u_z)
%WEIGHTED_HL_K_0_e Weighted Hodge Laplacian with k = 0.
function [err,grad_err,max_err] = weighted_HL_k_0_p2_e(f,grad_f_r,grad_f_z,gd,sf,ns,mesh_level,n,u,grad_u_r,grad_u_z)
%WEIGHTED_HL_K_0_P2_E Weighted Hodge Laplacian with k = 0.
% This program is set up to be given an exact solution.
%
% Syntax:
Expand Down Expand Up @@ -28,15 +28,17 @@
% n = 1;
% pdepoly([0,1,1,0], [0,0,1,1]);
% (OR) [gd,sf,ns] = get_gd_sf_ns([0,1,1,0],[0,0,1,1]);
% [err,grad_err,max_err] = weighted_HL_k_0_e(f,grad_f_r,grad_f_z,gd,sf,ns,mesh,n,u,grad_u_r,grad_u_z)
% [err,grad_err,max_err] = weighted_HL_k_0_p2_e(f,grad_f_r,grad_f_z,gd,sf,ns,mesh,n,u,grad_u_r,grad_u_z)
% Dependencies:
% basis_functions_weighted_p2.m
% basis_functions_weighted_HL_p2.m
% create_b_HL_p2.m
% display_errors.m
% errors_exact_weighted_p2.m
% stiffness_matrix_weighted_p2.m
% errors_exact_weighted_HL_p2.m
% stiffness_matrix_weighted_HL_p2.m
%
% Author: Nicole Stock
% Date: Fall 2020

addpath('data')

model=createpde(1);
Expand All @@ -61,7 +63,7 @@
[p2,t2] = find_midpoints(p,t);

[basis,Qh] = solve(p,p2,e,t,t2,f,grad_f_r,grad_f_z,n);
[err(1),grad_err(1),max_err(1)] = errors_exact_weighted_p2(p,t,p2,t2,basis,Qh,n,u,grad_u_r,grad_u_z);
[err(1),grad_err(1),max_err(1)] = errors_exact_weighted_HL_p2(p,t,p2,t2,basis,Qh,n,u,grad_u_r,grad_u_z);

for i = 2:mesh_level
% Refine mesh to next level
Expand All @@ -72,7 +74,7 @@
[p2,t2] = find_midpoints(p,t);

[basis,Qh] = solve(p,p2,e,t,t2,f,grad_f_r,grad_f_z,n);
[err(i),grad_err(i),max_err(i)] = errors_exact_weighted_p2(p,t,p2,t2,basis,Qh,n,u,grad_u_r,grad_u_z);
[err(i),grad_err(i),max_err(i)] = errors_exact_weighted_HL_p2(p,t,p2,t2,basis,Qh,n,u,grad_u_r,grad_u_z);

end
display_errors(err,grad_err,max_err)
Expand All @@ -85,11 +87,11 @@

% subfunction
function [basis,Qh] = solve(p,p2,e,t,t2,f,grad_f_r,grad_f_z,n)
basis = basis_functions_weighted_p2(p,t,p2,t2);
S = stiffness_matrix_weighted_p2(p,t,p2,t2,basis,n);
b = create_b_p2(p,t,p2,t2,basis,f,grad_f_r,grad_f_z,n);
basis = basis_functions_weighted_HL_p2(p,t,p2,t2);
S = stiffness_matrix_weighted_HL_p2(p,t,p2,t2,basis,n);
b = create_b_HL_p2(p,t,p2,t2,basis,f,grad_f_r,grad_f_z,n);
Qh = S\b;

figure();
pdeplot([p,p2],e,t, 'XYData',Qh, 'ZData', Qh, 'Mesh', 'on');
%figure();
%pdeplot([p,p2],e,t, 'XYData',Qh, 'ZData', Qh, 'Mesh', 'on');
end

0 comments on commit 6387f89

Please sign in to comment.