Skip to content

Commit

Permalink
Updating documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
NEStock committed Mar 1, 2021
1 parent 1cfbb37 commit 33e8d88
Show file tree
Hide file tree
Showing 32 changed files with 74 additions and 32 deletions.
6 changes: 4 additions & 2 deletions find_edge_connectivity.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function [t_ed] = find_edge_connectivity(t,ed,mesh)
% FIND_EDGES - Find the edges in each triangulation in the mesh
% FIND_EDGE_CONNECTIVITY - Find the edges in each triangulation in the mesh
%
% Syntax:
% [ed, t_ed] = find_edges(t)
Expand All @@ -20,7 +20,9 @@
% Date: Fall 2020

if exist('mesh','var')
% mesh is given
% if mesh is given
% determine if we have saved a matrix for the given mesh & domain to
% save computational time
if mesh == 6 && isfile('edge_resources/t_ed_6.mat')
t_ed_6 = load('edge_resources/t_ed_6.mat');
t_ed = t_ed_6.t_ed_6;
Expand Down
2 changes: 2 additions & 0 deletions k_0/data/get_data1.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
% data1
% u = (1/3)r^3 - (1/2)r^2
% f = -(8/3)r + (5/2)
% Author: Nicole Stock
% Date: Fall 2020

f = @(r,z) -(8./3).*r + (3./2);
grad_f_r =@(r,z) -8./3;
Expand Down
2 changes: 2 additions & 0 deletions k_0/data/get_data2.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
% data2
% u = r^3 - (3/2)r^2
% f = -8r + 9/2
% Author: Nicole Stock
% Date: Fall 2020

f = @(r,z) -8.*r + (9./2);
grad_f_r =@(r,z) -8;
Expand Down
2 changes: 2 additions & 0 deletions k_0/data/get_data3.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
%GET_U_DATA3 Get u and f function handles
%
% u = r^(1/2)
% Author: Nicole Stock
% Date: Fall 2020

u = @(r,z) r.^(1./2);
grad_u_r =@(r,z) (1./2).*r.^(-1./2);
Expand Down
2 changes: 2 additions & 0 deletions k_0/data/get_data4.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
%GET_U_DATA4 Get u and f function handles
%
% u = r^(2/3)
% Author: Nicole Stock
% Date: Fall 2020

u = @(r,z) r.^(2./3);
grad_u_r =@(r,z) (2./3).*r.^(-1./3);
Expand Down
2 changes: 2 additions & 0 deletions k_0/data/get_data5.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
%GET_U_DATA5 Get u and f function handles
%
% u = r^(5/6)
% Author: Nicole Stock
% Date: Fall 2020

u = @(r,z) r.^(5./6);
grad_u_r =@(r,z) (5./6).*r.^(-1./6);
Expand Down
2 changes: 2 additions & 0 deletions k_0/data/get_data6.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
%GET_U_DATA6 Get u and f function handles
%
% u = r*sin(z)
% Author: Nicole Stock
% Date: Fall 2020

u = @(r,z) r.*sin(z);
grad_u_r =@(r,z) sin(z);
Expand Down
2 changes: 2 additions & 0 deletions k_0/data/get_data7.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
%GET_U_DATA7 Get u and f function handles
%
% u = r^(1/3)
% Author: Nicole Stock
% Date: Fall 2020

u = @(r,z) r.^(1./3);
grad_u_r =@(r,z) (1./3).*r.^(-2./3);
Expand Down
2 changes: 2 additions & 0 deletions k_0/data/get_data8.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
%GET_U_DATA8 Get u and f function handles
% data3
% u = r^(4/3)
% Author: Nicole Stock
% Date: Fall 2020

u = @(r,z) r.^(4./3);
grad_u_r =@(r,z) (4./3).*r.^(1./3);
Expand Down
2 changes: 2 additions & 0 deletions k_0/data/get_data9.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
function [f,grad_f_r,grad_f_z,u,grad_u_r,grad_u_z] = get_data9()
%GET_U_DATA9 Get u and f function handles
% u = r^(5/3)
% Author: Nicole Stock
% Date: Fall 2020

