Mercurial > repos > public > sbplib
comparison +multiblock/DefCurvilinear.m @ 587:25fdc7a625b6 feature/better_multiblock_defs
Add abstract class for multiblock definitions
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 11 Sep 2017 13:46:08 +0200 |
parents | +multiblock/Def.m@9924f1f8c906 |
children | e7a6744499fa |
comparison
equal
deleted
inserted
replaced
586:97b9a0023d38 | 587:25fdc7a625b6 |
---|---|
1 classdef DefCurvilinear < multiblock.Definition | |
2 properties | |
3 nBlocks | |
4 blockMaps % Maps from logical blocks to physical blocks build from transfinite interpolation | |
5 blockNames | |
6 connections % Cell array specifying connections between blocks | |
7 boundaryGroups % Structure of boundaryGroups | |
8 end | |
9 | |
10 methods | |
11 % Defines a multiblock setup for transfinite interpolation blocks | |
12 % TODO: How to bring in plotting of points? | |
13 function obj = DefCurvilinear(blockMaps, connections, boundaryGroups, blockNames) | |
14 default_arg('boundaryGroups', struct()); | |
15 default_arg('blockNames',{}); | |
16 | |
17 nBlocks = length(blockMaps); | |
18 | |
19 obj.nBlocks = nBlocks; | |
20 | |
21 obj.blockMaps = blockMaps; | |
22 | |
23 assert(all(size(connections) == [nBlocks, nBlocks])); | |
24 obj.connections = connections; | |
25 | |
26 | |
27 if isempty(blockNames) | |
28 obj.blockNames = cell(1, nBlocks); | |
29 for i = 1:length(blockMaps) | |
30 obj.blockNames{i} = sprintf('%d', i); | |
31 end | |
32 else | |
33 assert(length(blockNames) == nBlocks); | |
34 obj.blockNames = blockNames; | |
35 end | |
36 | |
37 obj.boundaryGroups = boundaryGroups; | |
38 end | |
39 | |
40 function g = getGrid(obj, varargin) | |
41 ms = obj.getGridSizes(varargin{:}); | |
42 | |
43 grids = cell(1, obj.nBlocks); | |
44 for i = 1:obj.nBlocks | |
45 grids{i} = grid.equidistantCurvilinear(obj.blockMaps{i}.S, ms{i}); | |
46 end | |
47 | |
48 g = multiblock.Grid(grids, obj.connections, obj.boundaryGroups); | |
49 end | |
50 | |
51 function show(obj, label, gridLines, varargin) | |
52 default_arg('label', 'name') | |
53 default_arg('gridLines', false); | |
54 | |
55 if isempty('label') && ~gridLines | |
56 for i = 1:obj.nBlocks | |
57 obj.blockMaps{i}.show(2,2); | |
58 end | |
59 axis equal | |
60 return | |
61 end | |
62 | |
63 if gridLines | |
64 ms = obj.getGridSizes(varargin{:}); | |
65 for i = 1:obj.nBlocks | |
66 obj.blockMaps{i}.show(ms{i}(1),ms{i}(2)); | |
67 end | |
68 end | |
69 | |
70 | |
71 switch label | |
72 case 'name' | |
73 labels = obj.blockNames; | |
74 case 'id' | |
75 labels = {}; | |
76 for i = 1:obj.nBlocks | |
77 labels{i} = num2str(i); | |
78 end | |
79 otherwise | |
80 axis equal | |
81 return | |
82 end | |
83 | |
84 for i = 1:obj.nBlocks | |
85 parametrization.Ti.label(obj.blockMaps{i}, labels{i}); | |
86 end | |
87 | |
88 axis equal | |
89 end | |
90 end | |
91 | |
92 methods (Abstract) | |
93 % Returns the grid size of each block in a cell array | |
94 % The input parameters are determined by the subclass | |
95 ms = getGridSizes(obj, varargin) | |
96 % end | |
97 end | |
98 | |
99 end | |
100 | |
101 |