diff --git a/mcomputeGeometry.m b/mcomputeGeometry.m index 98b81c1d..63a28ced 100644 --- a/mcomputeGeometry.m +++ b/mcomputeGeometry.m @@ -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