Raw File
refine_mesh_parameters.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[NEWPARAMETERS] = refine_mesh_parameters(OLDPARAMETERS)

	% INPUT
	% OLDPARAMETERS		List of simulation parameters to be updated for refinement in time and/or in space
	%
	% OUTPUT
	% OLDPARAMETERS		List of simulation parameters updated for a refinement

	NEWPARAMETERS = OLDPARAMETERS;

	switch OLDPARAMETERS.CV_STUDY
		case {'IN_SPACE', 'IN_SPACETIME'}
			% Refine the parameters defining the space mesh step
			% (This part does not depend on the model)
			switch OLDPARAMETERS.MESH.GENERATION
				case {'NS2DDV'}
					switch OLDPARAMETERS.DOMAIN.GEOMETRY
						case {'RECTANGLE'}
							NEWPARAMETERS.MESH.NBSEG_X = OLDPARAMETERS.MESH.NBSEG_X * ...
														OLDPARAMETERS.REFINE_BY_DIVIDING_BY;
							NEWPARAMETERS.MESH.NBSEG_Y = OLDPARAMETERS.MESH.NBSEG_Y * ...
														OLDPARAMETERS.REFINE_BY_DIVIDING_BY;

						case {'CIRCLE'}
							NEWPARAMETERS.MESH.NBSEG_C = OLDPARAMETERS.MESH.NBSEG_C * ...
														OLDPARAMETERS.REFINE_BY_DIVIDING_BY;

						case {'DIHEDRON', 'STEP', 'FROM_FILE'}
							error(sprintf('Only RECTANGLE or CIRCLE geometry can be handled with NS2DDV mesh generator in a convergence study\n'));

						otherwise
							error(sprintf('Unknown domain geometry\n'));
					end
				case {'PDET'}
					NEWPARAMETERS.MESH.H0 = OLDPARAMETERS.MESH.H0 / ...
											OLDPARAMETERS.REFINE_BY_DIVIDING_BY;

				case {'FROM_FILE'}
					error(sprintf('Convergence study cannot be handled yet with external mesh files\n'));
				otherwise
					error(sprintf('Unknown mesh generation method\n'));
			end

		case {'IN_TIME'}
			% Refine the parameters defining the time step according to the model
			switch OLDPARAMETERS.MODEL
				case {'NSDV','NS'}
					% In fact, we refine C in the definition dt = C * hmax^alpha
					NEWPARAMETERS.FE.C_STEP_TIME = OLDPARAMETERS.FE.C_STEP_TIME / ...
											OLDPARAMETERS.REFINE_BY_DIVIDING_BY;

				otherwise
					error('Unknown model\n');
			end

		case {'IN_REYNOLDS'}
			% Change the value of Reynolds number
			NEWPARAMETERS.PHYSICAL.RE = OLDPARAMETERS.PHYSICAL.RE * OLDPARAMETERS.REFINE_BY_MULTIPLYING_BY;

		otherwise
			error(sprintf('Unknown convergence analysis choice\n'));
	end

end
back to top