changeset 582:ce44af8d7dd1 feature/grids

Rename grid.EmptyGrid to grid.Empty
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 07 Sep 2017 10:21:15 +0200
parents 00261f8d7e15
children 75f9b7a80f28
files +grid/Empty.m +grid/EmptyGrid.m +grid/evalOn.m
diffstat 3 files changed, 58 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/+grid/Empty.m	Thu Sep 07 10:21:15 2017 +0200
@@ -0,0 +1,53 @@
+classdef Empty < grid.Grid & grid.Structured
+    properties
+        dim
+    end
+
+    methods
+        function obj = Empty(D)
+            obj.dim = D;
+        end
+        % n returns the number of points in the grid
+        function o = N(obj)
+            o = 0;
+        end
+
+        % d returns the spatial dimension of the grid
+        function o = D(obj)
+            o = obj.dim;
+        end
+
+        % points returns a n x d matrix containing the coordinates for all points.
+        function X = points(obj)
+            X = sparse(0,obj.dim);
+        end
+
+        % Restricts the grid function gf on obj to the subgrid g.
+        function gf = restrictFunc(obj, gf, g)
+            error('Restrict does not make sense for an empty grid')
+        end
+
+        % Projects the grid function gf on obj to the grid g.
+        function gf = projectFunc(obj, gf, g)
+            error('Project does not make sense for an empty grid')
+        end
+
+        % Return the grid.boundaryIdentifiers of all boundaries in a cell array.
+        function bs = getBoundaryNames(obj)
+            bs = {};
+        end
+
+        % Return coordinates for the given boundary
+        function b = getBoundary(obj, name)
+            b = sparse(0,obj.dim-1);
+        end
+
+        function h = scaling(obj)
+            h = 1;
+        end
+
+        function s = size(obj)
+            s = zeros(1, obj.dim);
+        end
+    end
+end
\ No newline at end of file
--- a/+grid/EmptyGrid.m	Thu Sep 07 09:54:45 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-classdef EmptyGrid < grid.Grid
-    properties
-        dim
-    end
-
-    methods
-        function obj = EmptyGrid(D)
-            obj.dim = D;
-        end
-        % n returns the number of points in the grid
-        function o = N(obj)
-            o = 0;
-        end
-
-        % d returns the spatial dimension of the grid
-        function o = D(obj)
-            o = obj.dim;
-        end
-
-        % points returns a n x d matrix containing the coordinates for all points.
-        function X = points(obj)
-            X = sparse(0,obj.dim);
-        end
-
-        % Restricts the grid function gf on obj to the subgrid g.
-        function gf = restrictFunc(obj, gf, g)
-            error('Restrict does not make sense for an empty grid')
-        end
-
-        % Projects the grid function gf on obj to the grid g.
-        function gf = projectFunc(obj, gf, g)
-            error('Project does not make sense for an empty grid')
-        end
-
-        % Return the grid.boundaryIdentifiers of all boundaries in a cell array.
-        function bs = getBoundaryNames(obj)
-            bs = {};
-        end
-
-        % Return coordinates for the given boundary
-        function b = getBoundary(obj, name)
-            b = sparse(0,obj.dim-1);
-        end
-    end
-end
\ No newline at end of file
--- a/+grid/evalOn.m	Thu Sep 07 09:54:45 2017 +0200
+++ b/+grid/evalOn.m	Thu Sep 07 10:21:15 2017 +0200
@@ -27,7 +27,11 @@
     x = num2cell(g.points());
 
     % Find the number of components
-    x0 = x(1,:);
+    if size(x,1) ~= 0
+        x0 = x(1,:);
+    else
+        x0 = num2cell(ones(1,size(x,2)));
+    end
     f0 = func(x0{:});
     k = length(f0);