Mercurial > repos > public > sbplib
comparison +multiblock/DiffOp.m @ 533:06d1606d6977 feature/boundaryGroup
Factor out function for handling a single boundary condition
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 03 Aug 2017 17:45:06 +0200 |
parents | b29f04ab5d99 |
children | 55a7777dfcd0 |
comparison
equal
deleted
inserted
replaced
532:b29f04ab5d99 | 533:06d1606d6977 |
---|---|
149 % boundary of that block example: {1,'s'} or {3,'w'}. It | 149 % boundary of that block example: {1,'s'} or {3,'w'}. It |
150 % can also be a boundary group | 150 % can also be a boundary group |
151 function [closure, penalty] = boundary_condition(obj, boundary, type) | 151 function [closure, penalty] = boundary_condition(obj, boundary, type) |
152 switch class(boundary) | 152 switch class(boundary) |
153 case 'cell' | 153 case 'cell' |
154 I = boundary{1}; | 154 [closure, penalty] = singleBoundaryCondition(obj, boundary, type); |
155 name = boundary{2}; | |
156 | |
157 % Get the closure and penaly matrices | |
158 [blockClosure, blockPenalty] = obj.diffOps{I}.boundary_condition(name, type); | |
159 | |
160 % Expand to matrix for full domain. | |
161 div = obj.blockmatrixDiv; | |
162 if ~iscell(blockClosure) | |
163 temp = blockmatrix.zero(div); | |
164 temp{I,I} = blockClosure; | |
165 closure = blockmatrix.toMatrix(temp); | |
166 else | |
167 for i = 1:length(blockClosure) | |
168 temp = blockmatrix.zero(div); | |
169 temp{I,I} = blockClosure{i}; | |
170 closure{i} = blockmatrix.toMatrix(temp); | |
171 end | |
172 end | |
173 | |
174 if ~iscell(blockPenalty) | |
175 div{2} = size(blockPenalty, 2); % Penalty is a column vector | |
176 p = blockmatrix.zero(div); | |
177 p{I} = blockPenalty; | |
178 penalty = blockmatrix.toMatrix(p); | |
179 else | |
180 for i = 1:length(blockPenalty) | |
181 div{2} = size(blockPenalty{i}, 2); % Penalty is a column vector | |
182 p = blockmatrix.zero(div); | |
183 p{I} = blockPenalty{i}; | |
184 penalty{i} = blockmatrix.toMatrix(p); | |
185 end | |
186 end | |
187 case 'multiblock.BoundaryGroup' | 155 case 'multiblock.BoundaryGroup' |
188 error('not implemented') | 156 error('not implemented') |
189 otherwise | 157 otherwise |
190 error('Unknown boundary indentifier') | 158 error('Unknown boundary indentifier') |
191 end | 159 end |
192 | 160 |
161 end | |
162 | |
163 function [closure, penalty] = singleBoundaryCondition(obj, boundary, type) | |
164 I = boundary{1}; | |
165 name = boundary{2}; | |
166 | |
167 % Get the closure and penaly matrices | |
168 [blockClosure, blockPenalty] = obj.diffOps{I}.boundary_condition(name, type); | |
169 | |
170 % Expand to matrix for full domain. | |
171 div = obj.blockmatrixDiv; | |
172 if ~iscell(blockClosure) | |
173 temp = blockmatrix.zero(div); | |
174 temp{I,I} = blockClosure; | |
175 closure = blockmatrix.toMatrix(temp); | |
176 else | |
177 for i = 1:length(blockClosure) | |
178 temp = blockmatrix.zero(div); | |
179 temp{I,I} = blockClosure{i}; | |
180 closure{i} = blockmatrix.toMatrix(temp); | |
181 end | |
182 end | |
183 | |
184 if ~iscell(blockPenalty) | |
185 div{2} = size(blockPenalty, 2); % Penalty is a column vector | |
186 p = blockmatrix.zero(div); | |
187 p{I} = blockPenalty; | |
188 penalty = blockmatrix.toMatrix(p); | |
189 else | |
190 for i = 1:length(blockPenalty) | |
191 div{2} = size(blockPenalty{i}, 2); % Penalty is a column vector | |
192 p = blockmatrix.zero(div); | |
193 p{I} = blockPenalty{i}; | |
194 penalty{i} = blockmatrix.toMatrix(p); | |
195 end | |
196 end | |
193 end | 197 end |
194 | 198 |
195 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary) | 199 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary) |
196 error('not implemented') | 200 error('not implemented') |
197 end | 201 end |