comparison +multiblock/BoundaryGroup.m @ 704:111fcbcff2e9 feature/optim

merg with featuew grids
author Ylva Rydin <ylva.rydin@telia.com>
date Fri, 03 Nov 2017 10:53:15 +0100
parents 6712655953d3
children
comparison
equal deleted inserted replaced
703:027f606fa691 704:111fcbcff2e9
1 % BoundaryGroup defines a boundary grouping in a multiblock grid. 1 % BoundaryGroup defines a boundary grouping in a multiblock grid.
2 classdef BoundaryGroup 2 % It workds like a cell array and collects boundary identifiers
3 properties 3 % Within the multiblock package a BoundaryGroup is a valid boundary identifier as well.
4 blockIDs 4 classdef BoundaryGroup < Cell
5 names
6 end
7
8 methods 5 methods
9 function obj = BoundaryGroup(varargin) 6 function obj = BoundaryGroup(data)
10 % Input arguemnts are arbitrary number or 1x2 cell arrays 7 obj = obj@Cell(data);
11 % representing each boundary in the group.
12 % The 1st element of the cell array is an integer defining which grid it belongs to.
13 % The 2nd element of the cell array is the name of the boundary within the block.
14 %
15 % Ex:
16 % bg = multiblock.BoundaryGroup({1,'n'},{1,'s'},{2,'s'})
17
18
19 obj.blockIDs = [];
20 obj.names = {};
21 for i = 1:length(varargin)
22 if ~iscell(varargin{i}) || ~all(size(varargin{i}) == [1 2])
23 error('multiblock:BoundaryGroup:BoundaryGroup:InvalidInput', 'Inputs must be 1x2 cell arrays');
24 end
25 obj.blockIDs(i) = varargin{i}{1};
26 obj.names{i} = varargin{i}{2};
27 end
28 end 8 end
29 9
30 function display(obj, name) 10 function display(obj, name)
31 11
32 disp(' ') 12 disp(' ')
33 disp([name, ' =']) 13 disp([name, ' ='])
34 disp(' ') 14 disp(' ')
35 15
36 if length(obj.names) == 1 16 fprintf(' BoundaryGroup%s\n\n', toString(obj.data));
37 fprintf(' {}\n\n')
38 return
39 end
40
41 fprintf(' {')
42
43 fprintf('%d:%s', obj.blockIDs(1), obj.names{1})
44 for i = 2:length(obj.names)
45 fprintf(', %d:%s', obj.blockIDs(i), obj.names{i});
46 end
47
48 fprintf('}\n\n')
49 end 17 end
50 end 18 end
51 end 19 end