Mercurial > repos > public > sbplib
comparison +multiblock/BoundaryGroup.m @ 526:d8833f0a9f1a feature/boundaryGroup
Change the BoundaryGroup class into a simpler cellarray style
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 03 Aug 2017 09:55:59 +0200 |
parents | 3cedd5a596bb |
children | 6712655953d3 |
comparison
equal
deleted
inserted
replaced
525:3011f9a28ac8 | 526:d8833f0a9f1a |
---|---|
1 % BoundaryGroup defines a boundary grouping in a multiblock grid. | 1 % BoundaryGroup defines a boundary grouping in a multiblock grid. |
2 classdef BoundaryGroup | 2 classdef BoundaryGroup < Cell |
3 properties | |
4 blockIDs | |
5 names | |
6 end | |
7 | |
8 methods | 3 methods |
9 function obj = BoundaryGroup(varargin) | 4 function obj = BoundaryGroup(data) |
10 % Input arguemnts are arbitrary number or 1x2 cell arrays | 5 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 | 6 end |
29 | 7 |
30 function display(obj, name) | 8 % function display(obj, name) |
31 | 9 |
32 disp(' ') | 10 % disp(' ') |
33 disp([name, ' =']) | 11 % disp([name, ' =']) |
34 disp(' ') | 12 % disp(' ') |
35 | 13 |
36 if length(obj.names) == 1 | 14 % if length(obj.names) == 1 |
37 fprintf(' {}\n\n') | 15 % fprintf(' {}\n\n') |
38 return | 16 % return |
39 end | 17 % end |
40 | 18 |
41 fprintf(' {') | 19 % fprintf(' {') |
42 | 20 |
43 fprintf('%d:%s', obj.blockIDs(1), obj.names{1}) | 21 % fprintf('%d:%s', obj.blockIDs(1), obj.names{1}) |
44 for i = 2:length(obj.names) | 22 % for i = 2:length(obj.names) |
45 fprintf(', %d:%s', obj.blockIDs(i), obj.names{i}); | 23 % fprintf(', %d:%s', obj.blockIDs(i), obj.names{i}); |
46 end | 24 % end |
47 | 25 |
48 fprintf('}\n\n') | 26 % fprintf('}\n\n') |
49 end | 27 % end |
50 end | 28 end |
51 end | 29 end |