4.2.3.2. Outline of getMatrix.m

In this section the way the function getMatrix.m works is outlined.

Contents

In summary, the following steps are taken to read a matrix from a mtx file:

▪[1] Load the contents of the mtx file into a [n x 5] array in Matlab.

▪[2] Initialize and populate a square matrix with the data contained in the array loaded at step [1]

▪[3] Delete the rows and columns containing only zero elements.

▪[4] Format the square matrix appropriately.

Here the steps summarized in the previous section are explained in detail.

▪[1] Loading of a comma-delimited text file in Matlab is quite straightforward. The Matlab function "load" is used. For the next steps, assume that the loaded [n x 5] array is named "a".

▪[2.1] Find n which is the number of rows of "a".

▪[2.2] Find the degrees of freedom per node of the finite element model.

▪[2.3] Find the maximum node ID of the model.

▪[2.4] Initialize a zero matrix (assumed to be named as "K") with dimension equal to the product of the degrees of freedom per node and the maximum node ID of the model.

▪[2.5] Populate "K" by scanning all the entries at the 5th column of "a" and placing them in the appropriate positions in "K".

▪[3] This step is relatively straightforward. For more details, the user should see the code of the function getMatrix.m.

▪[4] Depending on the specifications of the user, the output matrix "K" is formatted according to the following pseudocode:

switch format

in case of sparse & lower triangular

...

in case of sparse & fully populated

...

in case of full & lower triangular

...

in case of full & fully populated

...

otherwise

do nothing

An exemplary Matlab script which reads and loads the matrix contained in a mtx file is as follows:

% S is the directory path of the results file. It is assumed that it is

% placed in the folder C:\Abaqus_Temp\

S='C:\Abaqus_Temp';

% AbaqusInputFile.inp is the name of the Abaqus input file

fileID = fopen('AbaqusInputFile.inp','wt');

% Write Abaqus options in the file

fprintf(fileID,' *HEADING\n');

fprintf(fileID,' ...<options in Abaqus input file>...\n');

fprintf(fileID,' *STEP\n');

fprintf(fileID,' ...<options to define the preloading history for the model>...\n');

fprintf(fileID,' *END STEP\n');

fprintf(fileID,' *STEP\n');

fprintf(fileID,' *MATRIX GENERATE, STIFFNESS, MASS, VISCOUS DAMPING,\n');

fprintf(fileID,' STRUCTURAL DAMPING\n');

fprintf(fileID,' *MATRIX OUTPUT, STIFFNESS, MASS, VISCOUS DAMPING,\n');

fprintf(fileID,' STRUCTURAL DAMPING, FORMAT=MATRIX INPUT\n');

fprintf(fileID,' *BOUNDARY\n');

fprintf(fileID,' ...<Options to define the boundary conditions for the matrix generation step>...\n');

fprintf(fileID,' *END STEP\n');

fclose(fileID);

% Run the input file with Abaqus

!abaqus job=AbaqusInputFile

% Give Abaqus enough time to create the lck file

pause(2)

% While the lck file exists then halt Matlab execution

while exist('AbaqusInputFile.lck','file')==2

pause(0.1)

end

% Obtain the matrix output contained in the various mtx files

format='full'; % other options also possible

Stiffness=getMatrix('AbaqusInputFile_STIF1.mtx',format,S);

Mass=getMatrix('AbaqusInputFile_MASS1.mtx',format,S);

ViscousDamping=getMatrix('AbaqusInputFile_DMPV1.mtx',format,S);

StructuralDamping=getMatrix('AbaqusInputFile_DMPS1.mtx',format,S);

For more details about the functions involved in this section see:

_________________________________________________________________________

Abaqus2Matlab - www.abaqus2matlab.com

Copyright (c) 2017 by George Papazafeiropoulos

If using this application for research or industrial purposes, please cite:

G. Papazafeiropoulos, M. Muniz-Calvente, E. Martinez-Paneda.

Abaqus2Matlab: a suitable tool for finite element post-processing.

Advances in Engineering Software. Vol 105. March 2017. Pages 9-16. (2017)

DOI:10.1016/j.advengsoft.2017.01.006

Created with an evaluation copy of HelpSmith.

To remove this notice, you should purchase the full version of the product.

We support Ukraine and condemn war. Push Russian government to act against war. Be brave, vocal and show your support to Ukraine. Follow the latest news **HERE**