%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 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 . % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function[usrbuf] = build_meshbuf(answers) usrbuf = {}; l = 1; usrbuf{l} = ''; l = l+1; usrbuf{l} = '% Mesh parameters'; l = l+1; usrbuf{l} = '%%%%%%%%%%%%%%%%%'; l = l+1; usrbuf{l} = '% Method for generating the space mesh'; l = l+1; if answers.PDET usrbuf{l} = '% ''PDET'' Use the Matlab PDE toolbox'; l = l+1; MESHGEN = 'PDET'; else MESHGEN = 'FROM_FILE'; end if (max(strcmp(answers.GEOM, {'RECTANGLE', 'CIRCLE', 'DIHEDRON'})) == 1) usrbuf{l} = '% ''NS2DDV'' Use the routines embedded in NS2DDV code'; l = l+1; end usrbuf{l} = '% ''FROM_FILE'' Load data from a mesh file (.msh or _p1/_t1 format allowed)'; l = l+1; usrbuf{l} = strcat('PARAMETERS.MESH.GENERATION = ''', MESHGEN, ''';'); l = l+1; usrbuf{l} = '% Node renumbering method'; l = l+1; usrbuf{l} = '% ''NONE'' No renumbering'; l = l+1; if answers.AMD usrbuf{l} = '% ''AMD'' Renumbering with Minimum Degree Algorithm Matlab built-in routines'; l = l+1; end if answers.CMK usrbuf{l} = '% ''CMK'' Renumbering with Cuthill-McKee Matlab built-in routines'; l = l+1; end usrbuf{l} = 'PARAMETERS.MESH.RENUMBERING = ''NONE'';'; l = l+1; % Add NS2DDV parameters switch answers.GEOM case {'RECTANGLE'} switch answers.TESTCASE case {'RTIN'} nx = 10; ny = 40; case {'CAEN'} nx = 20; ny = 20; case {'DROP'} nx = 20; ny = 40; case {'EXAC'} nx = 20; ny = 20; case {'EXACNEU'} nx = 20; ny = 20; case {'POIS'} nx = 40; ny = 10; case {'NONA'} nx = 60; ny = 20; case {'GTPSI'} nx = 20; ny = 20; otherwise error('Unknown test case'); end usrbuf{l} = '% Parameters for a NS2DDV mesh'; l = l+1; usrbuf{l} = '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'; l = l+1; usrbuf{l} = '% Design of structured mesh (''DIAGONAL'' or ''CROSS'')'; l = l+1; usrbuf{l} = 'PARAMETERS.MESH.TRIANGLES_ORIENTATION = ''DIAGONAL'';'; l = l+1; switch answers.CV_STUDY case {'IN_SPACE', 'IN_SPACETIME'} % The use provides a list of values for nx and ny usrbuf{l} = '% Number of edges on North and South bounds'; l = l+1; usrbuf{l} = '% WARNING: it must be a multiple of 2'; l = l+1; usrbuf{l} = '% {value 1, value 2, ...} set of values for NBSEG_X for running the convergence analysis'; l = l+1; usrbuf{l} = sprintf('PARAMETERS.MESH.NBSEG_X = {%d, %d, %d};', nx, 2*nx, 4*nx); l = l+1; usrbuf{l} = '% Number of edges on West and East bounds'; l = l+1; if (max(strcmp(answers.TESTCASE, {'RTIN', 'DROP'})) == 1) usrbuf{l} = '% WARNING: it must be a multiple of 4 if PARAMETERS.MESH.TRIANGLE_ORIENTATION = ''DIAGONAL'', and a multiple of 2 else'; l = l+1; else usrbuf{l} = '% WARNING: it must be a multiple of 2'; l = l+1; end usrbuf{l} = '% {value 1, value 2, ...} set of values for NBSEG_Y for running the convergence analysis'; l = l+1; usrbuf{l} = sprintf('PARAMETERS.MESH.NBSEG_Y = {%d, %d, %d};', ny, 2*ny, 4*ny); l = l+1; usrbuf{l} = sprintf('% Warning: NBSEG_X and NBSEG_Y must have the same size'); l = l+1; case {'IN_TIME', 'IN_REYNOLDS', 'NONE'} % The use provides a single value for nx and ny usrbuf{l} = '% Number of edges on North and South bounds'; l = l+1; usrbuf{l} = '% WARNING: it must be a multiple of 2'; l = l+1; usrbuf{l} = sprintf('PARAMETERS.MESH.NBSEG_X = %d;', nx); l = l+1; usrbuf{l} = '% Number of edges on West and East bounds'; l = l+1; if (max(strcmp(answers.TESTCASE, {'RTIN', 'DROP'})) == 1) usrbuf{l} = '% WARNING: it must be a multiple of 4 if PARAMETERS.MESH.TRIANGLE_ORIENTATION = ''DIAGONAL'', and a multiple of 2 else'; l = l+1; else usrbuf{l} = '% WARNING: it must be a multiple of 2'; l = l+1; end usrbuf{l} = sprintf('PARAMETERS.MESH.NBSEG_Y = %d;', ny); l = l+1; otherwise error('Problem in build_meshbuf'); end case {'CIRCLE'} switch answers.TESTCASE case {'RTIN'} error('RTIN is not compatible with CIRCLE geometry'); case {'CAEN'} error('CAEN is not compatible with CIRCLE geometry'); case {'DROP'} error('DROP is not compatible with CIRCLE geometry'); case {'EXAC'} nc = 10; case {'EXACNEU'} nc = 10; case {'POIS'} error('POIS is not compatible with CIRCLE geometry'); case {'NONA'} error('NONA is not compatible with CIRCLE geometry'); otherwise error('Unknown test case'); end usrbuf{l} = '% Parameters for a NS2DDV mesh'; l = l+1; usrbuf{l} = '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'; l = l+1; switch answers.CV_STUDY case {'IN_SPACE', 'IN_SPACETIME'} % The use provides a list of values for nc usrbuf{l} = '% Number of edges along the radius'; l = l+1; usrbuf{l} = sprintf('PARAMETERS.MESH.NBSEG_C = {%d, %d, %d};', nc, 2*nc, 4*nc); l = l+1; case {'IN_TIME', 'IN_REYNOLDS', 'NONE'} % The use provides a single value for nc usrbuf{l} = '% Number of edges along the radius'; l = l+1; usrbuf{l} = sprintf('PARAMETERS.MESH.NBSEG_C = %d;', nc); l = l+1; otherwise error('Problem in build_meshbuf'); end case {'DIHEDRON'} switch answers.TESTCASE case {'RTIN'} error('RTIN is not compatible with DIHEDRON geometry'); case {'CAEN'} error('CAEN is not compatible with DIHEDRON geometry'); case {'DROP'} error('DROP is not compatible with DIHEDRON geometry'); case {'EXAC'} error('EXAC is not compatible with DIHEDRON geometry'); case {'EXACNEU'} error('EXACNEU is not compatible with DIHEDRON geometry'); case {'POIS'} error('POIS is not compatible with DIHEDRON geometry'); case {'GTPSI'} error('GTPSI is not compatible with DIHEDRON geometry'); case {'NONA'} height_bl = 0.2; nbnodes_inbl_y = 8; nbseg_perunit_x = 40; nbseg_outbl_y = 36; prog_geom_bl_y = 1.1; otherwise error('Unknown test case'); end usrbuf{l} = '% Parameters for a NS2DDV mesh'; l = l+1; usrbuf{l} = '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'; l = l+1; usrbuf{l} = '% Height of the boundary layer'; l = l+1; usrbuf{l} = sprintf('PARAMETERS.MESH.HEIGHT_BL = %g;', height_bl); l = l+1; switch answers.CV_STUDY case {'IN_SPACE', 'IN_SPACETIME'} % The use provides a list of values for nbseg_perunit_x, nbnodes_inbl_y usrbuf{l} = '% Number of edges by segment of length 1 in x-direction (even values recommended)'; l = l+1; usrbuf{l} = sprintf('PARAMETERS.MESH.NBSEG_PERUNIT_X = {%d, %d, %d};', ... nbseg_perunit_x, 2*nbseg_perunit_x, 4*nbseg_perunit_x); l = l+1; usrbuf{l} = '% Number of nodes in the boundary layer in y-direction'; l = l+1; usrbuf{l} = sprintf('PARAMETERS.MESH.NBNODES_INBL_Y = {%d, %d, %d};', ... nbnodes_inbl_y, 2*nbnodes_inbl_y, 4*nbnodes_inbl_y); l = l+1; case {'IN_TIME', 'IN_REYNOLDS', 'NONE'} % The use provides a single value for nbseg_perunit_x, nbnodes_inbl_y usrbuf{l} = '% Number of edges by segment of length 1 in x-direction (even value recommended)'; l = l+1; usrbuf{l} = sprintf('PARAMETERS.MESH.NBSEG_PERUNIT_X = %d;', nbseg_perunit_x); l = l+1; usrbuf{l} = '% Number of nodes in the boundary layer in y-direction'; l = l+1; usrbuf{l} = sprintf('PARAMETERS.MESH.NBNODES_INBL_Y = %d;', nbnodes_inbl_y); l = l+1; otherwise error('Problem in build_meshbuf'); end usrbuf{l} = '% Geometric reason of nodes repartition in the boundary layer in y-direction'; l = l+1; usrbuf{l} = sprintf('PARAMETERS.MESH.PROG_GEOM_BL_Y = %g;', prog_geom_bl_y); l = l+1; switch answers.CV_STUDY case {'IN_SPACE', 'IN_SPACETIME'} % The use provides a list of values for nbseg_outbl_y usrbuf{l} = '% Number of edges out of the boundary layer in y-direction'; l = l+1; usrbuf{l} = sprintf('PARAMETERS.MESH.NBSEG_OUTBL_Y = {%d, %d, %d};', ... nbseg_outbl_y, 2*nbseg_outbl_y, 4*nbseg_outbl_y); l = l+1; case {'IN_TIME', 'IN_REYNOLDS', 'NONE'} % The use provides a single value for nbseg_outbl_y usrbuf{l} = '% Number of edges out of the boundary layer in y-direction'; l = l+1; usrbuf{l} = sprintf('PARAMETERS.MESH.NBSEG_OUTBL_Y = %d;', nbseg_outbl_y); l = l+1; otherwise error('Problem in build_meshbuf'); end usrbuf{l} = '% Design of structured mesh (''DIAGONAL'' or ''CROSS'')'; l = l+1; usrbuf{l} = 'PARAMETERS.MESH.TRIANGLES_ORIENTATION = ''CROSS'';'; l = l+1; case {'STEP'} case {'FROM_FILE'} otherwise error('Problem in build_meshbuf'); end % Add PDET parameters if answers.PDET switch answers.TESTCASE case {'RTIN'} h0 = 0.1; case {'CAEN'} h0 = 0.1; case {'DROP'} h0 = 0.1; case {'EXAC'} h0 = 0.1; case {'EXACNEU'} h0 = 0.1; case {'POIS'} switch answers.GEOM case {'RECTANGLE'} h0 = 0.001; case {'STEP'} h0 = 0.1; otherwise error('POIS test case is compatible only with RECTANGLE or STEP geometries'); end case {'NONA'} h0 = 0.2; case {'GTPSI'} h0 = 0.1; otherwise error('Unknown test case'); end usrbuf{l} = '% Parameters for a PDET mesh'; l = l+1; usrbuf{l} = '%%%%%%%%%%%%%%%%%%%%%%%%%%%%'; l = l+1; switch answers.CV_STUDY case {'IN_SPACE', 'IN_SPACETIME'} % The use provides a list of values for h0 usrbuf{l} = '% Characteristic edge length in the mesh'; l = l+1; usrbuf{l} = '% {value 1, value 2, ...} set of values for H0 for running the convergence analysis'; l = l+1; usrbuf{l} = sprintf('PARAMETERS.MESH.H0 = {%g, %g, %g};', h0, 0.5*h0, 0.25*h0); l = l+1; case {'IN_TIME', 'IN_REYNOLDS', 'NONE'} % The use provides a single value for h0 usrbuf{l} = '% Characteristic edge length in the mesh'; l = l+1; usrbuf{l} = sprintf('PARAMETERS.MESH.H0 = %g;', h0); l = l+1; otherwise error('Problem in build_meshbuf'); end end % Add parameters for external mesh usrbuf{l} = '% Parameters for a FROM_FILE mesh'; l = l+1; usrbuf{l} = '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'; l = l+1; usrbuf{l} = '% Mesh source file(s) : .msh or _p1/_t1 format allowed'; l = l+1; usrbuf{l} = '% {''xxxx.msh''} cell array of size 1 for .msh format'; l = l+1; usrbuf{l} = '% {''xxxx_p1'', ''xxxx_t1''} cell array of size 2 for _p1/_t1 format'; l = l+1; usrbuf{l} = 'PARAMETERS.MESH.SRC_FILES = {};'; l = l+1; usrbuf{l} = '% Rescale the mesh to fit with the domain geometry above (''YES'' or ''NO'')'; l = l+1; usrbuf{l} = 'PARAMETERS.MESH.RESCALE = ''NO'';'; l = l+1; end