comparison +grid/Curvilinear.m @ 200:ef41fde95ac4 feature/beams

Merged feature/grids into feature/beams.
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 13 Jun 2016 16:59:02 +0200
parents 7c1d3fc33f90
children 30321dc180e1
comparison
equal deleted inserted replaced
181:419ec303e97d 200:ef41fde95ac4
78 if isempty(obj.logic.h) 78 if isempty(obj.logic.h)
79 error('grid:Curvilinear:NoScalingSet','No scaling set'); 79 error('grid:Curvilinear:NoScalingSet','No scaling set');
80 end 80 end
81 h = obj.logic.h; 81 h = obj.logic.h;
82 end 82 end
83
84 % Return the names of all boundaries in this grid.
85 function bs = getBoundaryNames(obj)
86 bs = obj.logic.getBoundaryNames();
87 end
88
89 % Return coordinates for the given boundary
90 function X = getBoundary(obj, name)
91 % In what dimension is the boundary?
92 switch name
93 case {'l', 'r', 'w', 'e'}
94 D = 1;
95 case {'s', 'n'}
96 D = 2;
97 case {'d', 'u'}
98 D = 3;
99 otherwise
100 error('not implemented');
101 end
102
103 % At what index is the boundary?
104 switch name
105 case {'l', 'w', 's', 'd'}
106 index = 1;
107 case {'r', 'e', 'n', 'u'}
108 index = obj.logic.m(D);
109 otherwise
110 error('not implemented');
111 end
112
113
114
115 I = cell(1, obj.D);
116 for i = 1:obj.D
117 if i == D
118 I{i} = index;
119 else
120 I{i} = ':';
121 end
122 end
123
124 % Calculate size of result:
125 m = obj.logic.m;
126 m(D) = [];
127 N = prod(m);
128
129 X = zeros(N, obj.D);
130
131 p = obj.points;
132 for i = 1:obj.D()
133 coordMat{i} = reshapeRowMaj(p(:,i), obj.logic.m);
134 end
135
136 for i = 1:length(coordMat)
137 Xtemp = coordMat{i}(I{:});
138 X(:,i) = reshapeRowMaj(Xtemp, [N,1]);
139 end
140 end
83 end 141 end
84 end 142 end
85 143
86 144
87 function coords = cellMappingToCoords(mapping, N, D, m) 145 function coords = cellMappingToCoords(mapping, N, D, m)