| 1 |
function [nodes, A] = create_matrix(nregion_nodes_x, nregion_nodes_y, nintervals_x, nintervals_y) |
| 2 |
|
| 3 |
% INPUT: |
| 4 |
% nregions_nodes_x : number of nodes along the x direction for each region |
| 5 |
% nregions_nodes_y : number of nodes along the y direction for each region |
| 6 |
% nintervals_x : number of intervals splitting the domain along the x direction |
| 7 |
% nintervals_y : number of intervals splitting the domain along the y direction |
| 8 |
% |
| 9 |
% OUTPUT: |
| 10 |
% nodes: global node labels with region index associated with it |
| 11 |
% A: composite matrix |
| 12 |
% |
| 13 |
% A(i,j) = k if node j belongs to regions to region k |
| 14 |
|
| 15 |
[nodes, nodesToRegion, ~, nodes_neighbourhood] = create_regions( nregion_nodes_x, nregion_nodes_y, nintervals_x, nintervals_y ); |
| 16 |
|
| 17 |
nTotal_nodes = size(nodesToRegion,1); |
| 18 |
|
| 19 |
A = sparse(nTotal_nodes, nTotal_nodes); |
| 20 |
|
| 21 |
for i = 1: nTotal_nodes |
| 22 |
|
| 23 |
cols = nodes_neighbourhood{i}; |
| 24 |
|
| 25 |
for j = 1:length(cols) |
| 26 |
|
| 27 |
%A(i, cols(j)) = nodesOwnership(cols(j)); |
| 28 |
if( i==cols(j) ) |
| 29 |
A(i, cols(j)) = 8; |
| 30 |
else |
| 31 |
A(i, cols(j)) = -1; |
| 32 |
end |
| 33 |
|
| 34 |
end |
| 35 |
|
| 36 |
end |
| 37 |
|
| 38 |
end |