clc; clear;

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

Globals2D;

%[P,E,E_parts,E_parts_neighs] = MshToMatlab2D_with_partitions('Gmsh_mesh_partitions_debug_easier.msh'); % h = 8.00
[P,E,E_parts,E_parts_neighs] = MshToMatlab2D_with_partitions('Gmsh_mesh_partitions_debug.msh'); % h = 4.00
%[P,E,E_parts,E_parts_neighs] = MshToMatlab2D_with_partitions('Gmsh_mesh_partitions_16.msh'); % h = 2.00
mesh_size_parametr = 4.00;
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',' ');
filename = sprintf('E_partitions_for_h=%s.txt',mesh_size_parameter_string);
filename = [directory_string,filename];
MatrixToTextFile(E_parts,filename,'%d',' ');

N_vect = 2:2;
n = length(N_vect);

for i = 1:n
    N = N_vect(i);
    StartUp2D_modified;
    
    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',' ');
end