u = @(r,z) r.^(5./3);
grad_u_r =@(r,z) (5./3).*r.^(2./3);
Expand Down
2 changes: 1 addition & 1 deletion k_0/p1/basis_functions_weighted_HL_k_0_p1.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
%
% Outputs:
% basis - a matrix representing piece-wise basis functions for each node
% in each triangle. basis(i,:,T) represents the pieceiwise basis
% in each triangle. basis(:,i,T) represents the pieceiwise basis
% function for the ith node in triangle T.
%
% Author: Nicole Stock
Expand Down
3 changes: 3 additions & 0 deletions k_1/data/get_data_1.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
% f = [ -15r^2 + 8r + n^2r^2 - n^2r
% 2nr^2 - 2nr
% 0 ]
% Author: Nicole Stock
% Date: Fall 2020

u_vec_r = @(r,z) r.^4 - r.^3;
u_vec_th = @(r,z) 0;
u_vec_z = @(r,z) 0;
Expand Down
4 changes: 2 additions & 2 deletions k_1/lowest_order/create_B_weighted_HL_k_1_p1.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function B = create_B_weighted_HL_k_1_p1(p,t,ed,t_ed,basis_nodes,basis_edges,n)
% CREATE_B_WEIGHTED_HL_K_1_P1 - Create B matrix
% Hodge Laplacian k = 1 case, P1
% Hodge Laplacian k = 1 case, lowest order
% (grad_rz^n(phi_i), zeta_j)_r where {phi_k}k=1->N is the basis for Ah
% and {zeta_l}l=1->N+Ne is the basis for Bh
% (Ah is the weighted P1 space)
Expand Down Expand Up @@ -55,7 +55,7 @@

[R,Z,Wr,Wz] = triquad(7, coordinates);

% integrate for each pair of edges + 1 in the triangle
% integrate for each pair of basis functions in the triangle
for i = 1:3
for j = 1:6
I = basis_nodes(:,i,T);
Expand Down
2 changes: 1 addition & 1 deletion k_1/lowest_order/create_F_weighted_HL_k_1_p1.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
% weight
%
% Outputs:
% S - S matrix used to solve system of equations to approximate
% F - F matrix used to solve system of equations to approximate
% solution
%
% Author: Nicole Stock
Expand Down
2 changes: 1 addition & 1 deletion k_1/lowest_order/create_S_weighted_HL_k_1_p1.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

[R,Z,Wr,Wz] = triquad(7, coordinates);

