Mercurial > repos > public > sbplib
comparison +multiblock/DiffOp.m @ 1033:037f203b9bf5 feature/burgers1d
Merge with branch feature/advectioRV to utilize the +rv package
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 17 Jan 2019 10:44:12 +0100 |
parents | 21394c78c72e |
children | a4ad90b37998 a3accd2f1283 |
comparison
equal
deleted
inserted
replaced
854:18162a0a5bb5 | 1033:037f203b9bf5 |
---|---|
8 | 8 |
9 blockmatrixDiv | 9 blockmatrixDiv |
10 end | 10 end |
11 | 11 |
12 methods | 12 methods |
13 function obj = DiffOp(doHand, g, order, doParam) | 13 function obj = DiffOp(doHand, g, order, doParam, intfTypes) |
14 % doHand -- may either be a function handle or a cell array of | 14 % doHand -- may either be a function handle or a cell array of |
15 % function handles for each grid. The function handle(s) | 15 % function handles for each grid. The function handle(s) |
16 % should be on the form do = doHand(grid, order, ...) | 16 % should be on the form do = doHand(grid, order, ...) |
17 % Additional parameters for each doHand may be provided in | 17 % Additional parameters for each doHand may be provided in |
18 % the doParam input. | 18 % the doParam input. |
22 % for each block. If it is a cell array with length equal | 22 % for each block. If it is a cell array with length equal |
23 % to the number of blocks then each element is sent to the | 23 % to the number of blocks then each element is sent to the |
24 % corresponding function handle as extra parameters: | 24 % corresponding function handle as extra parameters: |
25 % doHand(..., doParam{i}{:}) Otherwise doParam is sent as | 25 % doHand(..., doParam{i}{:}) Otherwise doParam is sent as |
26 % extra parameters to all doHand: doHand(..., doParam{:}) | 26 % extra parameters to all doHand: doHand(..., doParam{:}) |
27 % | |
28 % intfTypes (optional) -- nBlocks x nBlocks cell array of types for | |
29 % every interface. | |
27 default_arg('doParam', []) | 30 default_arg('doParam', []) |
31 default_arg('intfTypes', cell(g.nBlocks(), g.nBlocks()) ); | |
28 | 32 |
29 [getHand, getParam] = parseInput(doHand, g, doParam); | 33 [getHand, getParam] = parseInput(doHand, g, doParam); |
30 | 34 |
35 obj.order = order; | |
31 nBlocks = g.nBlocks(); | 36 nBlocks = g.nBlocks(); |
32 | |
33 obj.order = order; | |
34 | 37 |
35 % Create the diffOps for each block | 38 % Create the diffOps for each block |
36 obj.diffOps = cell(1, nBlocks); | 39 obj.diffOps = cell(1, nBlocks); |
37 for i = 1:nBlocks | 40 for i = 1:nBlocks |
38 h = getHand(i); | 41 h = getHand(i); |
68 intf = g.connections{i,j}; | 71 intf = g.connections{i,j}; |
69 if isempty(intf) | 72 if isempty(intf) |
70 continue | 73 continue |
71 end | 74 end |
72 | 75 |
73 | 76 [ii, ij] = obj.diffOps{i}.interface(intf{1}, obj.diffOps{j}, intf{2}, intfTypes{i,j}); |
74 [ii, ij] = obj.diffOps{i}.interface(intf{1}, obj.diffOps{j}, intf{2}); | |
75 D{i,i} = D{i,i} + ii; | 77 D{i,i} = D{i,i} + ii; |
76 D{i,j} = D{i,j} + ij; | 78 D{i,j} = D{i,j} + ij; |
77 | 79 |
78 [jj, ji] = obj.diffOps{j}.interface(intf{2}, obj.diffOps{i}, intf{1}); | 80 [jj, ji] = obj.diffOps{j}.interface(intf{2}, obj.diffOps{i}, intf{1}, intfTypes{i,j}); |
79 D{j,j} = D{j,j} + jj; | 81 D{j,j} = D{j,j} + jj; |
80 D{j,i} = D{j,i} + ji; | 82 D{j,i} = D{j,i} + ji; |
81 end | 83 end |
82 end | 84 end |
83 obj.D = blockmatrix.toMatrix(D); | 85 obj.D = blockmatrix.toMatrix(D); |
199 | 201 |
200 % Get the closure and penaly matrices | 202 % Get the closure and penaly matrices |
201 [blockClosure, blockPenalty] = obj.diffOps{I}.boundary_condition(name, type); | 203 [blockClosure, blockPenalty] = obj.diffOps{I}.boundary_condition(name, type); |
202 | 204 |
203 % Expand to matrix for full domain. | 205 % Expand to matrix for full domain. |
204 div = obj.blockmatrixDiv; | 206 closure = multiblock.local2globalClosure(blockClosure, obj.blockmatrixDiv, I); |
205 if ~iscell(blockClosure) | 207 penalty = multiblock.local2globalPenalty(blockPenalty, obj.blockmatrixDiv, I); |
206 temp = blockmatrix.zero(div); | |
207 temp{I,I} = blockClosure; | |
208 closure = blockmatrix.toMatrix(temp); | |
209 else | |
210 for i = 1:length(blockClosure) | |
211 temp = blockmatrix.zero(div); | |
212 temp{I,I} = blockClosure{i}; | |
213 closure{i} = blockmatrix.toMatrix(temp); | |
214 end | |
215 end | |
216 | |
217 if ~iscell(blockPenalty) | |
218 div{2} = size(blockPenalty, 2); % Penalty is a column vector | |
219 p = blockmatrix.zero(div); | |
220 p{I} = blockPenalty; | |
221 penalty = blockmatrix.toMatrix(p); | |
222 else | |
223 % TODO: used by beam equation, should be eliminated. SHould only set one BC per call | |
224 for i = 1:length(blockPenalty) | |
225 div{2} = size(blockPenalty{i}, 2); % Penalty is a column vector | |
226 p = blockmatrix.zero(div); | |
227 p{I} = blockPenalty{i}; | |
228 penalty{i} = blockmatrix.toMatrix(p); | |
229 end | |
230 end | |
231 end | 208 end |
232 | 209 |
233 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary) | 210 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary) |
234 error('not implemented') | 211 error('not implemented') |
235 end | 212 end |