Mercurial > repos > public > sbplib
annotate +sbp/+util/minimalBoundaryOptimizedGrid.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 |
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] = minimalBoundaryOptimizedGrid(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 |
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 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
|
18 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
|
19 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
|
20 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
|
21 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
|
22 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
|
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.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
|
26 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
|
27 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
|
28 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
|
29 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
|
30 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
|
31 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
|
32 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
|
33 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
|
34 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
|
35 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
|
36 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
|
37 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
|
38 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
|
39 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
|
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.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
|
42 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
|
43 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
|
44 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
|
45 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
|
46 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
|
47 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
|
48 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
|
49 end |