%PROGNOSTIC class definition
%
%   Usage:
%      prognostic=prognostic();

classdef prognostic
	properties (SetAccess=public) 
		 spcthickness           = NaN;
		 hydrostatic_adjustment = 0;
		 stabilization          = 0;
		 vertex_pairing         = NaN;
		 penalty_factor         = 0;
	end
	methods
		function obj = prognostic(varargin) % {{{
			switch nargin
				case 0
					obj=setdefaultparameters(obj);
				case 1
					in=varargin{1};
					if (isa(in,'numeric') & in==0),
						% requesting templates do nothing
					else
						error('constructor not supported');
					end 
				otherwise
					error('constructor not supported');
			end
		end % }}}
		function obj = setdefaultparameters(obj) % {{{

			%Type of stabilization to use 0:nothing 1:artificial_diffusivity 3:Discontinuous Galerkin
			obj.stabilization=1;

			%Factor applied to compute the penalties kappa=max(stiffness matrix)*10^penalty_factor
			obj.penalty_factor=3;

			%Hydrostatic adjustment
			obj.hydrostatic_adjustment='Absolute';
		end % }}}
		function checkconsistency(obj,md,solution,analyses) % {{{

			%Early return,
			if ~ismember(PrognosticAnalysisEnum,analyses), return; end

			checkfield(md,'prognostic.spcthickness','forcing',1);
			checkfield(md,'prognostic.hydrostatic_adjustment','values',{'Absolute' 'Incremental'});
			checkfield(md,'prognostic.stabilization','values',[0 1 3]);

		end % }}}
		function disp(obj) % {{{
			disp(sprintf('   Prognostic solution parameters:'));
			fielddisplay(obj,'spcthickness','thickness constraints (NaN means no constraint)');
			fielddisplay(obj,'hydrostatic_adjustment','adjustment of ice shelves surface and bed elevations: ''Incremental'' or ''Absolute'' ');
			fielddisplay(obj,'stabilization','0->no, 1->artificial_diffusivity, 3->discontinuous Galerkin');

			disp(sprintf('\n      %s','Penalty options:'));
			fielddisplay(obj,'penalty_factor','offset used by penalties: penalty = Kmax*10^offset');
			fielddisplay(obj,'vertex_pairing','pairs of vertices that are penalized');

		end % }}}
		function marshall(obj,fid) % {{{
			WriteData(fid,'object',obj,'fieldname','spcthickness','format','DoubleMat','mattype',1);
			WriteData(fid,'data',StringToEnum(obj.hydrostatic_adjustment),'format','Integer','enum',PrognosticHydrostaticAdjustmentEnum);
			WriteData(fid,'object',obj,'fieldname','stabilization','format','Integer');
			WriteData(fid,'object',obj,'fieldname','vertex_pairing','format','DoubleMat','mattype',3);
			WriteData(fid,'object',obj,'fieldname','penalty_factor','format','Double');
		end % }}}
	end
end
