-
Notifications
You must be signed in to change notification settings - Fork 1
/
in_boundary.m
executable file
·73 lines (58 loc) · 3.46 KB
/
in_boundary.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
% This subroutine computes the boundary of the set grid_points_base before
% fattening it.
function boundary_indexes=in_boundary(N,grid_points_base)
w=1;
boundary_indexes=zeros(N*N,2);
for j=1:N
for k=1:N
if(grid_points_base(1,3,j,k)==1)
if(j>1 && k>1 && j<N && k<N)
if(grid_points_base(1,3,j-1,k-1)==0 || grid_points_base(1,3,j-1,k)==0 || grid_points_base(1,3,j-1,k+1)==0 || grid_points_base(1,3,j,k-1)==0 || grid_points_base(1,3,j,k+1)==0 || grid_points_base(1,3,j+1,k-1)==0 || grid_points_base(1,3,j+1,k)==0 || grid_points_base(1,3,j+1,k+1)==0)
boundary_indexes(w,:)=[j,k];
w=w+1;
end;
elseif(j==1 && k>1 && k<N)
if(grid_points_base(1,3,j,k-1)==0 || grid_points_base(1,3,j,k+1)==0 || grid_points_base(1,3,j+1,k-1)==0 || grid_points_base(1,3,j+1,k)==0 || grid_points_base(1,3,j+1,k+1)==0)
boundary_indexes(w,:)=[j,k];
w=w+1;
end;
elseif(k==1 && j>1 && j<N)
if(grid_points_base(1,3,j-1,k)==0 || grid_points_base(1,3,j-1,k+1)==0 || grid_points_base(1,3,j,k+1)==0 || grid_points_base(1,3,j+1,k)==0 || grid_points_base(1,3,j+1,k+1)==0)
boundary_indexes(w,:)=[j,k];
w=w+1;
end;
elseif(j==N && k>1 && k<N)
if(grid_points_base(1,3,j-1,k-1)==0 || grid_points_base(1,3,j-1,k)==0 || grid_points_base(1,3,j-1,k+1)==0 || grid_points_base(1,3,j,k-1)==0 || grid_points_base(1,3,j,k+1)==0)
boundary_indexes(w,:)=[j,k];
w=w+1;
end;
elseif(k==N && j>1 && j<N)
if(grid_points_base(1,3,j-1,k-1)==0 || grid_points_base(1,3,j-1,k)==0 || grid_points_base(1,3,j,k-1)==0 || grid_points_base(1,3,j+1,k-1)==0 || grid_points_base(1,3,j+1,k)==0)
boundary_indexes(w,:)=[j,k];
w=w+1;
end;
elseif(j==1 && k==1)
if(grid_points_base(1,3,j,k+1)==0 || grid_points_base(1,3,j+1,k)==0 || grid_points_base(1,3,j+1,k+1)==0)
boundary_indexes(w,:)=[j,k];
w=w+1;
end;
elseif(j==1 && k==N)
if(grid_points_base(1,3,j,k-1)==0 || grid_points_base(1,3,j+1,k-1)==0 || grid_points_base(1,3,j+1,k)==0)
boundary_indexes(w,:)=[j,k];
w=w+1;
end;
elseif(j==N && k==N)
if(grid_points_base(1,3,j-1,k)==0 || grid_points_base(1,3,j-1,k-1)==0 || grid_points_base(1,3,j,k-1)==0)
boundary_indexes(w,:)=[j,k];
w=w+1;
end;
elseif(j==N && k==1)
if(grid_points_base(1,3,j-1,k)==0 || grid_points_base(1,3,j-1,k+1)==0 || grid_points_base(1,3,j,k+1)==0)
boundary_indexes(w,:)=[j,k];
w=w+1;
end;
end;
end;
end;
end;
boundary_indexes=boundary_indexes(1:w-1,:);