annotate +sbp/+util/accurateBoundaryOptimizedGrid.m @ 1285:6b68f939d023 feature/boundary_optimized_grids

Add utility functions for constructing the grids used by the boundary optimized D1Nonequidistant opsets
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 01 Jul 2020 11:15:57 +0200
parents
children 38653d26225c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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
1 function [x,h] = accurateBoundaryOptimizedGrid(L,N,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
2 %%%% 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
3 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
4 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
5 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
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
7
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
8 %%%% 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
9 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
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
11
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 %%%% 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
13 x = h*[xb; linspace(xb(end)+1,L/h-xb(end)-1,N-2*(m+1))'; L/h-flip(xb) ];
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 %%%%%%%%%%%%%%%%%%%%%%%%%
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 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
16 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
17 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
18 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
19 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
20 x1 = 6.8764546205559e-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
21 x2 = 1.8022115125776e+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
22 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
23 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
24 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
25 x1 = 4.4090263368623e-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
26 x2 = 1.2855984345073e+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
27 x3 = 2.2638953951239e+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
28 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
29 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
30 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
31 x1 = 3.8118550247622e-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
32 x2 = 1.1899550868338e+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
33 x3 = 2.2476300175641e+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
34 x4 = 3.3192851303204e+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
35 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
36 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
37 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
38 x1 = 3.5902433622052e-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
39 x2 = 1.1436659188355e+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
40 x3 = 2.2144895894456e+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 x4 = 3.3682742337736e+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
42 x5 = 4.4309689056870e+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 x3 x4 x5]';
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 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
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 = 3.6098032343909e-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.1634317168086e+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 = 2.2975905356987e+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 x4 = 3.6057529790929e+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
50 x5 = 4.8918275675510e+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
51 x6 = 6.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 xb = [x0 x1 x2 x3 x4 x5 x6]';
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 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
54 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
55 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
56 end