Mercurial > repos > public > sbplib
comparison +multiblock/+domain/Rectangle.m @ 1300:196123459178
Merge in feature/boundary_optimized_grids
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Wed, 08 Jul 2020 18:22:54 +0200 |
parents | e53b1e25970a |
children | ee3d694f2340 |
comparison
equal
deleted
inserted
replaced
1250:8ec777fb473e | 1300:196123459178 |
---|---|
91 for j = 1:nx | 91 for j = 1:nx |
92 S_id = flat_index(m,j,ny); | 92 S_id = flat_index(m,j,ny); |
93 N_id = flat_index(m,j,1); | 93 N_id = flat_index(m,j,1); |
94 S{j} = {S_id,'s'}; | 94 S{j} = {S_id,'s'}; |
95 N{j} = {N_id,'n'}; | 95 N{j} = {N_id,'n'}; |
96 end | 96 end |
97 boundaryGroups.E = multiblock.BoundaryGroup(E); | 97 boundaryGroups.E = multiblock.BoundaryGroup(E); |
98 boundaryGroups.W = multiblock.BoundaryGroup(W); | 98 boundaryGroups.W = multiblock.BoundaryGroup(W); |
99 boundaryGroups.S = multiblock.BoundaryGroup(S); | 99 boundaryGroups.S = multiblock.BoundaryGroup(S); |
100 boundaryGroups.N = multiblock.BoundaryGroup(N); | 100 boundaryGroups.N = multiblock.BoundaryGroup(N); |
101 boundaryGroups.all = multiblock.BoundaryGroup([E,W,S,N]); | 101 boundaryGroups.all = multiblock.BoundaryGroup([E,W,S,N]); |
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 type, 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 a 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 |