Mercurial > repos > public > sbplib
comparison +sbp/+grid/accurateBoundaryOptimizedGrid.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 | 0ffb5bfa65e4 |
children |
comparison
equal
deleted
inserted
replaced
1250:8ec777fb473e | 1300:196123459178 |
---|---|
1 % Computes the grid points x and grid spacing h used by the boundary optimized SBP operators | |
2 % with improved boundary accuracy, presented in | |
3 % 'Boundary optimized diagonal-norm SBP operators - Mattsson, Almquist, van der Weide 2018'. | |
4 % | |
5 % lim - cell array with domain limits | |
6 % N - Number of grid points | |
7 % order - order of accuracy of sbp operator. | |
8 function [x,h] = accurateBoundaryOptimizedGrid(lim,N,order) | |
9 assert(iscell(lim) && numel(lim) == 2,'The limit should be cell array with 2 elements.'); | |
10 L = lim{2} - lim{1}; | |
11 assert(L>0,'Limits must be given in increasing order.'); | |
12 %%%% Non-equidistant grid points %%%%% | |
13 xb = boundaryPoints(order); | |
14 m = length(xb)-1; % Number of non-equidistant points | |
15 assert(N-2*(m+1)>=0,'Not enough grid points to contain the boundary region. Requires at least %d points.',2*(m+1)); | |
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
17 | |
18 %%%% Compute h %%%%%%%%%% | |
19 h = L/(2*xb(end) + N-1-2*m); | |
20 %%%%%%%%%%%%%%%%%%%%%%%%% | |
21 | |
22 %%%% Define grid %%%%%%%% | |
23 x = h*[xb; linspace(xb(end)+1,L/h-xb(end)-1,N-2*(m+1))'; L/h-flip(xb) ]; | |
24 x = x + lim{1}; | |
25 %%%%%%%%%%%%%%%%%%%%%%%%% | |
26 end | |
27 function xb = boundaryPoints(order) | |
28 switch order | |
29 case 4 | |
30 x0 = 0.0000000000000e+00; | |
31 x1 = 6.8764546205559e-01; | |
32 x2 = 1.8022115125776e+00; | |
33 xb = [x0 x1 x2]'; | |
34 case 6 | |
35 x0 = 0.0000000000000e+00; | |
36 x1 = 4.4090263368623e-01; | |
37 x2 = 1.2855984345073e+00; | |
38 x3 = 2.2638953951239e+00; | |
39 xb = [x0 x1 x2 x3]'; | |
40 case 8 | |
41 x0 = 0.0000000000000e+00; | |
42 x1 = 3.8118550247622e-01; | |
43 x2 = 1.1899550868338e+00; | |
44 x3 = 2.2476300175641e+00; | |
45 x4 = 3.3192851303204e+00; | |
46 xb = [x0 x1 x2 x3 x4]'; | |
47 case 10 | |
48 x0 = 0.0000000000000e+00; | |
49 x1 = 3.5902433622052e-01; | |
50 x2 = 1.1436659188355e+00; | |
51 x3 = 2.2144895894456e+00; | |
52 x4 = 3.3682742337736e+00; | |
53 x5 = 4.4309689056870e+00; | |
54 xb = [x0 x1 x2 x3 x4 x5]'; | |
55 case 12 | |
56 x0 = 0.0000000000000e+00; | |
57 x1 = 3.6098032343909e-01; | |
58 x2 = 1.1634317168086e+00; | |
59 x3 = 2.2975905356987e+00; | |
60 x4 = 3.6057529790929e+00; | |
61 x5 = 4.8918275675510e+00; | |
62 x6 = 6.0000000000000e+00; | |
63 xb = [x0 x1 x2 x3 x4 x5 x6]'; | |
64 otherwise | |
65 error('Invalid operator order %d.',order); | |
66 end | |
67 end |