Skip to content

Commit

Permalink
Adding example edge and midpoint matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
NEStock committed Mar 10, 2021
1 parent aee7499 commit 60fd76d
Show file tree
Hide file tree
Showing 19 changed files with 117 additions and 0 deletions.
Binary file added edge_resources/t_ed_1.mat
Binary file not shown.
Binary file added edge_resources/t_ed_2.mat
Binary file not shown.
Binary file added edge_resources/t_ed_3.mat
Binary file not shown.
Binary file added edge_resources/t_ed_4.mat
Binary file not shown.
Binary file added edge_resources/t_ed_5.mat
Binary file not shown.
Binary file added edge_resources/t_ed_6.mat
Binary file not shown.
Binary file added edge_resources/t_ed_7.mat
Binary file not shown.
Binary file added edge_resources/t_ed_8.mat
Binary file not shown.
Binary file added edge_resources/t_ed_9.mat
Binary file not shown.
62 changes: 62 additions & 0 deletions get_edge_connectivity.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
function [t_ed] = get_edge_connectivity(gd,sf,ns,mesh)
% GET_EDGE_CONNECTIVITY build edge connectivitity matrix for given mesh level
%
% Syntax:
% [t_ed] = get_edges(gd,sf,ns,mesh)
%
% Inputs:
% gd,sf,ns - outputs of pdepoly specifying domain
% mesh - max mesh level
%
% Outputs:
% t_ed - a 3xNumTriangles matrix representing the which edges
% correspond to which triangles. t_ed(i,T) represents the ith edge
% in triangle T.
%
% Usage Example:
% mesh = 8;
% 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]);
% [t_ed] = get_edge_connectivity(gd,sf,ns,mesh)
%
% Dependencies:
% find_edges.m
%
% Author: Nicole Stock
% Date: Fall 2020

addpath('data')
addpath('edge_resources')

model=createpde(1);
g=decsg(gd,sf,ns);
geometryFromEdges(model,g);
[p,e,t]=initmesh(g,'hmax',inf);
tr = triangulation(t(1:3,:)',p');

if mesh > 1
% To ensure we refine every triangle the same
[~,num_node]=size(p);
it=zeros(1,num_node);
for i=1:num_node
it(i)=i;
end

for i = 2:mesh
% Refine mesh to next level
[p,e,t]=refinemesh(g,p,e,t,it,'regular');
tr = triangulation(t(1:3,:)',p');
end

% get edge information for highest mesh level
ed = edges(tr);
t_ed = find_edge_connectivity(t,ed);
end
% get edge information for highest mesh level
ed = edges(tr);
t_ed = find_edge_connectivity(t,ed);
% mesh level must be greater than 1

% end main
end

55 changes: 55 additions & 0 deletions get_midpoints.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
function [p2,t2] = get_midpoints(gd,sf,ns,mesh)
%GET_MIDPOINTS
%
% Syntax:
% [p2,t2] = get_midpoints(gd,sf,ns,mesh)
%
% Inputs:
% gd,sf,ns - outputs of pdepoly specifying domain
% mesh - max mesh level
%
% Outputs:
% p2 - a 2xNumNodes matrix representing midpoint nodal coordinates.
% t2 - a 3xNumTriangles matrix representing the element connectivity in
% terms of node IDs. The three node IDs in a column are the three
% midpoints of the node IDS in corresponding column in t.
%
% Usage Exampled:
% mesh = 8;
% 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]);
% [p2,t2] = get_midpoints(gd,sf,ns,mesh)
%
% Dependencies:
% find_midpoints.m
%
% Author: Nicole Stock
% Date: Fall 2020

model=createpde(1);
g=decsg(gd,sf,ns);
geometryFromEdges(model,g);
[p,e,t]=initmesh(g,'hmax',inf);
%pdemesh(p,e,t, 'NodeLabels','on', 'ElementLabels','on');

if mesh > 1
% To ensure we refine every triangle the same
[~,num_node]=size(p);
it=zeros(1,num_node);
for i=1:num_node
it(i)=i;
end

for i = 2:mesh
% Refine mesh to next level
[p,e,t]=refinemesh(g,p,e,t,it,'regular');
%pdemesh(p,e,t, 'NodeLabels','on', 'ElementLabels','on');
end

% Find the midpoints for P2 nodal points for the highest mesh level
[p2,t2] = find_midpoints(p,t);
end
% mesh level must be greater than 1

% end main
end
Binary file added midpoint_resources/p2_6.mat
Binary file not shown.
Binary file added midpoint_resources/p2_7.mat
Binary file not shown.
Binary file added midpoint_resources/p2_8.mat
Binary file not shown.
Binary file added midpoint_resources/p2_9.mat
Binary file not shown.
Binary file added midpoint_resources/t2_6.mat
Binary file not shown.
Binary file added midpoint_resources/t2_7.mat
Binary file not shown.
Binary file added midpoint_resources/t2_8.mat
Binary file not shown.
Binary file added midpoint_resources/t2_9.mat
Binary file not shown.

0 comments on commit 60fd76d

Please sign in to comment.