Mercurial > repos > public > sbplib
changeset 529:2ec8080027ab feature/boundaryGroup
Add some documentation and decide on public function signatures
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 03 Aug 2017 14:09:00 +0200 |
parents | 6712655953d3 |
children | 0cd7b8128e04 |
files | +multiblock/DiffOp.m +multiblock/Grid.m |
diffstat | 2 files changed, 72 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
diff -r 6712655953d3 -r 2ec8080027ab +multiblock/DiffOp.m --- a/+multiblock/DiffOp.m Thu Aug 03 14:07:56 2017 +0200 +++ b/+multiblock/DiffOp.m Thu Aug 03 14:09:00 2017 +0200 @@ -120,60 +120,73 @@ ops = sparse2cell(op, obj.NNN); end + % Get a boundary operator specified by op for the given boundary/BoundaryGroup function op = getBoundaryOperator(obj, op, boundary) - if iscell(boundary) - localOpName = [op '_' boundary{2}]; - blockId = boundary{1}; - localOp = obj.diffOps{blockId}.(localOpName); + switch class(boundary) + case 'cell' + localOpName = [op '_' boundary{2}]; + blockId = boundary{1}; + localOp = obj.diffOps{blockId}.(localOpName); - div = {obj.blockmatrixDiv{1}, size(localOp,2)}; - blockOp = blockmatrix.zero(div); - blockOp{blockId,1} = localOp; - op = blockmatrix.toMatrix(blockOp); - return - else - % Boundary är en sträng med en boundary group i. + div = {obj.blockmatrixDiv{1}, size(localOp,2)}; + blockOp = blockmatrix.zero(div); + blockOp{blockId,1} = localOp; + op = blockmatrix.toMatrix(blockOp); + return + case 'multiblock.BoundaryGroup' + error('not implemented') + otherwise + error('Unknown boundary indentifier') end end % Creates the closure and penalty matrix for a given boundary condition, % boundary -- the name of the boundary on the form {id,name} where % id is the number of a block and name is the name of a - % boundary of that block example: {1,'s'} or {3,'w'} + % boundary of that block example: {1,'s'} or {3,'w'}. It + % can also be a boundary group function [closure, penalty] = boundary_condition(obj, boundary, type) - I = boundary{1}; - name = boundary{2}; + switch class(boundary) + case 'cell' + I = boundary{1}; + name = boundary{2}; - % Get the closure and penaly matrices - [blockClosure, blockPenalty] = obj.diffOps{I}.boundary_condition(name, type); + % Get the closure and penaly matrices + [blockClosure, blockPenalty] = obj.diffOps{I}.boundary_condition(name, type); - % Expand to matrix for full domain. - div = obj.blockmatrixDiv; - if ~iscell(blockClosure) - temp = blockmatrix.zero(div); - temp{I,I} = blockClosure; - closure = blockmatrix.toMatrix(temp); - else - for i = 1:length(blockClosure) - temp = blockmatrix.zero(div); - temp{I,I} = blockClosure{i}; - closure{i} = blockmatrix.toMatrix(temp); - end + % Expand to matrix for full domain. + div = obj.blockmatrixDiv; + if ~iscell(blockClosure) + temp = blockmatrix.zero(div); + temp{I,I} = blockClosure; + closure = blockmatrix.toMatrix(temp); + else + for i = 1:length(blockClosure) + temp = blockmatrix.zero(div); + temp{I,I} = blockClosure{i}; + closure{i} = blockmatrix.toMatrix(temp); + end + end + + if ~iscell(blockPenalty) + div{2} = size(blockPenalty, 2); % Penalty is a column vector + p = blockmatrix.zero(div); + p{I} = blockPenalty; + penalty = blockmatrix.toMatrix(p); + else + for i = 1:length(blockPenalty) + div{2} = size(blockPenalty{i}, 2); % Penalty is a column vector + p = blockmatrix.zero(div); + p{I} = blockPenalty{i}; + penalty{i} = blockmatrix.toMatrix(p); + end + end + case 'multiblock.BoundaryGroup' + error('not implemented') + otherwise + error('Unknown boundary indentifier') end - if ~iscell(blockPenalty) - div{2} = size(blockPenalty, 2); % Penalty is a column vector - p = blockmatrix.zero(div); - p{I} = blockPenalty; - penalty = blockmatrix.toMatrix(p); - else - for i = 1:length(blockPenalty) - div{2} = size(blockPenalty{i}, 2); % Penalty is a column vector - p = blockmatrix.zero(div); - p{I} = blockPenalty{i}; - penalty{i} = blockmatrix.toMatrix(p); - end - end end function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary)
diff -r 6712655953d3 -r 2ec8080027ab +multiblock/Grid.m --- a/+multiblock/Grid.m Thu Aug 03 14:07:56 2017 +0200 +++ b/+multiblock/Grid.m Thu Aug 03 14:09:00 2017 +0200 @@ -9,16 +9,19 @@ % General multiblock grid methods - - % grids -- cell array of N grids - % connections -- NxN upper triangular cell matrix. connections{i,j} - % specifies the connection between block i and j. If - % it's empty there is no connection otherwise it's a 2 - % -cell-vector with strings naming the boundaries to be - % connected. (inverted coupling?) - %% Should we have boundary groups at all? maybe it can be handled in a - %% cleaner way outside of the class. Maybe the grid class doesn't need to care at all. All boundaryGroup interaction is in DiffOp? + % grids -- cell array of N grids + % connections -- NxN upper triangular cell matrix. connections{i,j} + % specifies the connection between block i and j. If + % it's empty there is no connection otherwise it's a 2 + % -cell-vector with strings naming the boundaries to be + % connected. (inverted coupling?) + % boundaryGroups -- A struct of BoundaryGroups. The field names of the + % struct are the names of each boundary group. + % The boundary groups can be used to collect block + % boundaries into physical boundaries to simplify + % getting boundary operators and setting boundary conditions function obj = Grid(grids, connections, boundaryGroups) + default_arg('boundaryGroups', struct()); obj.grids = grids; obj.connections = connections; @@ -27,7 +30,7 @@ obj.nPoints = obj.nPoints + grids{i}.N(); end - % if iscell(boundaryGroups) + obj.boundaryGroups = boundaryGroups; end function n = size(obj) @@ -121,13 +124,15 @@ end + % Find all non interface boundaries of all blocks. + % Return their grid.boundaryIdentifiers in a cell array. function bs = getBoundaryNames(obj) - bs = []; + error('not implemented'); end - % Return coordinates for the given boundary + % Return coordinates for the given boundary/boundaryGroup function b = getBoundary(obj, name) - b = []; + error('not implemented'); end end end