comparison +multiblock/DiffOp.m @ 907:c0652621bd69 feature/utux2D

Add new class multiblock.InterfaceOptions whose instances are passed to multiblock.DiffOp.
author Martin Almquist <malmquist@stanford.edu>
date Fri, 23 Nov 2018 20:12:54 -0800
parents 703183ed8c8b
children d232483eb72f
comparison
equal deleted inserted replaced
906:0499239496cf 907:c0652621bd69
8 8
9 blockmatrixDiv 9 blockmatrixDiv
10 end 10 end
11 11
12 methods 12 methods
13 function obj = DiffOp(doHand, grid, order, doParam, interfaceType) 13 function obj = DiffOp(doHand, grid, order, doParam, interfaceOptions)
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.
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 % 27 %
28 % interfaceType -- nBlocks x nBlocks cell array of types that specify 28 % interfaceOptions (optional) -- An instance of class multiblock.InterfaceOptions
29 % that particular block-coupling is handled. (Could 29 % OR
30 % be non-conforming interface, etc.) 30 % nBlocks x nBlocks cell array of opts for
31 % Default: empty cell array. 31 % every interface.
32 default_arg('doParam', []) 32 default_arg('doParam', [])
33 default_arg('interfaceOptions', multiblock.InterfaceOptions(grid) ); % Empty options
34 if isa(interfaceOptions, 'multiblock.InterfaceOptions');
35 interfaceOptions = interfaceOptions.getOptions;
36 end
33 37
34 [getHand, getParam] = parseInput(doHand, grid, doParam); 38 [getHand, getParam] = parseInput(doHand, grid, doParam);
35 39
40 obj.order = order;
36 nBlocks = grid.nBlocks(); 41 nBlocks = grid.nBlocks();
37 default_arg('interfaceType', cell(nBlocks, nBlocks));
38
39 obj.order = order;
40 42
41 % Create the diffOps for each block 43 % Create the diffOps for each block
42 obj.diffOps = cell(1, nBlocks); 44 obj.diffOps = cell(1, nBlocks);
43 for i = 1:nBlocks 45 for i = 1:nBlocks
44 h = getHand(i); 46 h = getHand(i);
70 intf = grid.connections{i,j}; 72 intf = grid.connections{i,j};
71 if isempty(intf) 73 if isempty(intf)
72 continue 74 continue
73 end 75 end
74 76
75 [ii, ij] = obj.diffOps{i}.interface(intf{1}, obj.diffOps{j}, intf{2}, interfaceType{i,j}); 77 intfOpts = interfaceOptions{i,j};
78
79 [ii, ij] = obj.diffOps{i}.interface(intf{1}, obj.diffOps{j}, intf{2}, intfOpts{1});
76 D{i,i} = D{i,i} + ii; 80 D{i,i} = D{i,i} + ii;
77 D{i,j} = D{i,j} + ij; 81 D{i,j} = D{i,j} + ij;
78 82
79 [jj, ji] = obj.diffOps{j}.interface(intf{2}, obj.diffOps{i}, intf{1}, interfaceType{j,i}); 83 [jj, ji] = obj.diffOps{j}.interface(intf{2}, obj.diffOps{i}, intf{1}, intfOpts{2});
80 D{j,j} = D{j,j} + jj; 84 D{j,j} = D{j,j} + jj;
81 D{j,i} = D{j,i} + ji; 85 D{j,i} = D{j,i} + ji;
82 end 86 end
83 end 87 end
84 obj.D = blockmatrix.toMatrix(D); 88 obj.D = blockmatrix.toMatrix(D);