% integrate for each pair of edges + 1 in the triangle
% integrate for each pair of basis functions in the triangle
for i = 1:6
for j = i:6
if i <=3
Expand Down
2 changes: 1 addition & 1 deletion k_1/lowest_order/errors_exact_weighted_HL_k_1_p1.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
% Hodge Laplacian k = 1 case, P1
%
% Syntax:
% [err,grad_err,max_err] =
% [err_u,err_s] =
% errors_exact_weighted_HL_k_1_p1
% Inputs:
% p - a 2xNumNodes matrix representing nodal coordinates.
Expand Down
15 changes: 9 additions & 6 deletions k_1/lowest_order/weighted_HL_k_1_e.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
function [err_u,err_s] = weighted_HL_k_1_e(f_vec_r,f_vec_th,f_vec_z,gd,sf,ns,mesh,u_vec_r,u_vec_th,u_vec_z,s,n)
%WEIGHTED_HL_K_1_E Hodge Laplacian k = 1 P1 Finite Element Method.
%WEIGHTED_HL_K_1_E Hodge Laplacian k = 1 lowest order Finite Element Method.
% This program is set up to be given an exact solution.
% Hodge Laplacian k = 1 case, P1
% {phi_i}i=1->N is the basis for Ah
% {zeta_j}j=1->N+Ne is the basis for Bh
% Hodge Laplacian k = 1 case, lowest order
% {phi_i}i=1->N is the basis for Ah0
% {zeta_j}j=1->N+Ne is the basis for Bh0
% (Ah is the weighted P1 space)
% (Bh is the weighted fourier modified Nedelec and P1 space)
% Solve for (s,u) in (Ah x Bh) s.t.
Expand All @@ -14,6 +14,8 @@
%
% Syntax:
% [err] = weighted_HL_k_1_e(f_vec_r,f_vec_th,f_vec_z,gd,sf,ns,mesh,u_vec_r,u_vec_th,u_vec_z,s,n)
%
% Inputs:
% f_vec_r - given function r component
% f_vec_th - given function theta component
% f_vec_z - given function z component
Expand All @@ -31,11 +33,11 @@
% Usage Exampled:
% addpath ../../data ../data/
% n = 1;
% [u_vec_r,u_vec_th,u_vec_z,s,f_vec_r,f_vec_th,f_vec_z] = get_data_1(n)
% [u_vec_r,u_vec_th,u_vec_z,s,f_vec_r,f_vec_th,f_vec_z] = get_data_1(n);
% mesh = 7;
% 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_u,err_s] = weighted_HL_k_1_e(f_vec_r,f_vec_th,f_vec_z,gd,sf,ns,mesh,u_vec_r,u_vec_th,u_vec_z,s,n)
% [err_u,err_s] = weighted_HL_k_1_e(f_vec_r,f_vec_th,f_vec_z,gd,sf,ns,mesh,u_vec_r,u_vec_th,u_vec_z,s,n);
% Dependencies:
% find_edge_connectivity.m
% basis_functions_weighted_modified_nedelec_and_p1.m
Expand All @@ -52,6 +54,7 @@
addpath('../../');
addpath('../../modified_weighted_nedelec_pk/p1/');
addpath('../../nedelec/weighted_lowest_order/')
addpath('../../k_0/p1/');

model=createpde(1);
g=decsg(gd,sf,ns);
Expand Down
2 changes: 2 additions & 0 deletions k_2/data/get_data_1.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
% f = [ 3n^2 - (3n^2)/r + 6n - (4n)/r - 9
% -3n^2 + (2n^2)/r - 6n + (6n)/r + 9
% 0 ]
% Author: Nicole Stock
% Date: Fall 2020

s_vec_r = @(r,z) 3.*r.*(r-1); % 3.*r.^2 - 3.*r
s_vec_th = @(r,z) -3.*r.^2 + 2.*r;
Expand Down
4 changes: 2 additions & 2 deletions k_2/lowest_order/create_F_weighted_HL_k_2_p1.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
% f_vec_z - given function z component
%
% Outputs:
% S - S matrix used to solve system of equations to approximate
% F - F matrix used to solve system of equations to approximate
% solution
%
% Author: Nicole Stock
Expand Down Expand Up @@ -87,4 +87,4 @@

F = sparse(i_vec,j_vec,s_vec,edges+triangles,1);

% end
% end
6 changes: 3 additions & 3 deletions k_2/lowest_order/create_S_weighted_HL_k_2_p1.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function S = create_S_weighted_HL_k_2_p1(p,t,ed,t_ed,basis_RT_edges,basis_triangles)
% CREATE_S_WEIGHTED_HL_K_2_P1 - Create S matrix
% Hodge Laplacian k = 2 case, P1
% Hodge Laplacian k = 2 case, lowest order
% (div_rz^n(psi_i), div_rz^n(psi_j))_r where {psi_j}j=1->Ne+Nt is the basis for Ch
% (Ch is the weighted fourier Raviart Thomas space)
%
Expand All @@ -26,7 +26,7 @@
% function for the Tth triangle.
%
% Outputs:
% B - B matrix used to solve system of equations to approximate
% S - S matrix used to solve system of equations to approximate
% solution
%
% Author: Nicole Stock
Expand Down Expand Up @@ -99,4 +99,4 @@

S = sparse(i_vec,j_vec,s_vec,edges+triangles,edges+triangles);

