changeset 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 97b9a0023d38
children 42124009f940
files +multiblock/Def.m +multiblock/DefCurvilinear.m +multiblock/Definition.m
diffstat 3 files changed, 116 insertions(+), 101 deletions(-) [+]
line wrap: on
line diff
diff -r 97b9a0023d38 -r 25fdc7a625b6 +multiblock/Def.m
--- a/+multiblock/Def.m	Fri Sep 08 14:47:13 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-classdef Def
-    properties
-        nBlocks
-        blockMaps % Maps from logical blocks to physical blocks build from transfinite interpolation
-        blockNames
-        connections % Cell array specifying connections between blocks
-        boundaryGroups % Structure of boundaryGroups
-    end
-
-    methods
-        % Defines a multiblock setup for transfinite interpolation blocks
-        % TODO: How to bring in plotting of points?
-        function obj = Def(blockMaps, connections, boundaryGroups, blockNames)
-            default_arg('boundaryGroups', struct());
-            default_arg('blockNames',{});
-
-            nBlocks = length(blockMaps);
-
-            obj.nBlocks = nBlocks;
-
-            obj.blockMaps = blockMaps;
-
-            assert(all(size(connections) == [nBlocks, nBlocks]));
-            obj.connections = connections;
-
-
-            if isempty(blockNames)
-                obj.blockNames = cell(1, nBlocks);
-                for i = 1:length(blockMaps)
-                    obj.blockNames{i} = sprintf('%d', i);
-                end
-            else
-                assert(length(blockNames) == nBlocks);
-                obj.blockNames = blockNames;
-            end
-
-            obj.boundaryGroups = boundaryGroups;
-        end
-
-        function g = getGrid(obj, varargin)
-            ms = obj.getGridSizes(varargin{:});
-
-            grids = cell(1, obj.nBlocks);
-            for i = 1:obj.nBlocks
-                grids{i} = grid.equidistantCurvilinear(obj.blockMaps{i}.S, ms{i});
-            end
-
-            g = multiblock.Grid(grids, obj.connections, obj.boundaryGroups);
-        end
-
-        function show(obj, label, gridLines, varargin)
-            default_arg('label', 'name')
-            default_arg('gridLines', false);
-
-            if isempty('label') && ~gridLines
-                for i = 1:obj.nBlocks
-                    obj.blockMaps{i}.show(2,2);
-                end
-                axis equal
-                return
-            end
-
-            if gridLines
-                ms = obj.getGridSizes(varargin{:});
-                for i = 1:obj.nBlocks
-                    obj.blockMaps{i}.show(ms{i}(1),ms{i}(2));
-                end
-            end
-
-
-            switch label
-                case 'name'
-                    labels = obj.blockNames;
-                case 'id'
-                    labels = {};
-                    for i = 1:obj.nBlocks
-                        labels{i} = num2str(i);
-                    end
-                otherwise
-                    axis equal
-                    return
-            end
-
-            for i = 1:obj.nBlocks
-                parametrization.Ti.label(obj.blockMaps{i}, labels{i});
-            end
-
-            axis equal
-        end
-    end
-
-    methods (Abstract)
-        % Returns the grid size of each block in a cell array
-        % The input parameters are determined by the subclass
-        ms = getGridSizes(obj, varargin)
-        % end
-    end
-
-end
-
-
diff -r 97b9a0023d38 -r 25fdc7a625b6 +multiblock/DefCurvilinear.m
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/+multiblock/DefCurvilinear.m	Mon Sep 11 13:46:08 2017 +0200
@@ -0,0 +1,101 @@
+classdef DefCurvilinear < multiblock.Definition
+    properties
+        nBlocks
+        blockMaps % Maps from logical blocks to physical blocks build from transfinite interpolation
+        blockNames
+        connections % Cell array specifying connections between blocks
+        boundaryGroups % Structure of boundaryGroups
+    end
+
+    methods
+        % Defines a multiblock setup for transfinite interpolation blocks
+        % TODO: How to bring in plotting of points?
+        function obj = DefCurvilinear(blockMaps, connections, boundaryGroups, blockNames)
+            default_arg('boundaryGroups', struct());
+            default_arg('blockNames',{});
+
+            nBlocks = length(blockMaps);
+
+            obj.nBlocks = nBlocks;
+
+            obj.blockMaps = blockMaps;
+
+            assert(all(size(connections) == [nBlocks, nBlocks]));
+            obj.connections = connections;
+
+
+            if isempty(blockNames)
+                obj.blockNames = cell(1, nBlocks);
+                for i = 1:length(blockMaps)
+                    obj.blockNames{i} = sprintf('%d', i);
+                end
+            else
+                assert(length(blockNames) == nBlocks);
+                obj.blockNames = blockNames;
+            end
+
+            obj.boundaryGroups = boundaryGroups;
+        end
+
+        function g = getGrid(obj, varargin)
+            ms = obj.getGridSizes(varargin{:});
+
+            grids = cell(1, obj.nBlocks);
+            for i = 1:obj.nBlocks
+                grids{i} = grid.equidistantCurvilinear(obj.blockMaps{i}.S, ms{i});
+            end
+
+            g = multiblock.Grid(grids, obj.connections, obj.boundaryGroups);
+        end
+
+        function show(obj, label, gridLines, varargin)
+            default_arg('label', 'name')
+            default_arg('gridLines', false);
+
+            if isempty('label') && ~gridLines
+                for i = 1:obj.nBlocks
+                    obj.blockMaps{i}.show(2,2);
+                end
+                axis equal
+                return
+            end
+
+            if gridLines
+                ms = obj.getGridSizes(varargin{:});
+                for i = 1:obj.nBlocks
+                    obj.blockMaps{i}.show(ms{i}(1),ms{i}(2));
+                end
+            end
+
+
+            switch label
+                case 'name'
+                    labels = obj.blockNames;
+                case 'id'
+                    labels = {};
+                    for i = 1:obj.nBlocks
+                        labels{i} = num2str(i);
+                    end
+                otherwise
+                    axis equal
+                    return
+            end
+
+            for i = 1:obj.nBlocks
+                parametrization.Ti.label(obj.blockMaps{i}, labels{i});
+            end
+
+            axis equal
+        end
+    end
+
+    methods (Abstract)
+        % Returns the grid size of each block in a cell array
+        % The input parameters are determined by the subclass
+        ms = getGridSizes(obj, varargin)
+        % end
+    end
+
+end
+
+
diff -r 97b9a0023d38 -r 25fdc7a625b6 +multiblock/Definition.m
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/+multiblock/Definition.m	Mon Sep 11 13:46:08 2017 +0200
@@ -0,0 +1,15 @@
+classdef Definition
+    methods (Abstract)
+
+        % Returns a multiblock.Grid given some parameters
+        g = getGrid(obj, varargin)
+
+        % label is the type of label used for plotting,
+        % default is block name, 'id' show the index for each block.
+        show(obj, label, gridLines, varargin)
+
+        % Returns the grid size of each block in a cell array
+        % The input parameters are determined by the subclass
+        ms = getGridSizes(obj, varargin)
+    end
+end