Mercurial > repos > public > sbplib
diff +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 |
line wrap: on
line diff
--- a/+grid/Curvilinear.m Mon Feb 29 15:40:34 2016 +0100 +++ b/+grid/Curvilinear.m Mon Jun 13 16:59:02 2016 +0200 @@ -80,6 +80,64 @@ end h = obj.logic.h; end + + % Return the names of all boundaries in this grid. + function bs = getBoundaryNames(obj) + bs = obj.logic.getBoundaryNames(); + end + + % Return coordinates for the given boundary + function X = getBoundary(obj, name) + % In what dimension is the boundary? + switch name + case {'l', 'r', 'w', 'e'} + D = 1; + case {'s', 'n'} + D = 2; + case {'d', 'u'} + D = 3; + otherwise + error('not implemented'); + end + + % At what index is the boundary? + switch name + case {'l', 'w', 's', 'd'} + index = 1; + case {'r', 'e', 'n', 'u'} + index = obj.logic.m(D); + otherwise + error('not implemented'); + end + + + + I = cell(1, obj.D); + for i = 1:obj.D + if i == D + I{i} = index; + else + I{i} = ':'; + end + end + + % Calculate size of result: + m = obj.logic.m; + m(D) = []; + N = prod(m); + + X = zeros(N, obj.D); + + p = obj.points; + for i = 1:obj.D() + coordMat{i} = reshapeRowMaj(p(:,i), obj.logic.m); + end + + for i = 1:length(coordMat) + Xtemp = coordMat{i}(I{:}); + X(:,i) = reshapeRowMaj(Xtemp, [N,1]); + end + end end end