function [partmap2elems_out] = partmap2elements(part_num, dflow_floc,...
    dflow_beg, dflow_end)
%%Extracts information from partitioned files to variable. 
%   Information includes element ID, element domain, element x & y & z, 

% Calls partitioned file and pulls important data
for i = 0:part_num-1
    % Assigning the correct NetCDF file name to be opened
    file_num = sprintf('%04d',i);
    filename = strcat(dflow_beg, file_num, dflow_end);        
    
    read_file = strcat(dflow_floc,filename);
    
    if exist(read_file,'file') == 2
        x_elem = ncread(read_file,'FlowElem_xcc');
        y_elem = ncread(read_file,'FlowElem_ycc');
        z_elem = ncread(read_file,'FlowElem_zcc');
        elem_index = double(ncread(read_file,'FlowElemGlobalNr'));
        elem_domain = double(ncread(read_file,'FlowElemDomain'));
        
        elem_step_raw = [elem_index elem_domain x_elem y_elem z_elem];
        elem_step = elem_step_raw(elem_step_raw(:,2)==i,:);
        
        if i == 0
            elem_matrix = elem_step;
        else
            elem_matrix = [elem_matrix; elem_step];
        end

    end

end

partmap2elems_out = elem_matrix;

end

