diff +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
line wrap: on
line diff
--- a/+grid/Cartesian.m	Thu Feb 25 11:30:05 2016 +0100
+++ b/+grid/Cartesian.m	Fri Feb 26 16:06:03 2016 +0100
@@ -4,6 +4,7 @@
         d % Number of dimensions
         m % Number of points in each direction
         x % Cell array of vectors with node placement for each dimension.
+        h % Spacing/Scaling
     end
 
     % General d dimensional grid with n points
@@ -12,14 +13,18 @@
         % in each direction
         function obj = Cartesian(varargin)
             obj.d = length(varargin);
+
             for i = 1:obj.d
                 obj.x{i} = varargin{i};
                 obj.m(i) = length(varargin{i});
             end
+
             obj.n = prod(obj.m);
             if obj.n == 0
                 error('grid:Cartesian:EmptyGrid','Input parameter gives an empty grid.')
             end
+
+            obj.h = [];
         end
         % n returns the number of points in the grid
         function o = N(obj)
@@ -76,6 +81,14 @@
             end
         end
 
+        function h = scaling(obj)
+            if isempty(obj.h)
+                error('grid:Cartesian:NoScalingSet', 'No scaling set')
+            end
+
+            h = obj.h;
+        end
+
         % Restricts the grid function gf on obj to the subgrid g.
         % Only works for even multiples
         function gf = restrictFunc(obj, gf, g)