recover_areas

PURPOSE ^

RECOVER_AREAS - flag the element depending on the physical model that is assigned to them

SYNOPSIS ^

function [hutterflag macayealflag pattynflag stokesflag filltype]=recover_areas(md,varargin);

DESCRIPTION ^

RECOVER_AREAS - flag the element depending on the physical model that is assigned to them

   This routine is called by setelementstype, do not use

   Usage:
      [hutterflag macayealflag pattynflag stokesflag filltype]=recover_areas(md,varargin);

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [hutterflag macayealflag pattynflag stokesflag filltype]=recover_areas(md,varargin);
0002 %RECOVER_AREAS - flag the element depending on the physical model that is assigned to them
0003 %
0004 %   This routine is called by setelementstype, do not use
0005 %
0006 %   Usage:
0007 %      [hutterflag macayealflag pattynflag stokesflag filltype]=recover_areas(md,varargin);
0008 
0009     %initialize elementstype
0010     hutterflag=zeros(md.numberofelements,1);
0011     macayealflag=zeros(md.numberofelements,1);
0012     pattynflag=zeros(md.numberofelements,1);
0013     stokesflag=zeros(md.numberofelements,1);
0014     filltype='none';
0015 
0016     %make sure length(varargin) is even
0017     varargin=varargin{1};
0018     if mod(length(varargin),2),
0019         error('recover_elementstype_options error message: an even number of options is necessary');
0020     end
0021 
0022     %go through varargin, extract options and plug them into subtype options, by order of appearance
0023     for i=1:length(varargin)/2,
0024 
0025         optionstring=varargin{2*i-1};
0026         optionvalue=varargin{2*i};
0027 
0028         if strcmpi(optionstring,'hutter'),
0029             hutterflag=BuildFlag(md,optionvalue);
0030         elseif strcmpi(optionstring,'macayeal'),
0031             macayealflag=BuildFlag(md,optionvalue);
0032         elseif strcmpi(optionstring,'pattyn'),
0033             pattynflag=BuildFlag(md,optionvalue);
0034         elseif strcmpi(optionstring,'stokes'),
0035             stokesflag=BuildFlag(md,optionvalue);
0036         elseif strcmpi(optionstring,'fill'),
0037             filltype=optionvalue;
0038         else
0039             error('elementstype_options error message: bad elementstype options');
0040         end
0041     end
0042 end %end function
0043 
0044 
0045 function flag=BuildFlag(md,area),
0046     if ischar(area),
0047         if isempty(area),
0048             flag=zeros(md.numberofelements,1);
0049             invert=0;
0050         elseif strcmpi(area,'all')
0051             flag=ones(md.numberofelements,1);
0052             invert=0;
0053         else
0054             %make sure that we actually don't want the elements outside the domain outline!
0055             if strcmpi(area(1),'~'),
0056                 area=area(2:length(area));
0057                 invert=1;
0058             else
0059                 invert=0;
0060             end
0061             %ok, flag elements
0062             flag=ArgusContourToMesh(md.elements(:,1:3),md.x,md.y,expread(area,1),'element',1);
0063         end
0064         if invert,
0065             flag=~flag;
0066         end
0067     elseif isfloat(area),
0068         if size(area,1)~=md.numberofelements,
0069             setelementstypeusage();
0070             error('Flags for elements_type must be of same size as number of elements in model');
0071         end
0072         flag=area;
0073     else
0074         error('Invalide elements_type option');
0075     end
0076 end

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003