comparison +multiblock/DiffOp.m @ 968:a4ad90b37998 feature/poroelastic

Merge with default.
author Martin Almquist <malmquist@stanford.edu>
date Sun, 23 Dec 2018 14:39:31 +0100
parents 99c2ef883dc6 21394c78c72e
children adae8063ea2f
comparison
equal deleted inserted replaced
967:368a2773f78b 968:a4ad90b37998
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);
267 269
268 % Get the closure and penaly matrices 270 % Get the closure and penaly matrices
269 [blockClosure, blockPenalty] = obj.diffOps{I}.boundary_condition(name, type); 271 [blockClosure, blockPenalty] = obj.diffOps{I}.boundary_condition(name, type);
270 272
271 % Expand to matrix for full domain. 273 % Expand to matrix for full domain.
272 div = obj.blockmatrixDiv; 274 closure = multiblock.local2globalClosure(blockClosure, obj.blockmatrixDiv, I);
273 if ~iscell(blockClosure) 275 penalty = multiblock.local2globalPenalty(blockPenalty, obj.blockmatrixDiv, I);
274 temp = blockmatrix.zero(div);
275 temp{I,I} = blockClosure;
276 closure = blockmatrix.toMatrix(temp);
277 else
278 for i = 1:length(blockClosure)
279 temp = blockmatrix.zero(div);
280 temp{I,I} = blockClosure{i};
281 closure{i} = blockmatrix.toMatrix(temp);
282 end
283 end
284
285 if ~iscell(blockPenalty)
286 div{2} = size(blockPenalty, 2); % Penalty is a column vector
287 p = blockmatrix.zero(div);
288 p{I} = blockPenalty;
289 penalty = blockmatrix.toMatrix(p);
290 else
291 % TODO: used by beam equation, should be eliminated. SHould only set one BC per call
292 for i = 1:length(blockPenalty)
293 div{2} = size(blockPenalty{i}, 2); % Penalty is a column vector
294 p = blockmatrix.zero(div);
295 p{I} = blockPenalty{i};
296 penalty{i} = blockmatrix.toMatrix(p);
297 end
298 end
299 end 276 end
300 277
301 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary) 278 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary)
302 error('not implemented') 279 error('not implemented')
303 end 280 end