function [stats,data]=mphmeshstats(model,meshname)
% MPHMESHSTATS Return mesh statistics and mesh information
% 
%   STATS = MPHMESHSTATS(MODEL,MESHNAME) returns mesh statistics as a
%   structure. The fields in the structure are listed below.
% 
%   [STATS,DATA] = MPHMESHSTATS(MODEL,MESHNAME) returns mesh statistics and
%   mesh information such as vertex coordinates and definitions of elements.
% 
%   MESHNAME can be omitted if there is only one mesh in the model.
% 
%   STATS has the following fields
%   Field         Description
%   -----------------------------------------------------------------------
%   Isactive      Is the mesh node active
%   Hasproblems   Does the mesh have problems?
%   Iscomplete    Is the mesh built to completion?
%   Sdim          Space dimension
%   Types         Cell array with type names
%   Numelem       Vector with the number of elemenrts for each type
%   Minquality    Minimum quality
%   Meanquality   Mean quality
%   Qualitydistr  Quality distribution (vector)
%   Minvolume     Volume/area of the smallest element
%   Maxvolume     Volume/area of the largest element 
%   Volume        Volume/area of the mesh
% 
%   DATA has the following fields
%   Field         Description
%   -----------------------------------------------------------------------
%   Vertex        Coordinates of mesh vertices
%   Elem          Cell array of definition of each element type
%   Elementity    Entity information for each element type
% 
%   Example:
%     % Load busbar.mph from the Model Library:
%     model = mphload('busbar');
%     % Show the mesh distribution in a figure:
%     stats = mphmeshstats(model);
%     bar(linspace(0,1,20),stats.qualitydistr)
% 
%     % Show the element vertices in a plot:
%     [stats,data] = mphmeshstats(model, 'mesh1');
%     plot3(data.vertex(1,:), data.vertex(2,:), data.vertex(3,:), '.')
%     axis equal
%     view(3)
%     % Find the number of edge elements:
%     stats.types
%     % Note that the edg type is the first type in the list:
%     numedgeelem = stats.numelem(1)
% 
%   See also: mphmesh, mphviewselection

% Copyright 2010-2011 COMSOL
