comparison +grid/EmptyGrid.m @ 577:e45c9b56d50d feature/grids

Add an Empty grid class The need turned up for the flexural code when we may or may not have a grid for the open water and want to plot that solution. In case there is no open water we need an empty grid to plot the empty gridfunction against to avoid errors.
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 07 Sep 2017 09:16:12 +0200
parents
children
comparison
equal deleted inserted replaced
576:705658c55229 577:e45c9b56d50d
1 classdef EmptyGrid < grid.Grid
2 properties
3 dim
4 end
5
6 methods
7 function obj = EmptyGrid(D)
8 obj.dim = D;
9 end
10 % n returns the number of points in the grid
11 function o = N(obj)
12 o = 0;
13 end
14
15 % d returns the spatial dimension of the grid
16 function o = D(obj)
17 o = obj.dim;
18 end
19
20 % points returns a n x d matrix containing the coordinates for all points.
21 function X = points(obj)
22 X = sparse(0,obj.dim);
23 end
24
25 % Restricts the grid function gf on obj to the subgrid g.
26 function gf = restrictFunc(obj, gf, g)
27 error('Restrict does not make sense for an empty grid')
28 end
29
30 % Projects the grid function gf on obj to the grid g.
31 function gf = projectFunc(obj, gf, g)
32 error('Project does not make sense for an empty grid')
33 end
34
35 % Return the grid.boundaryIdentifiers of all boundaries in a cell array.
36 function bs = getBoundaryNames(obj)
37 bs = {};
38 end
39
40 % Return coordinates for the given boundary
41 function b = getBoundary(obj, name)
42 b = sparse(0,obj.dim-1);
43 end
44 end
45 end