%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 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[] = generate_setup_file(namefile) % INPUT % namefile Name of the setup file used for the simulation load_paths(); % Test if the required toolboxes are available %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% A = ver(); res.PCT = 0; res.PDET = 0; for i=1:numel(A) if strcmp(A(i).Name, 'Parallel Computing Toolbox') res.PCT = 1; end if strcmp(A(i).Name, 'Partial Differential Equation Toolbox') res.PDET = 1; end end res.AMD = ~(exist('amd') == 0); res.CMK = ~(exist('symrcm') == 0); % Choice of cluster profile %%%%%%%%%%%%%%%%%%%%%%%%%%% disp(sprintf('\nChoose a pre-defined cluster profile (if you do not know, select ''LOCAL''')); addlocal = sprintf('''LOCAL'' Default cluster profile (works on most configurations)'); addzeus = sprintf('''ZEUS'' Lille 1 HPC center cluster profile'); addmathcalc = sprintf('''MATHCALC'' Lab. Paul Painlevé cluster profile'); disp(addlocal) disp(addzeus) disp(addmathcalc) res.ALL_CLUSTER = {'LOCAL', 'ZEUS', 'MATHCALC'}; while 1 res.CLUSTER = input(sprintf('Your choice : ')); if (max(strcmp(res.CLUSTER, res.ALL_CLUSTER)) == 1) break; end end if strcmp(res.CLUSTER, {'ZEUS', 'MATHCALC'}) res.PDET = 1; res.PCT = 1; end % Choice of the model %%%%%%%%%%%%%%%%%%%%% disp(sprintf('\nSelect a model :')); disp('''NSDV'' 2D incompressible Navier-Stokes system with variable density'); disp('''NS'' 2D incompressible Navier-Stokes system'); while 1 res.MODEL = input(sprintf('Your choice : ')); if (max(strcmp(res.MODEL, {'NSDV', 'NS'})) == 1) break; end end % Choice of the test case %%%%%%%%%%%%%%%%%%%%%%%%% message = sprintf('\nSelect a test case :'); % Common test cases addcaen = sprintf('''CAEN'' Lid-driven cavity'); addexac = sprintf('''EXAC'' Analytic solution with divergence-free velocity'); addrtin = sprintf('''RTIN'' Rayleigh-Taylor instability'); adddrop = sprintf('''DROP'' Falling droplet'); addnona = sprintf('''NONA'' Non-analytic solution'); addpois = sprintf('''POIS'' Poiseuille flow'); addexacneu = sprintf('''EXACNEU'' Analytic solution with divergence-free velocity and mixed boundary conditions'); addgtpsi = sprintf('''GTPSI'' Translate a localized gaussian vorticity'); switch res.MODEL case {'NSDV'} message = sprintf('%s\n%s\n%s\n%s\n%s\n%s', message, addcaen, addexac, addrtin, adddrop, addexacneu); res.ALL_TESTCASES = {'RTIN', 'DROP', 'CAEN', 'EXAC', 'EXACNEU'}; res.ANALYTIC_TESTCASES = {'EXAC', 'EXACNEU'}; case {'NS'} message = sprintf('%s\n%s\n%s\n%s\n%s\n%s\n%s', message, addcaen, addexac, addnona, addpois, ... addexacneu, addgtpsi); res.ALL_TESTCASES = {'NONA', 'CAEN', 'EXAC', 'POIS', 'EXACNEU', 'GTPSI'}; res.ANALYTIC_TESTCASES = {'EXAC', 'EXACNEU'}; otherwise error(sprintf('Problem in generate_manual_setup.m: a model is missing\n')); end if (numel(res.ALL_TESTCASES) > 1) disp(message) while 1 res.TESTCASE = input(sprintf('Your choice : ')); if (max(strcmp(res.TESTCASE, res.ALL_TESTCASES)) == 1) break; end end elseif (numel(res.ALL_TESTCASES) == 1) res.TESTCASE = res.ALL_TESTCASES{1}; fprintf('\nDefault test case: %s\n', res.TESTCASE); else error(sprintf('No test case provided for the model %s. Please correct the file generate_setup_file.m', res.MODEL)); end % According to the chosen test case, allow the access to the convergence parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% addspace = sprintf('''IN_SPACE'' Convergence analysis according to the space step only'); addtime = sprintf('''IN_TIME'' Convergence analysis according to the time step only'); addspacetime = sprintf('''IN_SPACETIME'' Convergence analysis according to both space and time steps'); addReynolds = sprintf('''IN_REYNOLDS'' Stability analysis according to the Reynolds number'); addnone = sprintf('''NONE'' No stability/convergence analysis, run a simple simulation'); if (max(strcmp(res.TESTCASE, res.ANALYTIC_TESTCASES)) == 1) message = sprintf('\nDo you want to run a convergence or stability analysis ?'); message = sprintf('%s\n%s\n%s\n%s\n%s\n%s', message, addspace, addtime, addspacetime, addReynolds, addnone); res.ALL_CV_STUDY = {'IN_SPACE', 'IN_TIME', 'IN_SPACETIME', 'IN_REYNOLDS', 'NONE'}; else message = sprintf('\nDo you want to run a stability analysis ?'); message = sprintf('%s\n%s\n%s', message, addnone); res.ALL_CV_STUDY = {'NONE'}; end if (numel(res.ALL_CV_STUDY) > 1) disp(message) while 1 res.CV_STUDY = input(sprintf('Your choice : ')); if (max(strcmp(res.CV_STUDY, res.ALL_CV_STUDY)) == 1) break; end end elseif (numel(res.ALL_CV_STUDY) == 1) res.CV_STUDY = res.ALL_CV_STUDY{1}; fprintf('\nDefault convergence/stability analysis: %s\n', res.CV_STUDY); else error(sprintf('No convergence/stability analysis provided for the test case %s. Please correct the file generate_setup_file.m', res.TESTCASE)); end % Choice of a domain geometry %%%%%%%%%%%%%%%%%%%%%%%%%%%%% message = sprintf('\nChoose a domain geometry :'); addcircle = sprintf('''CIRCLE'' Use a pre-built circular geometry description'); addrectangle = sprintf('''RECTANGLE'' Use a pre-built rectangular geometry description'); addfromfile = sprintf('''FROM_FILE'' Load data from a Matlab geometry description (.m format)'); adddihedron = sprintf('''DIHEDRON'' Use a pre-built diedral geometry description'); addstep = sprintf('''STEP'' Use a pre-built step geometry description'); switch res.MODEL case {'NSDV'} switch res.TESTCASE case {'RTIN'} message = sprintf('%s\n%s', message, addrectangle); res.ALL_GEOM = {'RECTANGLE'}; case {'DROP'} message = sprintf('%s\n%s', message, addrectangle); res.ALL_GEOM = {'RECTANGLE'}; case {'CAEN'} message = sprintf('%s\n%s', message, addrectangle); res.ALL_GEOM = {'RECTANGLE'}; case {'EXAC'} message = sprintf('%s\n%s', message, addrectangle); res.ALL_GEOM = {'RECTANGLE'}; case {'EXACNEU'} message = sprintf('%s\n%s', message, addrectangle); res.ALL_GEOM = {'RECTANGLE'}; otherwise error(sprintf('Problem in generate_manual_setup.m: a test case is missing\n')); end case {'NS'} switch res.TESTCASE case {'NONA'} message = sprintf('%s\n%s\n%s\n%s', message, addrectangle, adddihedron, addstep); res.ALL_GEOM = {'RECTANGLE', 'DIHEDRON', 'STEP'}; case {'CAEN'} message = sprintf('%s\n%s', message, addrectangle); res.ALL_GEOM = {'RECTANGLE'}; case {'EXAC'} message = sprintf('%s\n%s', message, addrectangle); res.ALL_GEOM = {'RECTANGLE'}; case {'POIS'} message = sprintf('%s\n%s\n%s', message, addrectangle, addstep); res.ALL_GEOM = {'RECTANGLE', 'STEP'}; case {'EXACNEU'} message = sprintf('%s\n%s', message, addrectangle); res.ALL_GEOM = {'RECTANGLE'}; case {'GTPSI'} message = sprintf('%s\n%s', message, addrectangle); res.ALL_GEOM = {'RECTANGLE'}; otherwise error(sprintf('Problem in generate_setup_file.m: the test case %s is missing\n', res.TESTCASE)); end otherwise error(sprintf('Problem in generate_setup_file.m: the model %s is missing\n', res.MODEL)); end if (numel(res.ALL_GEOM) > 1) disp(message) while 1 res.GEOM = input(sprintf('Your choice : ')); if (max(strcmp(res.GEOM, res.ALL_GEOM)) == 1) break; end end elseif (numel(res.ALL_GEOM) == 1) res.GEOM = res.ALL_GEOM{1}; fprintf('\nDefault geometry : %s\n', res.GEOM); else error(sprintf('No geometry provided from the model %s and test case %s. Please correct the file generate_setup_file.m', res.MODEL, res.TESTCASE)); end % Finite Volume Method parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% switch res.MODEL case {'NSDV'} message = sprintf('\nChoose a Finite Volume method for discretizing the mass conservation equation :'); addmuscl = sprintf('''MUSCL'' MUSCL scheme'); addrdn = sprintf('''RDN'' Residual distribution scheme, N-scheme variant (not implemented)'); addrdlda = sprintf('''RDLDA'' Residual distribution scheme, LDA-scheme variant (not implemented)'); addrdpsi = sprintf('''RDPSI'' Residual distribution scheme, PSI-scheme variant (not implemented)'); message = sprintf('%s\n%s', message, addmuscl); res.ALL_FV = {'MUSCL'}; if (numel(res.ALL_FV) > 1) disp(message) while 1 res.FV = input(sprintf('Your choice : ')); if (max(strcmp(res.FV, res.ALL_FV)) == 1) break; end end elseif (numel(res.ALL_FV) == 1) res.FV = res.ALL_FV{1}; fprintf('\nDefault Finite Volume method: %s\n', res.FV); else error(sprintf('No Finite Volume method provided from the model %s. Please correct the file generate_setup_file.m', res.MODEL)); end case {'NS'} otherwise error(sprintf('Problem in generate_manual_setup.m: a model is missing\n')); end % Parallelization parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%% message = sprintf('\nChoose a parallelization toolbox :'); addserial = sprintf('''SERIAL'' No parallelization'); addpct = sprintf('''PCT'' Matlab Parallel Computing Toolbox'); if res.PCT message = sprintf('%s\n%s\n%s', message, addpct, addserial); res.ALL_PARALLEL = {'SERIAL', 'PCT'}; else message = sprintf('%s\n%s', message, addserial); res.ALL_PARALLEL = {'SERIAL'}; end if (numel(res.ALL_PARALLEL) > 1) disp(message) while 1 res.PARALLEL = input(sprintf('Your choice : ')); if (max(strcmp(res.PARALLEL, res.ALL_PARALLEL)) == 1) break; end end elseif (numel(res.ALL_PARALLEL) == 1) res.PARALLEL = res.ALL_PARALLEL{1}; fprintf('\nDefault parallelization toolbox: %s\n', res.PARALLEL); else error(sprintf('No parallelization toolbox. Please correct the file generate_setup_file.m')); end fixbuf = build_fixbuf(res); usrbuf = {}; tempbuf = build_domainbuf(res); usrbuf = {usrbuf{:}, tempbuf{:}}; tempbuf = build_physicalbuf(res); usrbuf = {usrbuf{:}, tempbuf{:}}; tempbuf = build_initbuf(res); usrbuf = {usrbuf{:}, tempbuf{:}}; tempbuf = build_meshbuf(res); usrbuf = {usrbuf{:}, tempbuf{:}}; tempbuf = build_FEBCbuf(res); usrbuf = {usrbuf{:}, tempbuf{:}}; tempbuf = build_FEbuf(res); usrbuf = {usrbuf{:}, tempbuf{:}}; tempbuf = build_dtFEbuf(res); usrbuf = {usrbuf{:}, tempbuf{:}}; tempbuf = build_FVbuf(res); usrbuf = {usrbuf{:}, tempbuf{:}}; tempbuf = build_parallelbuf(res); usrbuf = {usrbuf{:}, tempbuf{:}}; tempbuf = build_outputbuf(res); usrbuf = {usrbuf{:}, tempbuf{:}}; if strcmp(namefile(numel(namefile)-1:numel(namefile)), '.m') newnamefile = namefile; else newnamefile = strcat(namefile, '.m'); end fid = fopen(newnamefile, 'w'); for i=1:numel(fixbuf) fprintf(fid, '%s\n', fixbuf{i}); end for i=1:numel(usrbuf) fprintf(fid, '%s\n', usrbuf{i}); end fclose(fid); end