% end
% end
4 changes: 2 additions & 2 deletions k_2/lowest_order/mass_matrix_weighted_HL_k_2_p1.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function mass_matrix = mass_matrix_weighted_HL_k_2_p1(p,t,ed,t_ed,basis_nodes,basis_edges,n)
% MASS_MATRIX_WEIGHTED_HL_K_2_P1 - Create mass matrix
% Hodge Laplacian k = 2 case, P1
% Hodge Laplacian k = 2 case, lowest order
% (zeta_i, zeta_j)_r where {zeta_k}k=1->(N+Ne) is the basis for Bh
% (Bh is the weighted fourier modified Nedelec and P1 space)
%
Expand Down Expand Up @@ -112,4 +112,4 @@
end

mass_matrix = sparse(i_vec,j_vec,s_vec,nodes+edges,nodes+edges);
% end
% end
8 changes: 4 additions & 4 deletions k_2/lowest_order/weighted_HL_k_2_e.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
function [err_u,err_s] = weighted_HL_k_2_e(f_vec_r,f_vec_th,f_vec_z,gd,sf,ns,mesh,u_vec_r,u_vec_th,u_vec_z,s_vec_r,s_vec_th,s_vec_z,n)
%WEIGHTED_HL_K_1_E Hodge Laplacian k = 1 P1 Finite Element Method.
%WEIGHTED_HL_K_2_E Hodge Laplacian k = 2 lowest order Finite Element Method.
% This program is set up to be given an exact solution.
% Hodge Laplacian k = 2 case, P1
% {zeta_j}j=1->N+Ne is the basis for Bh
% {psi_i}i=1->Ne+Nt is the basis for Ch
% Hodge Laplacian k = 2 case, lowest order
% {zeta_j}j=1->N+Ne is the basis for Bh0
% {psi_i}i=1->Ne+Nt is the basis for Ch0
% (Bh is the weighted fourier modified Nedelec and P1 space)
% (Ch is the weighted fourier Raviart Thomas space)
% Solve for (s,u) in (Bh x Ch) s.t.
Expand Down
4 changes: 1 addition & 3 deletions k_3/lowest_order/errors_exact_weighted_HL_k_3_p1.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@
% find L2 Error for p
integrand =@(r,z) ((p_exact(r,z) - p_h(T)).^2).*r;

integral_p = integral_p + Wx'*feval(integrand,X,Y)*Wy;


integral_p = integral_p + Wx'*feval(integrand,X,Y)*Wy;
end

err_z = sqrt(integral_z);
Expand Down
8 changes: 4 additions & 4 deletions k_3/lowest_order/weighted_HL_k_3_e.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
function [err_z,err_p] = weighted_HL_k_3_e(f,gd,sf,ns,mesh,z_vec_r,z_vec_th,z_vec_z,p_exact,n)
%WEIGHTED_HL_K_3_E Hodge Laplacian k = 3 P1 Finite Element Method.
%WEIGHTED_HL_K_3_E Hodge Laplacian k = 3 lowest order Finite Element Method.
% This program is set up to be given an exact solution.
% Hodge Laplacian k = 3 case, P1
% {psi_i}i=1->Ne+Nt is the basis for Ch
% {chi_j}j=1->Nt is the basis for Dh
% Hodge Laplacian k = 3 case, lowest order
% {psi_i}i=1->Ne+Nt is the basis for Ch0
% {chi_j}j=1->Nt is the basis for Dh0
% (Ch is the weighted fourier Raviart Thomas space)
% (Dh is the piecewise constant space)
% Solve for (z,p) in (Ch x Dh) s.t.
Expand Down
2 changes: 2 additions & 0 deletions modified_weighted_nedelec_pk/data/p1/get_data_1.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
% F = [ n(r-1) + u_r ]
% [ -2r + 1 + u_th ]
% [ u_z ]
% Author: Nicole Stock
% Date: Fall 2020

u_vec_r = @(r,z) z - (1./n).*((1./3).*r.^3 - (1./2).*r.^2);
u_vec_th = @(r,z) (-1).*n.*z + (1./3).*r.^3 - (1./2).*r.^2;
Expand Down
2 changes: 2 additions & 0 deletions nedelec/data/weighted/get_data_1.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
%GET_DATA_1 Get u vector and f vector
% u = [ sin(pi*r) ; cos(pi*r) ]
% F = u
% Author: Nicole Stock
% Date: Fall 2020

