Mercurial > repos > public > sbplib
comparison +multiblock/BoundaryGroup.m @ 189:6054dcd3c8a9 feature/grids
Added a class for boundary groups. Added methods stubs and failing tests.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 04 Mar 2016 17:20:30 +0100 |
parents | |
children | 3cedd5a596bb |
comparison
equal
deleted
inserted
replaced
188:c5ca9bbfed41 | 189:6054dcd3c8a9 |
---|---|
1 % BoundaryGroup defines a boundary grouping in a multiblock grid. | |
2 classdef BoundaryGroup | |
3 properties | |
4 blockIDs | |
5 names | |
6 end | |
7 | |
8 methods | |
9 function obj = BoundaryGroup(varargin) | |
10 % Input arguemnts are arbitrary number or 1x2 cell arrays | |
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 obj.blockIDs(i) = varargin{i}{1}; | |
23 obj.names{i} = varargin{i}{2}; | |
24 end | |
25 end | |
26 | |
27 function display(obj, name) | |
28 | |
29 disp(' ') | |
30 disp([name, ' =']) | |
31 disp(' ') | |
32 | |
33 if length(obj.names) == 1 | |
34 fprintf(' {}\n\n') | |
35 return | |
36 end | |
37 | |
38 fprintf(' {') | |
39 | |
40 fprintf('%d:%s', obj.blockIDs(1), obj.names{1}) | |
41 for i = 2:length(obj.names) | |
42 fprintf(', %d:%s', obj.blockIDs(i), obj.names{i}); | |
43 end | |
44 | |
45 fprintf('}\n\n') | |
46 end | |
47 end | |
48 end |