%MASK class definition
%
%   Usage:
%      mask=mask();

classdef mask
	properties (SetAccess=public) 
		groundedice_levelset = NaN;
		ice_levelset         = NaN;
	end
	methods
		function obj = mask(varargin) % {{{
			switch nargin
				case 0
					obj=setdefaultparameters(obj);
				otherwise
					error('constructor not supported');
			end
		end % }}}
		function obj = setdefaultparameters(obj) % {{{

		end % }}}
		function md = checkconsistency(obj,md,solution,analyses) % {{{

			md = checkfield(md,'mask.groundedice_levelset','size',[md.mesh.numberofvertices 1]);
			md = checkfield(md,'mask.ice_levelset'        ,'size',[md.mesh.numberofvertices 1]);
			isice=(md.mask.ice_levelset>0);
			if any(sum(isice(md.mesh.elements),2)==0),
				error('elements with no ice not implemented yet, each element should have at least one vertex with md.mask.ice_levelset > 0');
			end
		end % }}}
		function disp(obj) % {{{
			disp(sprintf('   masks:'));

			fielddisplay(obj,'groundedice_levelset','is ice grounded ? grounded ice if > 0, grounding line position if = 0, floating ice if < 0');
			fielddisplay(obj,'ice_levelset','presence of ice if > 0, icefront position if = 0, no ice if < 0');
		end % }}}
		function marshall(obj,md,fid) % {{{
			WriteData(fid,'object',obj,'fieldname','groundedice_levelset','format','DoubleMat','mattype',1);
			WriteData(fid,'object',obj,'fieldname','ice_levelset','format','DoubleMat','mattype',1);
		end % }}}
	end
end
