-
Notifications
You must be signed in to change notification settings - Fork 15
/
lattice3d.m
74 lines (60 loc) · 2.02 KB
/
lattice3d.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
function lat = lattice3d()
% build 3d redundancy lattice
lat.Nx = 3;
lat.Nnodes = 18;
lat.Nelements = 7;
lat.elements = {1, 2, 3, [1 2], [1 3], [2 3], [1 2 3]};
lat.A = {
{1 2 3};
{1 2}; {1 3}; {2 3};
{1 [2 3]}; {2 [1 3]}; {3 [1 2]};
{1}; {2}; {3}; {[1 2] [1 3] [2 3]};
{[1 2] [1 3]}; {[1 2] [2 3]}; {[1 3] [2 3]};
{[1 2]}; {[1 3]}; {[2 3]};
{[1 2 3]} }';
lat.level = [1 2 2 2 3 3 3 4 4 4 4 5 5 5 6 6 6 7];
lat.Nlevels = max(lat.level);
labels = cell(size(lat.A));
for ni=1:lat.Nnodes
thsA = lat.A{ni};
st = cell(size(thsA));
for ai=1:length(st)
st{ai} = sprintf('{%s}',sprintf('%d',thsA{ai}));
end
labels{ni} = sprintf('%s',st{:});
end
lat.labels = labels;
nodes = containers.Map(lat.labels, 1:lat.Nnodes);
parents = cell(1,lat.Nnodes);
n = nodes;
parents{n('{1}{2}{3}')} = [n('{1}{2}') n('{1}{3}') n('{2}{3}')];
parents{n('{1}{2}')} = [n('{1}{23}') n('{2}{13}')];
parents{n('{1}{3}')} = [n('{1}{23}') n('{3}{12}')];
parents{n('{2}{3}')} = [n('{2}{13}') n('{3}{12}')];
parents{n('{1}{23}')} = [n('{1}') n('{12}{13}{23}')];
parents{n('{2}{13}')} = [n('{2}') n('{12}{13}{23}')];
parents{n('{3}{12}')} = [n('{3}') n('{12}{13}{23}')];
parents{n('{1}')} = n('{12}{13}');
parents{n('{2}')} = n('{12}{23}');
parents{n('{3}')} = n('{13}{23}');
parents{n('{12}{13}{23}')} = [n('{12}{13}') n('{12}{23}') n('{13}{23}')];
parents{n('{12}{13}')} = [n('{12}') n('{13}')];
parents{n('{12}{23}')} = [n('{12}') n('{23}')];
parents{n('{13}{23}')} = [n('{13}') n('{23}')];
parents{n('{12}')} = n('{123}');
parents{n('{13}')} = n('{123}');
parents{n('{23}')} = n('{123}');
% build children for birectional link
children = cell(1,lat.Nnodes);
for ni=1:lat.Nnodes
for parent=parents{ni}
children{parent} = [children{parent} ni];
end
end
lat.nodes = nodes;
lat.parents = parents;
lat.children = children;
lat.top = nodes('{123}');
lat.bottom = nodes('{1}{2}{3}');
lat.Icap = NaN(1,lat.Nnodes);
lat.PI = NaN(1,lat.Nnodes);