Mercurial > repos > public > sbplib
comparison +grid/Cartesian.m @ 173:f7bb2a94d291 feature/grids
Added functionallity for storing grid scaling on structured grids.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 26 Feb 2016 16:06:03 +0100 |
parents | ba1ae5b2c45e |
children | c5ca9bbfed41 |
comparison
equal
deleted
inserted
replaced
172:c3483685116a | 173:f7bb2a94d291 |
---|---|
2 properties | 2 properties |
3 n % Number of points in the grid | 3 n % Number of points in the grid |
4 d % Number of dimensions | 4 d % Number of dimensions |
5 m % Number of points in each direction | 5 m % Number of points in each direction |
6 x % Cell array of vectors with node placement for each dimension. | 6 x % Cell array of vectors with node placement for each dimension. |
7 h % Spacing/Scaling | |
7 end | 8 end |
8 | 9 |
9 % General d dimensional grid with n points | 10 % General d dimensional grid with n points |
10 methods | 11 methods |
11 % Creates a cartesian grid given vectors conatining the coordinates | 12 % Creates a cartesian grid given vectors conatining the coordinates |
12 % in each direction | 13 % in each direction |
13 function obj = Cartesian(varargin) | 14 function obj = Cartesian(varargin) |
14 obj.d = length(varargin); | 15 obj.d = length(varargin); |
16 | |
15 for i = 1:obj.d | 17 for i = 1:obj.d |
16 obj.x{i} = varargin{i}; | 18 obj.x{i} = varargin{i}; |
17 obj.m(i) = length(varargin{i}); | 19 obj.m(i) = length(varargin{i}); |
18 end | 20 end |
21 | |
19 obj.n = prod(obj.m); | 22 obj.n = prod(obj.m); |
20 if obj.n == 0 | 23 if obj.n == 0 |
21 error('grid:Cartesian:EmptyGrid','Input parameter gives an empty grid.') | 24 error('grid:Cartesian:EmptyGrid','Input parameter gives an empty grid.') |
22 end | 25 end |
26 | |
27 obj.h = []; | |
23 end | 28 end |
24 % n returns the number of points in the grid | 29 % n returns the number of points in the grid |
25 function o = N(obj) | 30 function o = N(obj) |
26 o = obj.n; | 31 o = obj.n; |
27 end | 32 end |
74 s(i) = 1; | 79 s(i) = 1; |
75 X{i} = repmat(t,s); | 80 X{i} = repmat(t,s); |
76 end | 81 end |
77 end | 82 end |
78 | 83 |
84 function h = scaling(obj) | |
85 if isempty(obj.h) | |
86 error('grid:Cartesian:NoScalingSet', 'No scaling set') | |
87 end | |
88 | |
89 h = obj.h; | |
90 end | |
91 | |
79 % Restricts the grid function gf on obj to the subgrid g. | 92 % Restricts the grid function gf on obj to the subgrid g. |
80 % Only works for even multiples | 93 % Only works for even multiples |
81 function gf = restrictFunc(obj, gf, g) | 94 function gf = restrictFunc(obj, gf, g) |
82 m1 = obj.m; | 95 m1 = obj.m; |
83 m2 = g.m; | 96 m2 = g.m; |