4.2.1.7. Outline of readElementFieldOdb.m

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

Contents

Summary

Detailed outline

Template

Reference

Summary

In summary, the following steps are taken to read and load in Matlab the element-type field output results of an odb file:

[1] Check if the odb file specified exists in the working directory

[2] Delete any Abaqus rpy files if present in the working directory. If any file cannot be deleted (e.g. if it is opened in Abaqus) then issue a warning

[3] Upgrade in case that the version of the odb file is older than the version of Abaqus running on the pc

[4] Find the category of the requested field output variable identifier

[5] Create the Python script to be executed for postprocessing of the odb file

[6.1] If the Python script is created successfully

[6.1.1] Execute the Python script

[6.1.2] Load the numerical data printed in the output (out) file during the execution of the Python script

[6.1.3] Load the indexing data printed in the data (dat) file during the execution of the Python script

[6.1.4] Read all the rpy files which are present in the working directory

[6.2] If the Python script is not created successfully, terminate execution and issue an error

Detailed outline

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

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

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

[3] This step is implemented by issuing the following command to the operating system through Matlab, where odbFileNew is the name of the updated odb file which is compatible with the Abaqus version used at the computing platform and odbFileOld is the name of the existing odb file:

system('abaqus -upgrade -job odbFileNew -odb odbFileOld')
 

[4] The structure of the Python script created at step [5] depends on the category of the field output variable identifier that is requested. See 4.2.1.2. Categories of field output for more details.

[5] The Python script that is generated at this step is named readElementFieldOdb.py and performs the following operations:

[5.1] Make the basic Abaqus objects accessible to the script

[5.2] Open an empty lock file (*lck). This file is closed after the termination of the execution of the Python script. As long as this file exists, this means that either the Python script is running, or an error/bug has occurred which does not allow the Python script to run successfully.

[5.3] Open the odb file for reading and the out file with writing permission.

[5.4] Determine the step, the instance, the element set and the output variable identifier for which the output will be extracted, based on the options specified by the user as input arguments.

[5.5] Perform the following loop to print the odb results in the out file, written in a simplified way to facilitate understanding the various programming concepts:

for step in steps
    for frame in step.frames
         for i in frame.fieldOutputs
             print the key associated with i
             for outVal in i.values
                 if it contains 1 scalar quantity
                     print the result to the out file
                 else
                     for j in outVal.data
                         print data to the out file
                     if the identifier is of category 2
                         print magnitude to the out file
                     if the identifier is of category 3
                         print 10 invariants to the out file
close the out file

[5.6] Open the dat file (if requested) with writing permission and perform the following loop to print the indices of the odb results in the dat file, written in a simplified way to facilitate understanding the various programming concepts:

if indexing is requested
    for step in steps
        for frame in step.frames
             for i in frame.fieldOutputs
                 print the key associated with i
                 for outVal in i.values
                     print the index pair to the dat file
    close the dat file

[5.7] Close the odb file

[5.8] Close the lck file and delete the lck file

[5.9] Check if the Python script has been successfully created in the working directory in order to notify the parent Matlab function to proceed in executing the script.

[6.1] This step is checked through the results of step [5.9]

[6.1.1] Execute the script by issuing a command to the operating system and halting Matlab execution as long as the lck file opened in [5.2] and closed in [5.8] exists:

!abaqus cae nogui=readElementFieldOdb.py
pause(0.5);
while the lck file exists
    pause(0.1)

[6.1.2] The output (out) files are actually text files in ascii format that contain the element-type field output results that are extracted from an odb file. It is created and populated during the execution of the Python script readElementFieldOdb.py. The numerical values in this file are arranged in a single column (one value per row). The step and the frame to which each value belongs are printed in the indexing (dat) file which is optional and described in the next section.

[6.1.3] The indexing (dat) files are actually text files in ascii format that contain indices concerning the step and the frame of each element-type field output result that is printed in the output file. It is created and populated during the execution of the Python script readElementFieldOdb.py. The numerical values in this file are arranged in two columns (two values per row). The generation of this file is optional and can be specified among the input arguments of the readElementFieldOdbPyScript.m function.

[6.1.4] The rpy files contain information about the model, written by Abaqus by default, as well as information printed in the Abaqus Command Line Interface (CLI) during execution of the Python script, which is tagged as Abaqus2Matlab output. The function that reads the rpy files searches and prints in the Matlab command window the contents of rpy file by executing the following loop:

Read the first line of the rpy file
while the read line contains characters
    if it contains Abaqus2Matlab output
        if the Abaqus2Matlab output is not duplicate
            print the Abaqus2Matlab output in the Matlab command window
    elseif the line starts with the string "#: Number of"
        print the remaining of the line
    elseif the line starts with the string "#: Warning:"
        issue the statement as warning in the Matlab command window
    read the next line of the rpy file
close the rpy file

[6.2] This step is quite straightforward. The user is referred to lines 271-272 of the function readElementFieldOdb.m

Template

An exemplary Matlab script which extracts from an odb file the element-type field output results and their indices 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,' *OUTPUT, FIELD\n');
% specify at least one of the following:
fprintf(fileID,' *ELEMENT OUTPUT\n');
fprintf(fileID,'  ...<Element output variable IDs>...\n');
% or:
fprintf(fileID,' *NODE OUTPUT\n');
fprintf(fileID,'  ...<Node output variable IDs>...\n');
% end the step definition
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
% Read the field output contained in AbaqusInputFile.odb
stepName='myStep';
instanceName='myInstance';
elsetName='myElSet';
outputVar='myOutputVar';
indOut=false; %(no dat file)
indOut=true; %(create dat file)
[odbOut,odbDat,rpyOut]=readElementFieldOdb('AbaqusInputFile.odb',...
    stepName,instanceName,elsetName,outputVar,indOut,S);
 

Reference

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

readElementFieldOdb.m

readElementFieldOdbPyScript.m

_________________________________________________________________________
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