Mercurial > repos > public > sbplib
comparison +multiblock/DiffOp.m @ 529:2ec8080027ab feature/boundaryGroup
Add some documentation and decide on public function signatures
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 03 Aug 2017 14:09:00 +0200 |
parents | 68178e013868 |
children | b29f04ab5d99 |
comparison
equal
deleted
inserted
replaced
528:6712655953d3 | 529:2ec8080027ab |
---|---|
118 % Splits a matrix operator into a cell-matrix of matrix operators for | 118 % Splits a matrix operator into a cell-matrix of matrix operators for |
119 % each grid. | 119 % each grid. |
120 ops = sparse2cell(op, obj.NNN); | 120 ops = sparse2cell(op, obj.NNN); |
121 end | 121 end |
122 | 122 |
123 % Get a boundary operator specified by op for the given boundary/BoundaryGroup | |
123 function op = getBoundaryOperator(obj, op, boundary) | 124 function op = getBoundaryOperator(obj, op, boundary) |
124 if iscell(boundary) | 125 switch class(boundary) |
125 localOpName = [op '_' boundary{2}]; | 126 case 'cell' |
126 blockId = boundary{1}; | 127 localOpName = [op '_' boundary{2}]; |
127 localOp = obj.diffOps{blockId}.(localOpName); | 128 blockId = boundary{1}; |
128 | 129 localOp = obj.diffOps{blockId}.(localOpName); |
129 div = {obj.blockmatrixDiv{1}, size(localOp,2)}; | 130 |
130 blockOp = blockmatrix.zero(div); | 131 div = {obj.blockmatrixDiv{1}, size(localOp,2)}; |
131 blockOp{blockId,1} = localOp; | 132 blockOp = blockmatrix.zero(div); |
132 op = blockmatrix.toMatrix(blockOp); | 133 blockOp{blockId,1} = localOp; |
133 return | 134 op = blockmatrix.toMatrix(blockOp); |
134 else | 135 return |
135 % Boundary är en sträng med en boundary group i. | 136 case 'multiblock.BoundaryGroup' |
137 error('not implemented') | |
138 otherwise | |
139 error('Unknown boundary indentifier') | |
136 end | 140 end |
137 end | 141 end |
138 | 142 |
139 % Creates the closure and penalty matrix for a given boundary condition, | 143 % Creates the closure and penalty matrix for a given boundary condition, |
140 % boundary -- the name of the boundary on the form {id,name} where | 144 % boundary -- the name of the boundary on the form {id,name} where |
141 % id is the number of a block and name is the name of a | 145 % id is the number of a block and name is the name of a |
142 % boundary of that block example: {1,'s'} or {3,'w'} | 146 % boundary of that block example: {1,'s'} or {3,'w'}. It |
147 % can also be a boundary group | |
143 function [closure, penalty] = boundary_condition(obj, boundary, type) | 148 function [closure, penalty] = boundary_condition(obj, boundary, type) |
144 I = boundary{1}; | 149 switch class(boundary) |
145 name = boundary{2}; | 150 case 'cell' |
146 | 151 I = boundary{1}; |
147 % Get the closure and penaly matrices | 152 name = boundary{2}; |
148 [blockClosure, blockPenalty] = obj.diffOps{I}.boundary_condition(name, type); | 153 |
149 | 154 % Get the closure and penaly matrices |
150 % Expand to matrix for full domain. | 155 [blockClosure, blockPenalty] = obj.diffOps{I}.boundary_condition(name, type); |
151 div = obj.blockmatrixDiv; | 156 |
152 if ~iscell(blockClosure) | 157 % Expand to matrix for full domain. |
153 temp = blockmatrix.zero(div); | 158 div = obj.blockmatrixDiv; |
154 temp{I,I} = blockClosure; | 159 if ~iscell(blockClosure) |
155 closure = blockmatrix.toMatrix(temp); | 160 temp = blockmatrix.zero(div); |
156 else | 161 temp{I,I} = blockClosure; |
157 for i = 1:length(blockClosure) | 162 closure = blockmatrix.toMatrix(temp); |
158 temp = blockmatrix.zero(div); | 163 else |
159 temp{I,I} = blockClosure{i}; | 164 for i = 1:length(blockClosure) |
160 closure{i} = blockmatrix.toMatrix(temp); | 165 temp = blockmatrix.zero(div); |
161 end | 166 temp{I,I} = blockClosure{i}; |
162 end | 167 closure{i} = blockmatrix.toMatrix(temp); |
163 | 168 end |
164 if ~iscell(blockPenalty) | 169 end |
165 div{2} = size(blockPenalty, 2); % Penalty is a column vector | 170 |
166 p = blockmatrix.zero(div); | 171 if ~iscell(blockPenalty) |
167 p{I} = blockPenalty; | 172 div{2} = size(blockPenalty, 2); % Penalty is a column vector |
168 penalty = blockmatrix.toMatrix(p); | 173 p = blockmatrix.zero(div); |
169 else | 174 p{I} = blockPenalty; |
170 for i = 1:length(blockPenalty) | 175 penalty = blockmatrix.toMatrix(p); |
171 div{2} = size(blockPenalty{i}, 2); % Penalty is a column vector | 176 else |
172 p = blockmatrix.zero(div); | 177 for i = 1:length(blockPenalty) |
173 p{I} = blockPenalty{i}; | 178 div{2} = size(blockPenalty{i}, 2); % Penalty is a column vector |
174 penalty{i} = blockmatrix.toMatrix(p); | 179 p = blockmatrix.zero(div); |
175 end | 180 p{I} = blockPenalty{i}; |
176 end | 181 penalty{i} = blockmatrix.toMatrix(p); |
182 end | |
183 end | |
184 case 'multiblock.BoundaryGroup' | |
185 error('not implemented') | |
186 otherwise | |
187 error('Unknown boundary indentifier') | |
188 end | |
189 | |
177 end | 190 end |
178 | 191 |
179 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary) | 192 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary) |
180 error('not implemented') | 193 error('not implemented') |
181 end | 194 end |