-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathBoundaryMat.m
More file actions
67 lines (52 loc) · 1.13 KB
/
BoundaryMat.m
File metadata and controls
67 lines (52 loc) · 1.13 KB
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
function [p g] = BoundaryMat(p,g)
% create a matrix C that is 1 where uplift and erosion should occur,
% 0 where it shouldn't
%
% and a vector bvec representing boundary conditions. bvec is
% [left right upper lower]
% with
% 0 = fixed elevation
% 1 = mirror
% 2 = periodic
g.C=ones(p.K,p.J);
p.bvec=zeros(1,4);
switch p.bdy.left
case 'fixed'
g.C(:,1)=0;
p.bvec(1)=0;
case 'mirror'
p.bvec(1)=1;
case 'periodic'
p.bvec(1)=2;
end
switch p.bdy.right
case 'fixed'
g.C(:,p.J)=0;
p.bvec(2)=0;
case 'mirror'
p.bvec(2)=1;
case 'periodic'
p.bvec(2)=2;
end
switch p.bdy.upper
case 'fixed'
g.C(1,:)=0;
p.bvec(3)=0;
case 'mirror'
p.bvec(3)=1;
case 'periodic'
p.bvec(3)=2;
end
switch p.bdy.lower
case 'fixed'
g.C(p.K,:)=0;
p.bvec(4)=0;
case 'mirror'
p.bvec(4)=1;
case 'periodic'
p.bvec(4)=2;
end
% Set additional fixed points
if isfield(p,'F') % if user specified additional fixed points
g.C(p.F==1) = 0;
end