You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: postprocess.m
    path of file: ./repos/Isogeometric-Analysis/projects/j2_plasticity/3d_circular_bar_in_torsion
    
    the code of the file until where you have to start completion: %--------------------------------------------------------------------------
%  Author: Isaac J. Lee (ijlee2@ices.utexas.edu)
%  
%  
%  Summary:
%  
%  This routine plots the 3D specimen after deformation.
%  
%  
%  Instructions:
%  
%  Use the terminal to run the driver file with this command:
%  
%      ./matbg.sh driver_postprocess.m output
%  
%  Note that,
%  
%      path_to_assembly_directory is the path to the assembly files directory
%      path_to_results_directory is the path to the results directory
%      path_to_outputs_directory is the path to the plots directory
%  
%  
%  Output:
%  
%  1. Plot of the displacement fields (.png file)
%--------------------------------------------------------------------------
function postprocess(path_to_assembly_directory, path_to_results_directory, path_to_outputs_directory, time_index)
    close all;
    
    % Load the global assembly file
    load(sprintf('%sfile_assembly_global', path_to_assembly_directory), ...
         'numPatches', ...
         'numNodesBeforePatch', ...
         'numDOFsPerNode', ...
         'GN_array');
    
    % Load the results file
    load(sprintf('%sfile_results_time%06.0f', path_to_results_directory, time_index), ...
         'u', 'ID_array');
    
    
    %----------------------------------------------------------------------
    % ---------------------------------------------------------------------
    %   Begin: Loop over patches
    % ---------------------------------------------------------------------
    %----------------------------------------------------------------------
    for p = 1 : numPatches
        % Load the patch assembly file
        load(sprintf('%sfile_assembly_patch%d', path_to_assembly_directory, p), ...
             'elementType', ...
             'p1', ...
             'p2', ...
             'p3', ...
             'nodes', ...
            
    
function draw_3d_element(x, y, z, numPointsPerElementCoordinate)
    %----------------------------------------------------------------------
    %  Draw the points
    %----------------------------------------------------------------------
    % Number of points on an edge, excluding the endpoints
    numInteriorPointsPerEdge = (numPointsPerElementCoordinate - 1) / 4 - 1;
    
    % Initialize the points arrays
    points_on_edge = zeros(12 * numInteriorPointsPerEdge + 6, 3);
    points_on_face = zeros(6 * numInteriorPointsPerEdge^2, 3);
    points_in_element = zeros(numInteriorPointsPerEdge^3, 3);
    
    % Counters for the points arrays
    count_points_on_edge = 1;
    count_points_on_face = 1;
    count_points_in_element = 1;
    
    % Select every other fourth point
    for j3 = 1 : 4 : numPointsPerElementCoordinate
        for j2 = 1 : 4 : numPointsPerElementCoordinate
            for j1 = 1 : 4 : numPointsPerElementCoordinate
                % Flag to check where the point exists in the volume
                flag = (j1 == 1 || j1 == numPointsPerElementCoordinate) + (j2 == 1 || j2 == numPointsPerElementCoordinate) + (j3 == 1 || j3 == numPointsPerElementCoordinate);
                
                % Mark the points on the edges of the outer surface
                if (flag >= 2)
                    points_on_edge(count_points_on_edge, :) = [x(j1, j2, j3), y(j1, j2, j3), z(j1, j2, j3)];
                    count_points_on_edge = count_points_on_edge + 1;
                    
                % Mark the points on the faces of the outer surface
                elseif (flag == 1)
                    points_on_face(count_points_on_face, :) = [x(j1, j2, j3), y(j1, j2, j3), z(j1, j2, j3)];
                    count_points_on_face = count_points_on_face + 1;
                    
                % Mark the points inside the volume
                else
                    points_in_element(count_points_in_element, :) = [x(j1, j2, j3), y(j1, j2, j3), z(j1, j2, j3)];
                    count_points_in_element = count_points_in_element + 1;
                    
                end