Mercurial > repos > public > sbplib
comparison +multiblock/+domain/Rectangle.m @ 1290:b0208b130880 feature/boundary_optimized_grids
Add option to pass a boundary optimized grid to Rectangle.getGrid
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Wed, 01 Jul 2020 17:34:40 +0200 |
parents | 4bb298faa8dc |
children | 2853b655c172 |
comparison
equal
deleted
inserted
replaced
1289:2fd2e2337b77 | 1290:b0208b130880 |
---|---|
115 | 115 |
116 | 116 |
117 % Returns a multiblock.Grid given some parameters | 117 % Returns a multiblock.Grid given some parameters |
118 % ms: cell array of [mx, my] vectors | 118 % ms: cell array of [mx, my] vectors |
119 % For same [mx, my] in every block, just input one vector. | 119 % For same [mx, my] in every block, just input one vector. |
120 % Currently defaults to equidistant grid if varargin is empty. | |
121 % If varargin is non-empty, the first argument should supply the grid, followed by | |
122 % additional arguments required to construct the grid. | |
123 % Grid types: | |
124 % 'equidist' - equidistant grid | |
125 % Additional argumets: none | |
126 % 'boundaryopt' - boundary optimized grid based on boundary | |
127 % optimized SBP operators | |
128 % Additional arguments: order, stencil option | |
129 % Example: g = getGrid() - the local blocks are 21x21 equidistant grids. | |
130 % g = getGrid(ms,) - block i is an equidistant grid with size given by ms{i}. | |
131 % g = getGrid(ms,'equidist') - block i is an equidistant grid with size given by ms{i}. | |
132 % g = getGrid(ms,'boundaryopt',4,'minimal') - block i is an cartesian grid with size given by ms{i} | |
133 % and nodes placed according to the boundary optimized minimal 4th order SBP operator. | |
120 function g = getGrid(obj, ms, varargin) | 134 function g = getGrid(obj, ms, varargin) |
121 | 135 |
122 default_arg('ms',[21,21]) | 136 default_arg('ms',[21,21]) |
123 | 137 |
124 % Extend ms if input is a single vector | 138 % Extend ms if input is a single vector |
127 ms = cell(1,obj.nBlocks); | 141 ms = cell(1,obj.nBlocks); |
128 for i = 1:obj.nBlocks | 142 for i = 1:obj.nBlocks |
129 ms{i} = m; | 143 ms{i} = m; |
130 end | 144 end |
131 end | 145 end |
132 | 146 if isempty(varargin) || strcmp(varargin{1},'equidist') |
147 gridgenerator = @(m,xlim,ylim)grid.equidistant(m,xlim,ylim); | |
148 elseif strcmp(varargin{1},'boundaryopt') | |
149 order = varargin{2}; | |
150 stenciloption = varargin{3}; | |
151 gridgenerator = @(m,xlim,ylim)grid.boundaryoptimized(m,xlim,ylim,... | |
152 order,stenciloption); | |
153 else | |
154 error('No grid type supplied!'); | |
155 end | |
133 grids = cell(1, obj.nBlocks); | 156 grids = cell(1, obj.nBlocks); |
134 for i = 1:obj.nBlocks | 157 for i = 1:obj.nBlocks |
135 grids{i} = grid.equidistant(ms{i}, obj.xlims{i}, obj.ylims{i}); | 158 grids{i} = gridgenerator(ms{i}, obj.xlims{i}, obj.ylims{i}); |
136 end | 159 end |
137 | 160 |
138 g = multiblock.Grid(grids, obj.connections, obj.boundaryGroups); | 161 g = multiblock.Grid(grids, obj.connections, obj.boundaryGroups); |
139 end | 162 end |
140 | 163 |