import_INP
Below is a demonstration of the features of the import_INP function
Contents
clear all; close all; clc;
Plot settings
fig_color='w'; fig_colordef='white'; faceAlpha=0.5; fontSize=25;
Specifying file location
%Set main folder defaultFolder = fileparts(mfilename('fullpath')); pathName=fullfile(defaultFolder,'data','INP'); %Set model testCase=4; 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 33276 ---> Found target:** on line 62677 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 = E: [29400x8 double] E_ind: [264600x1 double] E_type: '*ELEMENT, TYPE=C3D8R, ELSET=EB1' nodeStruct = N: [33264x3 double] N_ind: [33264x1 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
Kevin M. Moerman (kevinmoerman@hotmail.com)