build_outputbuf.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_outputbuf(answers)
usrbuf = {};
l = 1;
% Visualization parameters
%%%%%%%%%%%%%%%%%%%%%%%%%%
usrbuf{l} = '';
l = l+1;
usrbuf{l} = '% Visualization parameters';
l = l+1;
usrbuf{l} = '%%%%%%%%%%%%%%%%%%%%%%%%%%';
l = l+1;
usrbuf{l} = '% Display 2D results in a Matlab graphical window :';
l = l+1;
usrbuf{l} = '% ''SINGLE_FIGURE'' All graphical outputs in a unique figure';
l = l+1;
usrbuf{l} = '% ''MULTIPLE_FIGURE'' One graphical output per figure, stable';
l = l+1;
usrbuf{l} = '% ''NONE'' No graphical output';
l = l+1;
if ~strcmp(answers.CV_STUDY, 'NONE')
usrbuf{l} = 'PARAMETERS.OUTPUT.XDISPLAY = ''NONE'';';
l = l+1;
else
usrbuf{l} = 'PARAMETERS.OUTPUT.XDISPLAY = ''SINGLE_FIGURE'';';
l = l+1;
end
usrbuf{l} = '% Refreshing frequency for 2D graphical display (default = 1)';
l = l+1;
usrbuf{l} = 'PARAMETERS.OUTPUT.XDISPLAY_FREQUENCY = 1;';
l = l+1;
usrbuf{l} = '% List of 2D results to be plotted :';
l = l+1;
usrbuf{l} = '% ''MESH'' The P1 mesh';
l = l+1;
usrbuf{l} = '% ''SUBTRI_U'' The subtriangulation for velocity (either P2 or P1B)';
l = l+1;
if strcmp(answers.MODEL, {'NSDV'})
usrbuf{l} = '% ''RHO'' The density isovalues';
l = l+1;
if (max(strcmp(answers.TESTCASE, answers.ANALYTIC_TESTCASES)) == 1)
% It is possible to plot the exact solution
usrbuf{l} = '% ''RHO_EX'' The exact density isovalues';
l = l+1;
end
end
usrbuf{l} = '% ''U_VECTOR'' The velocity vector field';
l = l+1;
if (max(strcmp(answers.TESTCASE, answers.ANALYTIC_TESTCASES)) == 1)
% It is possible to plot the exact solution
usrbuf{l} = '% ''U_VECTOR_EX'' The exact velocity vector field';
l = l+1;
end
usrbuf{l} = '% ''UX'' The isovalues of the x-component of velocity';
l = l+1;
if (max(strcmp(answers.TESTCASE, answers.ANALYTIC_TESTCASES)) == 1)
% It is possible to plot the exact solution
usrbuf{l} = '% ''UX_EX'' The isovalues of the x-component of exact velocity';
l = l+1;
end
usrbuf{l} = '% ''UY'' The isovalues of the y-component of velocity';
l = l+1;
if (max(strcmp(answers.TESTCASE, answers.ANALYTIC_TESTCASES)) == 1)
% It is possible to plot the exact solution
usrbuf{l} = '% ''UY_EX'' The isovalues of the y-component of exact velocity';
l = l+1;
end
usrbuf{l} = '% ''UX_DX'' The isovalues of the x-derivative of the x-component of velocity';
l = l+1;
if (max(strcmp(answers.TESTCASE, answers.ANALYTIC_TESTCASES)) == 1)
% It is possible to plot the exact solution
usrbuf{l} = '% ''UX_DX_EX'' The isovalues of the x-derivative of the x-component of exact velocity';
l = l+1;
end
usrbuf{l} = '% ''UX_DY'' The isovalues of the y-derivative of the x-component of velocity';
l = l+1;
if (max(strcmp(answers.TESTCASE, answers.ANALYTIC_TESTCASES)) == 1)
% It is possible to plot the exact solution
usrbuf{l} = '% ''UX_DY_EX'' The isovalues of the y-derivative of the x-component of exact velocity';
l = l+1;
end
usrbuf{l} = '% ''UY_DX'' The isovalues of the x-derivative of the y-component of velocity';
l = l+1;
if (max(strcmp(answers.TESTCASE, answers.ANALYTIC_TESTCASES)) == 1)
% It is possible to plot the exact solution
usrbuf{l} = '% ''UY_DX_EX'' The isovalues of the x-derivative of the y-component of exact velocity';
l = l+1;
end
usrbuf{l} = '% ''UY_DY'' The isovalues of the y-derivative of the y-component of velocity';
l = l+1;
if (max(strcmp(answers.TESTCASE, answers.ANALYTIC_TESTCASES)) == 1)
% It is possible to plot the exact solution
usrbuf{l} = '% ''UY_DY_EX'' The isovalues of the y-derivative of the y-component of exact velocity';
l = l+1;
end
usrbuf{l} = '% ''SHEAR'' The isovalues of the shear rate';
l = l+1;
if (max(strcmp(answers.TESTCASE, answers.ANALYTIC_TESTCASES)) == 1)
% It is possible to plot the exact solution
usrbuf{l} = '% ''SHEAR_EX'' The isovalues of the exact shear rate';
l = l+1;
end
usrbuf{l} = '% ''U_MODULE'' The velocity magnitude isovalues';
l = l+1;
if (max(strcmp(answers.TESTCASE, answers.ANALYTIC_TESTCASES)) == 1)
% It is possible to plot the exact solution
usrbuf{l} = '% ''U_MODULE_EX'' The exact velocity magnitude isovalues';
l = l+1;
end
usrbuf{l} = '% ''VORTIC'' The vorticity isovalues';
l = l+1;
if (max(strcmp(answers.TESTCASE, answers.ANALYTIC_TESTCASES)) == 1)
% It is possible to plot the exact solution
usrbuf{l} = '% ''VORTIC_EX'' The exact vorticity isovalues';
l = l+1;
end
usrbuf{l} = '% ''STREAM'' The velocity streamlines';
l = l+1;
if (max(strcmp(answers.TESTCASE, answers.ANALYTIC_TESTCASES)) == 1)
% It is possible to plot the exact solution
usrbuf{l} = '% ''STREAM_EX'' The exact velocity streamlines';
l = l+1;
end
usrbuf{l} = '% ''P'' The pressure isovalues';
l = l+1;
if (max(strcmp(answers.TESTCASE, answers.ANALYTIC_TESTCASES)) == 1)
% It is possible to plot the exact solution
usrbuf{l} = '% ''P_EX'' The exact pressure isovalues';
l = l+1;
end
usrbuf{l} = '% ''GRAD_P'' The pressure gradient';
l = l+1;
usrbuf{l} = '% ''P_DX'' The isovalues of the x-derivative of pressure';
l = l+1;
usrbuf{l} = '% ''P_DY'' The isovalues of the y-derivative of pressure';
l = l+1;
if (max(strcmp(answers.TESTCASE, answers.ANALYTIC_TESTCASES)) == 1)
% It is possible to plot the exact solution
usrbuf{l} = '% ''GRAD_P_EX'' The exact pressure gradient';
l = l+1;
usrbuf{l} = '% ''P_DX'' The isovalues of the x-derivative of exact pressure';
l = l+1;
usrbuf{l} = '% ''P_DY'' The isovalues of the y-derivative of exact pressure';
l = l+1;
end
if max(strcmp(answers.TESTCASE, {'NONA', 'POIS', 'GTPSI'}))
usrbuf{l} = '% ''W_VECTOR'' The auxiliary Stokes velocity vector field (only for NATURAL boundary conditions)';
l = l+1;
usrbuf{l} = '% ''WX'' The isovalues of the x-component of the auxiliary Stokes velocity (only for NATURAL boundary conditions)';
l = l+1;
usrbuf{l} = '% ''WY'' The isovalues of the y-component of the auxiliary Stokes velocity (only for NATURAL boundary conditions)';
l = l+1;
usrbuf{l} = '% ''R'' The auxiliary Stokes pressure isovalues (only for NATURAL boundary conditions)';
l = l+1;
end
switch answers.MODEL
case {'NSDV'}
switch answers.TESTCASE
case {'RTIN','DROP'}
usrbuf{l} = 'PARAMETERS.OUTPUT.XDISPLAY_LIST = {''MESH'', ''RHO'', ''U_VECTOR''};';
l = l+1;
case {'CAEN'}
usrbuf{l} = 'PARAMETERS.OUTPUT.XDISPLAY_LIST = {''MESH'', ''VORTIC'', ''STREAM'', ''U_MODULE''};';
l = l+1;
case {'EXAC'}
usrbuf{l} = 'PARAMETERS.OUTPUT.XDISPLAY_LIST = {''MESH'', ''RHO'', ''U_VECTOR''};';
l = l+1;
case {'EXACNEU'}
usrbuf{l} = 'PARAMETERS.OUTPUT.XDISPLAY_LIST = {''MESH'', ''RHO'', ''U_VECTOR''};';
l = l+1;
otherwise
error(sprintf('Unknown test case\n'));
end
case {'NS'}
switch answers.TESTCASE
case {'CAEN', 'NONA'}
usrbuf{l} = 'PARAMETERS.OUTPUT.XDISPLAY_LIST = {''MESH'', ''VORTIC'', ''STREAM'', ''U_MODULE''};';
l = l+1;
case {'POIS'}
usrbuf{l} = 'PARAMETERS.OUTPUT.XDISPLAY_LIST = {''MESH'', ''U_VECTOR'', ''P''};';
l = l+1;
case {'EXAC', 'EXACNEU'}
usrbuf{l} = 'PARAMETERS.OUTPUT.XDISPLAY_LIST = {''MESH'', ''U_VECTOR''};';
l = l+1;
case {'GTPSI'}
usrbuf{l} = 'PARAMETERS.OUTPUT.XDISPLAY_LIST = {''MESH'', ''VORTIC'', ''STREAM'', ''UX'', ''UY''};';
l = l+1;
otherwise
error(sprintf('Unknown test case\n'));
end
otherwise
error(sprintf('Unknown model\n'));
end
% Output parameters
%%%%%%%%%%%%%%%%%%%
usrbuf{l} = '';
l = l+1;
usrbuf{l} = '% Output parameters';
l = l+1;
usrbuf{l} = '%%%%%%%%%%%%%%%%%%%';
l = l+1;
usrbuf{l} = '% Directory for numerical results';
l = l+1;
usrbuf{l} = 'PARAMETERS.OUTPUT.DIRECTORY_NAME = ''./RESULTS'';';
l = l+1;
usrbuf{l} = '% Name of output file(s)';
l = l+1;
usrbuf{l} = 'PARAMETERS.OUTPUT.FILE_NAME = ''diags'';';
l = l+1;
usrbuf{l} = '% Save method of these results :';
l = l+1;
usrbuf{l} = '% ''LAST_FRAME'' The solution is only saved at final time';
l = l+1;
usrbuf{l} = '% ''ANIMATION'' If time dynamics is considered, an animated result is saved';
l = l+1;
usrbuf{l} = '% ''NONE'' Only the log file is saved';
l = l+1;
if ~strcmp(answers.CV_STUDY, 'NONE')
usrbuf{l} = 'PARAMETERS.OUTPUT.XDISPLAY_SAVE = ''NONE'';';
l = l+1;
else
usrbuf{l} = 'PARAMETERS.OUTPUT.XDISPLAY_SAVE = ''ANIMATION'';';
l = l+1;
end
usrbuf{l} = '% Refreshing frequency for save 2D results (default = 1)';
l = l+1;
usrbuf{l} = 'PARAMETERS.OUTPUT.XDISPLAY_SAVE_FREQUENCY = 1;';
l = l+1;
usrbuf{l} = '% List of optional diagnostics';
l = l+1;
if strcmp(answers.MODEL, {'NS'})
if (max(strcmp(answers.TESTCASE, answers.ANALYTIC_TESTCASES)) == 1)
usrbuf{l} = '% ''U_VECTOR_EX'' exact velocity';
l = l+1;
usrbuf{l} = '% ''P_EX'' exact pressure';
l = l+1;
usrbuf{l} = '% ''VORTIC_EX'' exact vorticity';
l = l+1;
usrbuf{l} = '% ''STREAM_EX'' exact streamlines';
l = l+1;
usrbuf{l} = '% ''U_MODULE_EX'' exact velocity magnitude';
l = l+1;
end
usrbuf{l} = '% ''UX_DX'' x-derivative of x-component of velocity';
l = l+1;
usrbuf{l} = '% ''UX_DY'' y-derivative of x-component of velocity';
l = l+1;
usrbuf{l} = '% ''UY_DX'' x-derivative of y-component of velocity';
l = l+1;
usrbuf{l} = '% ''UY_DY'' y-derivative of y-component of velocity';
l = l+1;
usrbuf{l} = '% ''SHEAR'' shear rate';
l = l+1;
usrbuf{l} = '% ''GRAD_P'' Pressure gradient';
l = l+1;
usrbuf{l} = '% ''P_DX'' x-derivative of the pressure';
l = l+1;
usrbuf{l} = '% ''P_DY'' y-derivative of the pressure';
l = l+1;
if (max(strcmp(answers.TESTCASE, answers.ANALYTIC_TESTCASES)) == 1)
usrbuf{l} = '% ''UX_DX_EX'' x-derivative of x-component of exact velocity';
l = l+1;
usrbuf{l} = '% ''UX_DY_EX'' y-derivative of x-component of exact velocity';
l = l+1;
usrbuf{l} = '% ''UY_DX_EX'' x-derivative of y-component of exact velocity';
l = l+1;
usrbuf{l} = '% ''UY_DY_EX'' y-derivative of y-component of exact velocity';
l = l+1;
usrbuf{l} = '% ''SHEAR_EX'' exact shear rate';
l = l+1;
usrbuf{l} = '% ''GRAD_P_EX'' exact pressure gradient';
l = l+1;
usrbuf{l} = '% ''P_DX_EX'' x-derivative of the exact pressure';
l = l+1;
usrbuf{l} = '% ''P_DY_EX'' y-derivative of the exact pressure';
l = l+1;
end
if max(strcmp(answers.TESTCASE, {'NONA', 'POIS', 'GTPSI'}))
usrbuf{l} = '% ''W_VECTOR'' Auxiliary Stokes velocity (only for NATURAL boundary conditions)';
l = l+1;
usrbuf{l} = '% ''R'' Auxiliary Stokes pressure (only for NATURAL boundary conditions)';
l = l+1;
end
end
if strcmp(answers.MODEL, {'NSDV'})
if (max(strcmp(answers.TESTCASE, answers.ANALYTIC_TESTCASES)) == 1)
usrbuf{l} = '% ''U_VECTOR_EX'' exact velocity';
l = l+1;
usrbuf{l} = '% ''P_EX'' exact pressure';
l = l+1;
usrbuf{l} = '% ''VORTIC_EX'' exact vorticity';
l = l+1;
usrbuf{l} = '% ''STREAM_EX'' exact streamlines';
l = l+1;
usrbuf{l} = '% ''U_MODULE_EX'' exact velocity magnitude';
l = l+1;
usrbuf{l} = '% ''RHO_EX'' exact density';
l = l+1;
end
usrbuf{l} = '% ''UX_DX'' x-derivative of x-component of velocity';
l = l+1;
usrbuf{l} = '% ''UX_DY'' y-derivative of x-component of velocity';
l = l+1;
usrbuf{l} = '% ''UY_DX'' x-derivative of y-component of velocity';
l = l+1;
usrbuf{l} = '% ''UY_DY'' y-derivative of y-component of velocity';
l = l+1;
usrbuf{l} = '% ''SHEAR'' shear rate';
l = l+1;
usrbuf{l} = '% ''GRAD_P'' Pressure gradient';
l = l+1;
usrbuf{l} = '% ''P_DX'' x-derivative of the pressure';
l = l+1;
usrbuf{l} = '% ''P_DY'' y-derivative of the pressure';
l = l+1;
if (max(strcmp(answers.TESTCASE, answers.ANALYTIC_TESTCASES)) == 1)
usrbuf{l} = '% ''UX_DX_EX'' x-derivative of x-component of exact velocity';
l = l+1;
usrbuf{l} = '% ''UX_DY_EX'' y-derivative of x-component of exact velocity';
l = l+1;
usrbuf{l} = '% ''UY_DX_EX'' x-derivative of y-component of exact velocity';
l = l+1;
usrbuf{l} = '% ''UY_DY_EX'' y-derivative of y-component of exact velocity';
l = l+1;
usrbuf{l} = '% ''SHEAR_EX'' exact shear rate';
l = l+1;
usrbuf{l} = '% ''GRAD_P_EX'' exact pressure gradient';
l = l+1;
usrbuf{l} = '% ''P_DX_EX'' x-derivative of the exact pressure';
l = l+1;
usrbuf{l} = '% ''P_DY_EX'' y-derivative of the exact pressure';
l = l+1;
end
end
usrbuf{l} = 'PARAMETERS.OUTPUT.XDISPLAY_SAVE_OPTDIAGS = {};';
l = l+1;
% Backup parameters
%%%%%%%%%%%%%%%%%%%
usrbuf{l} = '';
l = l+1;
usrbuf{l} = '% Backup parameters';
l = l+1;
usrbuf{l} = '%%%%%%%%%%%%%%%%%%%';
l = l+1;
usrbuf{l} = '% Number of backup files (default = 1)';
l = l+1;
usrbuf{l} = '% Each backup file contains the required data to restart the code after a critical crash';
l = l+1;
usrbuf{l} = 'PARAMETERS.BACKUP.NB_FILES = 1;';
l = l+1;
usrbuf{l} = '% Backup frequency (default = 10)';
l = l+1;
usrbuf{l} = 'PARAMETERS.BACKUP.FREQUENCY = 10;';
l = l+1;
usrbuf{l} = '% Backup file location';
l = l+1;
usrbuf{l} = 'PARAMETERS.BACKUP.DIRECTORY_NAME = ''./BACKUP'';';
l = l+1;
end