u_vec_r = @(r,z) sin(pi.*r);
u_vec_z = @(r,z) cos(pi.*z);
Expand Down
2 changes: 2 additions & 0 deletions nedelec/data/weighted/get_data_2.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
% (1/2)r^2z - rz ]
% F = [ (1/3)rz^3 - (1/3)z^3 - 2rz + 2z + r - 1
% 2z^2 - (z^2)/r + (1/2)r^2z - rz - 2z + z/r ]
% Author: Nicole Stock
% Date: Fall 2020

u_vec_r =@(r,z) (1/3).*(r-1).*z.^3;
u_vec_z =@(r,z) (1/2).*r.^2.*z - r.*z;
Expand Down
2 changes: 2 additions & 0 deletions nedelec/data/weighted/get_data_3.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
% (-1/2)r^2z^2 + rz^2 ]
% F = [ (-1/2)rz^2 + (1/2)z^2 - 2rz + 2z + r - 1
% (-1/2)r^2z^2 + rz^2 + 2z^2 - z^2/r - 2z + z/r ]
% Author: Nicole Stock
% Date: Fall 2020

u_vec_r =@(r,z) (-1/2).*r.*z.^2 + (1./2).*z.^2;
u_vec_z =@(r,z) (-1/2).*r.^2.*z.^2 + r.*z.^2;
Expand Down
2 changes: 2 additions & 0 deletions raviart_thomas/data/unweighted2D/get_data_1.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
% -(1/2)r^2z^2 + (1/2)rz^2 ]
% F = [ (1/3)r^3z^2 - (1/2)r^2z^2 - 2rz^2 + z^2 + 2rz - z
% -(1/2)r^2z^2 + (1/2)rz^2 - 2r^2z + 2rz + r^2 - r ]
% Author: Nicole Stock
% Date: Fall 2020

u_vec_r = @(r,z) (1./3).*(r.^3).*(z.^2) - (1./2).*(r.^2).*(z.^2);
u_vec_z = @(r,z) -(1./2).*(r.^2).*(z.^2) + (1./2).*r.*z.^2;
Expand Down
2 changes: 2 additions & 0 deletions raviart_thomas/data/unweighted2D/get_data_2.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
% -(1/3)rz^3 + (1/2)rz^2 ]
% F = [ (1/3)r^3z^2 - (1/3)r^3z - 2rz^2 + z^2 + 2rz - z
% -(1/3)rz^3 + (1/2)rz^2 - 2r^2z + 2rz + r^2 - r ]
% Author: Nicole Stock
% Date: Fall 2020

u_vec_r = @(r,z) (1./3).*(r.^3).*(z.^2) - (1./3).*z.*r.^3;
u_vec_z = @(r,z) -(1./3).*r.*z.^3 + (1./2).*r.*z.^2;
Expand Down
2 changes: 2 additions & 0 deletions raviart_thomas/data/weighted/get_data_1.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
% F = [ -rz^2 - z^2 + z
% -(n/r)(rz^2 - z^2 - rz + z)
% (1/3)rz^3 - (1/2)rz^2 + (1/2)z^2 + (1/3)z^3 - 2rz + 2z + r - 1 ]
% Author: Nicole Stock
% Date: Fall 2020

u_vec_r = @(r,z) -r.*z.^2;
u_vec_th = @(r,z) 0;
Expand Down
2 changes: 2 additions & 0 deletions raviart_thomas/data/weighted/get_data_2.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
% F = [ (1/2)rz - (1/2)rz^2 - z^2 + z
% -(n/r)(rz^2 - z^2 - rz + z)
% (1/3)rz^3 - (1/2)rz^2 -2rz + 2z + r - 1 ]
% Author: Nicole Stock
% Date: Fall 2020

u_vec_r = @(r,z) (1./2).*r.*z - (1./2).*r.*z.^2;
u_vec_th = @(r,z) 0;
Expand Down

0 comments on commit 33e8d88

Please sign in to comment.