Raw File
build_dtFEbuf.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file is part of NS2DDV.                                                      %
%                                                                                   %
% Copyright(C) 2011-2018    C. Calgaro  (caterina.calgaro@math.univ-lille1.fr)      %
%                           E. Creusé   (emmanuel.creuse@math.univ-lille1.fr)       %
%                           T. Goudon   (thierry.goudon@inria.fr)                   %
%                           A. Mouton   (alexandre.mouton@math.univ-lille1.fr)      %
%                                                                                   %
% NS2DDV is free software: you can redistribute it and/or modify it under the terms %
% of the GNU General Public License as published by the Free Software Foundation,   %
% either version 3 of the License, or (at your option) any later version.           %
%                                                                                   %
% NS2DDV is distributed in the hope that it will be useful, but WITHOUT ANY         %
% WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A   %
% PARTICULAR PURPOSE. See the GNU General Public License for more details.          %
%                                                                                   %
% You should have received a copy of the GNU General Public License along with      %
% NS2DDV. If not, see <http://www.gnu.org/licenses/>.                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function[usrbuf] = build_dtFEbuf(answers)

	usrbuf = {};
	l = 1;

	switch answers.MODEL
		case {'NS', 'NSDV'}
			if strcmp(answers.MODEL, 'NS')
				alpha = 1.;
			else
				alpha = 1.5;
			end
			usrbuf{l} = '% Time step for solving Stokes equation';
			l = l+1;
			

			switch answers.CV_STUDY
				case {'IN_TIME'}
					usrbuf{l} = '% WARNING : this time step is of the form C*hmax^alpha';
					l = l+1;
					usrbuf{l} = '% where hmax is the max length of an edge for the considered space mesh';
					l = l+1;

					usrbuf{l} = '% Value of alpha';
					l = l+1;
					usrbuf{l} = sprintf('PARAMETERS.FE.ALPHA_STEP_TIME = %g;', alpha);
					l = l+1;

					usrbuf{l} = '% Values of C (provide several values for running a convergence analysis in dt)';
					l = l+1;
					usrbuf{l} = 'PARAMETERS.FE.C_STEP_TIME = {1., 0.5, 0.25};';
					l = l+1;

				case {'IN_SPACE'}
					usrbuf{l} = '% WARNING : this time step is of the form Cmax*hmax^alphamax + Cmin*hmin^alphamin';
					l = l+1;
					usrbuf{l} = '% where hmax (hmin) is the max (min) length of an edge for the most refined space mesh';
					l = l+1;

					usrbuf{l} = '% Value of alphamax';
					l = l+1;
					usrbuf{l} = sprintf('PARAMETERS.FE.ALPHAMAX_STEP_TIME = %g;', alpha);
					l = l+1;
					usrbuf{l} = '% Value of alphamin';
					l = l+1;
					usrbuf{l} = sprintf('PARAMETERS.FE.ALPHAMIN_STEP_TIME = %g;', alpha);
					l = l+1;

					Cmax = 0.;
					Cmin = 1.;
					usrbuf{l} = '% Value of Cmax';
					l = l+1;
					usrbuf{l} = sprintf('PARAMETERS.FE.CMAX_STEP_TIME = %g;', Cmax);
					l = l+1;
					usrbuf{l} = '% Value of Cmin';
					l = l+1;
					usrbuf{l} = sprintf('PARAMETERS.FE.CMIN_STEP_TIME = %g;', Cmin);
					l = l+1;


				case {'IN_SPACETIME'}
					usrbuf{l} = '% WARNING : this time step is of the form Cmax*hmax^alphamax + Cmin*hmin^alphamin';
					l = l+1;
					usrbuf{l} = '% where hmax (hmin) is the max (min) length of an edge for each considered space mesh';
					l = l+1;

					usrbuf{l} = '% Value of alphamax';
					l = l+1;
					usrbuf{l} = sprintf('PARAMETERS.FE.ALPHAMAX_STEP_TIME = %g;', alpha);
					l = l+1;
					usrbuf{l} = '% Value of alphamin';
					l = l+1;
					usrbuf{l} = sprintf('PARAMETERS.FE.ALPHAMIN_STEP_TIME = %g;', alpha);
					l = l+1;

					Cmax = 0.;
					Cmin = 1.;
					usrbuf{l} = '% Value of Cmax';
					l = l+1;
					usrbuf{l} = sprintf('PARAMETERS.FE.CMAX_STEP_TIME = %g;', Cmax);
					l = l+1;
					usrbuf{l} = '% Value of Cmin';
					l = l+1;
					usrbuf{l} = sprintf('PARAMETERS.FE.CMIN_STEP_TIME = %g;', Cmin);
					l = l+1;

				case {'IN_REYNOLDS', 'NONE'}
					usrbuf{l} = '% WARNING : this time step is of the form Cmax*hmax^alphamax + Cmin*hmin^alphamin';
					l = l+1;
					usrbuf{l} = '% where hmax (hmin) is the max (min) length of an edge';
					l = l+1;
					usrbuf{l} = '% Value of alphamax';
					l = l+1;
					usrbuf{l} = sprintf('PARAMETERS.FE.ALPHAMAX_STEP_TIME = %g;', alpha);
					l = l+1;
					usrbuf{l} = '% Value of alphamin';
					l = l+1;
					usrbuf{l} = sprintf('PARAMETERS.FE.ALPHAMIN_STEP_TIME = %g;', alpha);
					l = l+1;

					Cmax = 0.;
					Cmin = 1.;
					usrbuf{l} = '% Value of Cmax';
					l = l+1;
					usrbuf{l} = sprintf('PARAMETERS.FE.CMAX_STEP_TIME = %g;', Cmax);
					l = l+1;
					usrbuf{l} = '% Value of Cmin';
					l = l+1;
					usrbuf{l} = sprintf('PARAMETERS.FE.CMIN_STEP_TIME = %g;', Cmin);
					l = l+1;

				otherwise
					error('Problem in generate_manual_setup');
			end

			usrbuf{l} = '% Reduce the time step to reach the final time T exactly (''YES'' or ''NO'')';
			l = l+1;
			usrbuf{l} = '% Warning: answering ''NO'' will probably make the simulation stop a little before the final time';
			l = l+1;
			usrbuf{l} = 'PARAMETERS.FE.FIT_STEP_TIME = ''YES'';';
			l = l+1;

			if strcmp(answers.MODEL, 'NSDV')
				usrbuf{l} = '% Time splitting';
				l = l+1;
				usrbuf{l} = '% 1  1st order Lie splitting';
				l = l+1;
				usrbuf{l} = '% 2  2nd order symmetric Strang splitting';
				l = l+1;
				usrbuf{l} = 'PARAMETERS.TIME_SPLITTING = 2;';
				l = l+1;
			end

		otherwise
			error('Unknown model');
	end

end
back to top