Support empty grids.

This commit is contained in:
Bård Skaflestad
2010-08-18 08:50:26 +00:00
parent 1f8773b5e7
commit 4013dec710
+17 -15
View File
@@ -21,22 +21,24 @@ function G = mcomputeGeometry(G)
% $Date$
% $Revision$
if ~isfield(G(1), 'type'),
warning(msgid('GridType:Unknown'), ...
['Input grid has no known type. ', ...
'I''ll assume it arose from the primordial soup...']);
if numel(G) > 0,
if ~isfield(G(1), 'type'),
warning(msgid('GridType:Unknown'), ...
['Input grid has no known type. ', ...
'I''ll assume it arose from the primordial soup...']);
[ G(:).type ] = deal( {'Primordial Soup'} );
end
[ G(:).type ] = deal( {'Primordial Soup'} );
end
for k = 1 : numel(G),
[fa,fc,fn,cc,cv] = mex_compute_geometry(G(k));
G(k).faces.areas = fa;
G(k).faces.centroids = fc';
G(k).faces.normals = fn';
G(k).cells.centroids = cc';
G(k).cells.volumes = cv;
G(k).type = [ G(k).type, { mfilename } ];
for k = 1 : numel(G),
[fa,fc,fn,cc,cv] = mex_compute_geometry(G(k));
G(k).faces.areas = fa;
G(k).faces.centroids = fc';
G(k).faces.normals = fn';
G(k).cells.centroids = cc';
G(k).cells.volumes = cv;
G(k).type = [ G(k).type, { mfilename } ];
end
end
end