Mercurial > repos > public > sbplib
comparison +multiblock/DefCurvilinear.m @ 780:e7a6744499fa feature/grids
Merge with feature/better_multiblock_defs
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 24 Jul 2018 20:01:29 -0700 |
parents | +multiblock/Def.m@edb1d60b0b77 +multiblock/Def.m@25fdc7a625b6 |
children | 8aa0909125a4 7df63b17e078 |
comparison
equal
deleted
inserted
replaced
778:b9d2c76a4a07 | 780:e7a6744499fa |
---|---|
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 h = show(obj, label, gridLines, varargin) | |
52 default_arg('label', 'name') | |
53 default_arg('gridLines', false); | |
54 | |
55 h = []; | |
56 if isempty('label') && ~gridLines | |
57 for i = 1:obj.nBlocks | |
58 h = [h, obj.blockMaps{i}.show(2,2)]; | |
59 end | |
60 axis equal | |
61 return | |
62 end | |
63 | |
64 if gridLines | |
65 ms = obj.getGridSizes(varargin{:}); | |
66 for i = 1:obj.nBlocks | |
67 h = [h, obj.blockMaps{i}.show(ms{i}(1),ms{i}(2))]; | |
68 end | |
69 end | |
70 | |
71 | |
72 switch label | |
73 case 'name' | |
74 labels = obj.blockNames; | |
75 case 'id' | |
76 labels = {}; | |
77 for i = 1:obj.nBlocks | |
78 labels{i} = num2str(i); | |
79 end | |
80 case 'none' | |
81 axis equal | |
82 return | |
83 end | |
84 | |
85 for i = 1:obj.nBlocks | |
86 parametrization.Ti.label(obj.blockMaps{i}, labels{i}); | |
87 end | |
88 | |
89 axis equal | |
90 end | |
91 end | |
92 | |
93 methods (Abstract) | |
94 % Returns the grid size of each block in a cell array | |
95 % The input parameters are determined by the subclass | |
96 ms = getGridSizes(obj, varargin) | |
97 % end | |
98 end | |
99 | |
100 end | |
101 | |
102 |