Add documentation, support multiple grid components and '.type' field.

This commit is contained in:
Bård Skaflestad
2010-08-18 08:37:40 +00:00
parent 8df4a5f14b
commit e7155b332a

View File

@@ -1,8 +1,47 @@
function G = mcomputeGeometry(G)
[fa,fc,fn,cc,cv] = mex_compute_geometry(G);
G.faces.areas = fa;
G.faces.centroids = fc';
G.faces.normals = fn';
G.cells.centroids = cc';
G.cells.volumes = cv;
%Compute geometric primitves using compiled C code.
%
% SYNOPSIS:
% G = mcomputeGeometry(G)
%
% PARAMETERS:
% G - A grid_structure.
%
% RETURNS:
% G - An updated grid_structure containing areas, volumes, normals and
% centroids.
%
% SEE ALSO:
% computeGeometry, grid_structure.
%{
#COPYRIGHT#
%}
% $Date$
% $Revision$
warn_no_type = false;
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;
if ~isfield(G(k), 'type'),
if ~warn_no_type,
warning(msgid('GridType:Unknown'), ...
['Input grid has no known type. ', ...
'I''ll assume it arose from the primordial soup...']);
warn_no_type = true;
end
G(k).type = { 'Primordial Soup' };
end
G(k).type = [ G(k).type, { mfilename } ];
end
end