clc; clear;

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

Globals3D;
N_faces = 4;

Problem;
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',' ');

StartUp3D_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; b_advec; c_advec],filename,format_spec,' ');
%
%N_vect = 4:4;
%n = length(N_vect);
%
%for i = 1:n
%    N = N_vect(i);
%    N_p = ((N + 3) * (N + 2) * (N + 1)) / 6;
%    N_fp = ((N + 2) * (N + 1)) / 2;
%    
%    StartUp3D_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('y_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(y,filename,format_spec,' ');
%    filename = sprintf('z_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(z,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('r_y_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(r_y,filename,format_spec,' ');
%    filename = sprintf('r_z_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(r_z,filename,format_spec,' ');
%    filename = sprintf('s_x_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(s_x,filename,format_spec,' ');
%    filename = sprintf('s_y_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(s_y,filename,format_spec,' ');
%    filename = sprintf('s_z_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(s_z,filename,format_spec,' ');
%    filename = sprintf('t_x_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(t_x,filename,format_spec,' ');
%    filename = sprintf('t_y_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(t_y,filename,format_spec,' ');
%    filename = sprintf('t_z_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(t_z,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('Fy_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(Fy,filename,format_spec,' ');
%    filename = sprintf('Fz_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(Fz,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('n_y_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(n_y,filename,format_spec,' ');
%    filename = sprintf('n_z_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(n_z,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('mapM_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(mapM,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('mapP_for_h=%s_and_N=%d.txt',mesh_size_parameter_string,N);
%    filename = [directory_string,filename];
%    MatrixToTextFile(mapP,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',' ');
%    
%    GLnodes = GaussLobattoNodes(N + 1); r_min = abs(GLnodes(2) - GLnodes(1));
%    dtscale = dtscale3D(); C = 0.125; dt = C * min(dtscale) * (2 / 3) * r_min / sqrt(a_advec ^ 2 + b_advec ^ 2 + c_advec ^ 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