Mercurial > repos > public > sbplib
comparison +sbp/+util/minimalBoundaryOptimizedGrid.m @ 1287:38653d26225c feature/boundary_optimized_grids
Make accurate/minimalBoundaryOptimizedGrid take the domain limits as input
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Wed, 01 Jul 2020 14:54:21 +0200 |
parents | 6b68f939d023 |
children | e059a43bb675 |
comparison
equal
deleted
inserted
replaced
1286:4cb627c7fb90 | 1287:38653d26225c |
---|---|
1 function [x,h] = minimalBoundaryOptimizedGrid(L,N,order) | 1 function [x,h] = minimalBoundaryOptimizedGrid(lim,N,order) |
2 L = lim{2} - lim{1}; | |
3 assert(L>0,'Limits must be given in increasing order.') | |
2 %%%% Non-equidistant grid points %%%%% | 4 %%%% Non-equidistant grid points %%%%% |
3 xb = boundaryPoints(order); | 5 xb = boundaryPoints(order); |
4 m = length(xb)-1; % Number of non-equidistant points | 6 m = length(xb)-1; % Number of non-equidistant points |
5 assert(N-2*(m+1)>=0,'Not enough grid points to contain the boundary region. Requires at least %d points.',2*(m+1)); | 7 assert(N-2*(m+1)>=0,'Not enough grid points to contain the boundary region. Requires at least %d points.',2*(m+1)); |
6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
9 h = L/(2*xb(end) + N-1-2*m); | 11 h = L/(2*xb(end) + N-1-2*m); |
10 %%%%%%%%%%%%%%%%%%%%%%%%% | 12 %%%%%%%%%%%%%%%%%%%%%%%%% |
11 | 13 |
12 %%%% Define grid %%%%%%%% | 14 %%%% Define grid %%%%%%%% |
13 x = h*[xb; linspace(xb(end)+1,L/h-xb(end)-1,N-2*(m+1))'; L/h-flip(xb) ]; | 15 x = h*[xb; linspace(xb(end)+1,L/h-xb(end)-1,N-2*(m+1))'; L/h-flip(xb) ]; |
16 x = x + lim{1}; | |
14 %%%%%%%%%%%%%%%%%%%%%%%%% | 17 %%%%%%%%%%%%%%%%%%%%%%%%% |
15 end | 18 end |
16 | 19 |
17 function xb = boundaryPoints(order) | 20 function xb = boundaryPoints(order) |
18 switch order | 21 switch order |