comparison +multiblock/DiffOp.m @ 955:92c3c170e90b

Merged in feature/utux2D (pull request #11) Feature/utux2D Approved-by: Jonatan Werpers <jonatan.werpers@it.uu.se> Approved-by: Martin Almquist <malmquist@stanford.edu> Approved-by: Vidar Stiernström <vidar.stiernstrom@it.uu.se>
author Jonatan Werpers <jonatan.werpers@it.uu.se>
date Mon, 10 Dec 2018 08:29:41 +0000
parents 21394c78c72e
children a4ad90b37998 a3accd2f1283
comparison
equal deleted inserted replaced
951:a6c5e73ff44e 955:92c3c170e90b
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);