clc; clear;

format_spec = '%0.15f';
directory_string = 'generace_dat/';

Globals1D;
N_faces = 2;
%N_fp = 1;

Problem;
mesh_size_parametr = (R_x - L_x) / size(E,2);
mesh_size_parameter_string = sprintf('%0.3f',mesh_size_parametr);
mesh_size_parameter_string = strrep(mesh_size_parameter_string,'.',',');

filename = sprintf('P_for_h=%s.txt',mesh_size_parameter_string);
filename = [directory_string,filename];
MatrixToTextFile(P,filename,format_spec,' ');
filename = sprintf('E_for_h=%s.txt',mesh_size_parameter_string);
filename = [directory_string,filename];
MatrixToTextFile(E,filename,'%d',' ');

StartUp1D_generace_dat;

filename = sprintf('EtoE_for_h=%s.txt',mesh_size_parameter_string);
filename = [directory_string,filename];
MatrixToTextFile(EtoE,filename,'%d',' ');
filename = sprintf('EtoF_for_h=%s.txt',mesh_size_parameter_string);
filename = [directory_string,filename];
MatrixToTextFile(EtoF,filename,'%d',' ');

%filename = 'advection_parameters.txt';
%filename = [directory_string,filename];
%MatrixToTextFile(a_advec,filename,format_spec,' ');
%
%N_vect = 1:8;
%n = length(N_vect);
%
%for i = 1:n
%    N = N_vect(i);
%    N_p = N + 1;
%    
%    
%    StartUp1D_generace_dat;
%    
%    filename = sprintf('x_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(x,filename,format_spec,' ');
%    
%    filename = sprintf('r_x_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(r_x,filename,format_spec,' ');
%    
%    filename = sprintf('J_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(J,filename,format_spec,' ');
%    
%    filename = sprintf('Fx_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(Fx,filename,format_spec,' ');
%    
%    filename = sprintf('n_x_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(n_x,filename,format_spec,' ');
%    
%    filename = sprintf('Fscale_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(Fscale,filename,format_spec,' ');
%    
%    filename = sprintf('EtoE_for_h=%s.txt',mesh_size_parameter_string);
%    filename = [directory_string,filename];
%    MatrixToTextFile(EtoE,filename,'%d',' ');
%    filename = sprintf('EtoF_for_h=%s.txt',mesh_size_parameter_string);
%    filename = [directory_string,filename];
%    MatrixToTextFile(EtoF,filename,'%d',' ');
%    
%    filename = sprintf('vmapM_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(vmapM,filename,'%d',' ');
%    filename = sprintf('vmapP_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(vmapP,filename,'%d',' ');
%    filename = sprintf('mapB_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(mapB,filename,'%d',' ');
%    filename = sprintf('vmapB_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(vmapB,filename,'%d',' ');
%    
%    [mapI, vmapI, mapO, vmapO] = BuildBCMaps();
%    
%    filename = sprintf('mapI_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(mapI,filename,'%d',' ');
%    filename = sprintf('vmapI_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(vmapI,filename,'%d',' ');
%    filename = sprintf('mapO_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(mapO,filename,'%d',' ');
%    filename = sprintf('vmapO_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(vmapO,filename,'%d',' ');
%    
%    CLF = 0.75; dt = (CLF / abs(a_advec)) * min(abs(x(1,:) - x(2,:)));
%    N_steps = ceil(T / dt); dt = T / N_steps;
%    
%    filename = sprintf('time_discretization_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile([T; dt; N_steps],filename,format_spec,' ');
%end