comparison +grid/Curvilinear.m @ 191:7c1d3fc33f90 feature/grids

Added methods for returning boundary names and boundary coordinates from Cartesian and Curvilinear grids.
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 04 Apr 2016 18:23:50 +0200
parents c5ca9bbfed41
children 30321dc180e1
comparison
equal deleted inserted replaced
190:2c2ba1f3bbe3 191:7c1d3fc33f90
81 h = obj.logic.h; 81 h = obj.logic.h;
82 end 82 end
83 83
84 % Return the names of all boundaries in this grid. 84 % Return the names of all boundaries in this grid.
85 function bs = getBoundaryNames(obj) 85 function bs = getBoundaryNames(obj)
86 bs = []; 86 bs = obj.logic.getBoundaryNames();
87 end 87 end
88 88
89 % Return coordinates for the given boundary 89 % Return coordinates for the given boundary
90 function b = getBoundary(obj, name) 90 function X = getBoundary(obj, name)
91 b = []; 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
92 end 140 end
93 end 141 end
94 end 142 end
95 143
96 144