annotate +sbp/+grid/minimalBoundaryOptimizedGrid.m @ 1298:0ffb5bfa65e4 feature/boundary_optimized_grids

Improve comments
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Tue, 07 Jul 2020 16:23:44 +0200
parents e53b1e25970a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1298
0ffb5bfa65e4 Improve comments
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1297
diff changeset
1 % Computes the grid points x and grid spacing h used by the boundary optimized SBP operators
0ffb5bfa65e4 Improve comments
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1297
diff changeset
2 % with minimal number of non-equidistant boundary points, presented in
0ffb5bfa65e4 Improve comments
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1297
diff changeset
3 % 'Boundary optimized diagonal-norm SBP operators - Mattsson, Almquist, van der Weide 2018'.
0ffb5bfa65e4 Improve comments
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1297
diff changeset
4 %
0ffb5bfa65e4 Improve comments
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1297
diff changeset
5 % lim - cell array with domain limits
0ffb5bfa65e4 Improve comments
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1297
diff changeset
6 % N - Number of grid points
0ffb5bfa65e4 Improve comments
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1297
diff changeset
7 % order - order of accuracy of sbp operator.
1287
38653d26225c Make accurate/minimalBoundaryOptimizedGrid take the domain limits as input
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1285
diff changeset
8 function [x,h] = minimalBoundaryOptimizedGrid(lim,N,order)
1298
0ffb5bfa65e4 Improve comments
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1297
diff changeset
9 assert(iscell(lim) && numel(lim) == 2,'The limit should be a cell array with 2 elements.');
1287
38653d26225c Make accurate/minimalBoundaryOptimizedGrid take the domain limits as input
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1285
diff changeset
10 L = lim{2} - lim{1};
1288
e059a43bb675 Error-check format of limit arguments
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1287
diff changeset
11 assert(L>0,'Limits must be given in increasing order.');
1285
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
12 %%%% Non-equidistant grid points %%%%%
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
13 xb = boundaryPoints(order);
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
14 m = length(xb)-1; % Number of non-equidistant points
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
15 assert(N-2*(m+1)>=0,'Not enough grid points to contain the boundary region. Requires at least %d points.',2*(m+1));
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
17
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
18 %%%% Compute h %%%%%%%%%%
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
19 h = L/(2*xb(end) + N-1-2*m);
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
20 %%%%%%%%%%%%%%%%%%%%%%%%%
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
21
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
22 %%%% Define grid %%%%%%%%
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
23 x = h*[xb; linspace(xb(end)+1,L/h-xb(end)-1,N-2*(m+1))'; L/h-flip(xb) ];
1287
38653d26225c Make accurate/minimalBoundaryOptimizedGrid take the domain limits as input
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 1285
diff changeset
24 x = x + lim{1};
1285
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
25 %%%%%%%%%%%%%%%%%%%%%%%%%
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
26 end
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
27
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
28 function xb = boundaryPoints(order)
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
29 switch order
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
30 case 4
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
31 x0 = 0.0000000000000e+00;
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
32 x1 = 7.7122987842562e-01;
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
33 xb = [x0 x1]';
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
34 case 6
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
35 x0 = 0.0000000000000e+00;
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
36 x1 = 4.0842950991998e-01;
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
37 x2 = 1.1968523189207e+00;
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
38 xb = [x0 x1 x2]';
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
39 case 8
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
40 x0 = 0.0000000000000e+00;
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
41 x1 = 4.9439570885261e-01;
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
42 x2 = 1.4051531374839e+00;
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
43 xb = [x0 x1 x2]';
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
44 case 10
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
45 x0 = 0.0000000000000e+00;
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
46 x1 = 5.8556160757529e-01;
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
47 x2 = 1.7473267488572e+00;
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
48 x3 = 3.0000000000000e+00;
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
49 xb = [x0 x1 x2 x3]';
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
50 case 12
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
51 x0 = 0.0000000000000e+00;
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
52 x1 = 4.6552112904489e-01;
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
53 x2 = 1.4647984306493e+00;
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
54 x3 = 2.7620429464763e+00;
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
55 x4 = 4.0000000000000e+00;
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
56 xb = [x0 x1 x2 x3 x4]';
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
57 otherwise
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
58 error('Invalid operator order %d.',order);
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
59 end
6b68f939d023 Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
60 end