Mercurial > repos > public > sbplib
comparison +multiblock/DiffOp.m @ 210:39b7dcb2c724 feature/grids
multiblock: Implemented boundary conditions.
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Thu, 16 Jun 2016 09:21:17 +0200 |
| parents | e2fefb6f0746 |
| children | 8b10476b9bb7 |
comparison
equal
deleted
inserted
replaced
| 209:4fc2631477a3 | 210:39b7dcb2c724 |
|---|---|
| 3 grid | 3 grid |
| 4 order | 4 order |
| 5 diffOps | 5 diffOps |
| 6 D | 6 D |
| 7 H | 7 H |
| 8 | |
| 9 blockmatrixDiv | |
| 8 end | 10 end |
| 9 | 11 |
| 10 methods | 12 methods |
| 11 function obj = DiffOp(doHand, grid, order, doParam) | 13 function obj = DiffOp(doHand, grid, order, doParam) |
| 12 % 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 |
| 42 % Build the norm matrix | 44 % Build the norm matrix |
| 43 H = cell(nBlocks, nBlocks); | 45 H = cell(nBlocks, nBlocks); |
| 44 for i = 1:nBlocks | 46 for i = 1:nBlocks |
| 45 H{i,i} = obj.diffOps{i}.H; | 47 H{i,i} = obj.diffOps{i}.H; |
| 46 end | 48 end |
| 47 obj.H = cell2sparse(H); | 49 obj.H = blockmatrix.toMatrix(H); |
| 48 | 50 |
| 49 | 51 |
| 50 % Build the differentiation matrix | 52 % Build the differentiation matrix |
| 51 D = cell(nBlocks, nBlocks); | 53 D = cell(nBlocks, nBlocks); |
| 52 for i = 1:nBlocks | 54 for i = 1:nBlocks |
| 67 [jj, ji] = obj.diffOps{j}.interface(intf{2}, obj.diffOps{i}, intf{1}); | 69 [jj, ji] = obj.diffOps{j}.interface(intf{2}, obj.diffOps{i}, intf{1}); |
| 68 D{j,j} = D{j,j} + jj; | 70 D{j,j} = D{j,j} + jj; |
| 69 D{j,i} = D{j,i} + ji; | 71 D{j,i} = D{j,i} + ji; |
| 70 end | 72 end |
| 71 end | 73 end |
| 72 obj.D = cell2sparse(D); | 74 obj.D = blockmatrix.toMatrix(D); |
| 73 | 75 |
| 74 % end | 76 obj.blockmatrixDiv = blockmatrix.getDivision(D); |
| 75 | 77 |
| 76 function [getHand, getParam] = parseInput(doHand, grid, doParam) | 78 function [getHand, getParam] = parseInput(doHand, grid, doParam) |
| 77 if ~isa(grid, 'multiblock.Grid') | 79 if ~isa(grid, 'multiblock.Grid') |
| 78 error('multiblock:DiffOp:DiffOp:InvalidGrid', 'Requires a multiblock grid.'); | 80 error('multiblock:DiffOp:DiffOp:InvalidGrid', 'Requires a multiblock grid.'); |
| 79 end | 81 end |
| 108 % boundary of that block example: 1s or 3w | 110 % boundary of that block example: 1s or 3w |
| 109 function [closure, penalty] = boundary_condition(obj,boundary,type,data) | 111 function [closure, penalty] = boundary_condition(obj,boundary,type,data) |
| 110 I = boundary(1) | 112 I = boundary(1) |
| 111 name = boundary(2:end); | 113 name = boundary(2:end); |
| 112 | 114 |
| 113 [c, p] = obj.diffOps{I}.boundary_condition(name, type, data); | 115 % Get the closure and penaly matrices |
| 116 [blockClosure, blockPenalty] = obj.diffOps{I}.boundary_condition(name, type, data); | |
| 117 | |
| 118 % Expand to matrix for full domain. | |
| 119 div = obj.blockmatrixDiv; | |
| 120 closure = blockmatrix.zero(div); | |
| 121 closure{I,I} = blockClosure; | |
| 122 | |
| 123 div{2} = 1; % Penalty is a column vector | |
| 124 penalty = blockmatrix.zero(div); | |
| 125 penalty{I} = blockPenalty; | |
| 126 | |
| 127 % Convert to matrix | |
| 128 closure = blockmatrix.toMatrix(closure); | |
| 129 penalty = blockmatrix.toMatrix(closure); | |
| 114 end | 130 end |
| 115 | 131 |
| 116 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary) | 132 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary) |
| 117 | 133 |
| 118 end | 134 end |
