-
Notifications
You must be signed in to change notification settings - Fork 0
/
set_up_DD_normal_sparse.m
69 lines (60 loc) · 1.98 KB
/
set_up_DD_normal_sparse.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
% Author: Hussam Al Daas
% Email: [email protected]
% Date: 14/04/2022
function [p, Oi, Og, O, ri, D, kc, km] = set_up_DD_normal_sparse(C, A, N, zeroBoundaryPartUnity, varargin)
[m, n] = size(C);
if m ~= n
fprintf("Matrix is not squared\n");
return;
end
[p, ~, ~, b, e] = Partition(C, N);
Oi = cell(N, 1); % Interior subdomain
Og = Oi; % Interface of subdomain
O = Og; % Overlapping subdomain
D = O; % Partition of unity (PoU)
ri = D; % Nonzero rows of interior subdomain columns in A
p1n = 1:n;
p = p1n(p);
for i = 1 : N
Oi{i} = p(b(i) : e(i));
[~, ci, ~] = find(C(Oi{i}, :)); % Find nonzero column in row block
ci = unique(ci)'; % Get the unique ones: this is the overlapping subdomain not ordered
Og{i} = setdiff(ci, Oi{i}); % Set the boundary
O{i} = [Oi{i}, Og{i}]; % Set the overlapping nodes in order [Interior, Interface]
[ri{i}, ~, ~] = find(A(:, Oi{i})); % Get indices of nonzero rows in interior subdomain columns in A
ri{i} = unique(ri{i});
D{i} = speye(length(O{i})); % Set the PoU matrix to I
end
SD = sparse(n, n); % will contain the sum of the partition of unity
for i = 1 : N
GD = sparse(n, n); % To expand the local PoU
GD(O{i}, O{i}) = D{i}; % Set the values
SD = SD + GD; % Sum the ith PoU
end
% Set up linear continuous PoU
for i = 1 : N
D{i} = sparse(diag(1./diag(SD(O{i}, O{i}))));
end
km = max(diag(SD)); % multiplicity constant
if(zeroBoundaryPartUnity)
for i = 1 : N
lOi = length(Oi{i});
lO = length(O{i});
D{i} = speye(lO);
D{i}(lOi + 1 : lO, lOi + 1 : lO) = 0 * D{i}(lOi + 1 : lO, lOi + 1 : lO);
end
end
k_c = zeros(N, 1); % number of colors
for i = 1 : N
for j = 1 : N
if j == i
continue;
end
if(~isempty(intersect(O{i}, O{j})))
k_c(i) = k_c(i) + 1;
end
end
end
kc = max(k_c);
kcp1 = kc + 1;
kc = kcp1;