import_INP

Below is a demonstration of the features of the import_INP function

Contents

clear; close all; clc;

Plot settings

fig_color='w';
fig_colordef='white';
faceAlpha=0.5;
fontSize=25;

Specifying file location

%Set main folder
defaultFolder = fileparts(fileparts(mfilename('fullpath')));
pathName=fullfile(defaultFolder,'data','INP');

%Set model
testCase=3;
switch testCase
    case 1 %Triangular elements
        fileNameEnd='example_TRI.inp';
        numberNodesElement=3;
    case 2 %Quad elements
        fileNameEnd='example_QUAD.inp';
        numberNodesElement=4;
    case 3 %Tetrahedral elements
        fileNameEnd='example_TET.inp';
        numberNodesElement=4;
    case 4 %Hexahedral elements
        fileNameEnd='example_HEX.inp';
        numberNodesElement=8;
end
fileName=fullfile(pathName,fileNameEnd);

Importing the INP file

logicRenumberOption=1;
[elementStruct,nodeStruct]=import_INP(fileName,numberNodesElement,logicRenumberOption);
--- import_INP ---
IMPORTING .INP FILE INTO CELL ARRAY
---> Found target:*NODE on line 9
---> Found target:*ELEMENT on line 8536
---> Found target:** on line 53847
CONVERTING TEXT FIELDS TO MATLAB ARRAYS
---> Created elementStruct
---> Created nodeStruct
DONE!

Content:

elementStruct
nodeStruct

V=nodeStruct.N; %The nodes
E=elementStruct.E; %The elements
elementStruct = 

  struct with fields:

         E: [45310×4 double]
     E_ind: [226550×1 double]
    E_type: '*ELEMENT, TYPE=C3D4, ELSET=PART-DEFAULT_1_EB1'


nodeStruct = 

  struct with fields:

        N: [8524×3 double]
    N_ind: [8524×1 double]

Displaying the model

%Get patch data for plotting
if ~isempty(strfind(elementStruct.E_type,'S4R')) || ~isempty(strfind(elementStruct.E_type,'STRI3')); %quad or tri elements
    F=E; %elements already describe faces
else %hex or tet elements
    [F,~]=element2patch(E,[]);
end

figuremax(fig_color,fig_colordef);
title('INP imported model','fontSize',fontSize);
xlabel('X','fontSize',fontSize);ylabel('Y','fontSize',fontSize); zlabel('Z','fontSize',fontSize); hold on;

hpm=patch('Faces',F,'Vertices',V,'EdgeColor','k','FaceColor','g','FaceAlpha',1);
view(3); axis equal; axis tight; axis vis3d; grid on;
drawnow;

GIBBON www.gibboncode.org

Kevin Mattheus Moerman, [email protected]