Mercurial > repos > public > sbplib
comparison +grid/Cartesian.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 | 3da69d57e684 |
comparison
equal
deleted
inserted
replaced
181:419ec303e97d | 200:ef41fde95ac4 |
---|---|
120 | 120 |
121 % Projects the grid function gf on obj to the grid g. | 121 % Projects the grid function gf on obj to the grid g. |
122 function gf = projectFunc(obj, gf, g) | 122 function gf = projectFunc(obj, gf, g) |
123 error('grid:Cartesian:NotImplemented') | 123 error('grid:Cartesian:NotImplemented') |
124 end | 124 end |
125 | |
126 % Return the names of all boundaries in this grid. | |
127 function bs = getBoundaryNames(obj) | |
128 switch obj.D() | |
129 case 1 | |
130 bs = {'l', 'r'}; | |
131 case 2 | |
132 bs = {'w', 'e', 's', 'n'}; | |
133 case 3 | |
134 bs = {'w', 'e', 's', 'n', 'd', 'u'}; | |
135 otherwise | |
136 error('not implemented'); | |
137 end | |
138 end | |
139 | |
140 % Return coordinates for the given boundary | |
141 function X = getBoundary(obj, name) | |
142 % In what dimension is the boundary? | |
143 switch name | |
144 case {'l', 'r', 'w', 'e'} | |
145 D = 1; | |
146 case {'s', 'n'} | |
147 D = 2; | |
148 case {'d', 'u'} | |
149 D = 3; | |
150 otherwise | |
151 error('not implemented'); | |
152 end | |
153 | |
154 % At what index is the boundary? | |
155 switch name | |
156 case {'l', 'w', 's', 'd'} | |
157 index = 1; | |
158 case {'r', 'e', 'n', 'u'} | |
159 index = obj.m(D); | |
160 otherwise | |
161 error('not implemented'); | |
162 end | |
163 | |
164 | |
165 | |
166 I = cell(1, obj.d); | |
167 for i = 1:obj.d | |
168 if i == D | |
169 I{i} = index; | |
170 else | |
171 I{i} = ':'; | |
172 end | |
173 end | |
174 | |
175 % Calculate size of result: | |
176 m = obj.m; | |
177 m(D) = []; | |
178 N = prod(m); | |
179 | |
180 X = zeros(N, obj.d); | |
181 | |
182 coordMat = obj.matrices(); | |
183 for i = 1:length(coordMat) | |
184 Xtemp = coordMat{i}(I{:}); | |
185 X(:,i) = reshapeRowMaj(Xtemp, [N,1]); | |
186 end | |
187 end | |
125 end | 188 end |
126 end | 189 end |