-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFun_SetInvFaultBoundary.m
More file actions
51 lines (38 loc) · 1.72 KB
/
Copy pathFun_SetInvFaultBoundary.m
File metadata and controls
51 lines (38 loc) · 1.72 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
function [isStable, NormSlip] = Fun_SetInvFaultBoundary( ...
slip, locadep, gridsize, CCritSlip)
% =========================================================================
% Determine whether low-slip margins exist around the main rupture area
% =========================================================================
maxSlip = max(slip(:));
if isempty(maxSlip) || ~isfinite(maxSlip) || maxSlip <= 0
warning('The inverted slip is zero, negative, or invalid.');
isStable = true;
NormSlip = zeros(size(slip));
return;
end
NormSlip = slip ./ maxSlip;
% Retain only the main rupture region.
NormSlip(NormSlip <= CCritSlip) = 0;
% Number of zero-slip rows from the top edge.
topCumulative = cumsum(sum(NormSlip, 2));
nZeroTop = sum(topCumulative == 0);
% Number of zero-slip rows from the bottom edge.
bottomCumulative = cumsum(flipud(sum(NormSlip, 2)));
nZeroBottom = sum(bottomCumulative == 0);
% Number of zero-slip columns from the left edge.
leftCumulative = cumsum(sum(NormSlip, 1));
nZeroLeft = sum(leftCumulative == 0);
% Number of zero-slip columns from the right edge.
rightCumulative = cumsum(fliplr(sum(NormSlip, 1)));
nZeroRight = sum(rightCumulative == 0);
% If the top row is near or above the surface, it is accepted directly;
% otherwise, require at least one low-slip row at the top edge.
Cond1 = (locadep(1) < gridsize(1)) || (nZeroTop >= 1);
% Require low-slip margins at the lower, left, and right edges.
Cond2 = (nZeroBottom >= 1) && ...
(nZeroLeft >= 1) && ...
(nZeroRight >= 1);
isStable = Cond1 && Cond2;
fprintf([' Zero-slip margins [Top Bottom Left Right] = ','[%d %d %d %d]\n'], ...
nZeroTop, nZeroBottom, nZeroLeft, nZeroRight);
end