Overview
Step 1: Creating a structure for one element
Step 2: Creating a structure for two elements
Step 3: Structure of handles
Step 3: Structure of Handles
Introduction
MATLAB assigns a handle to every graphics object it creates. One can use this handle to subsequently change the object's properties. The guihandles function allows the user to create a structure containing the handles of the objects in a figure. This feature is used in redAnTS to create a structure containing the handles of the objects in the graphical user interface (GUI) as shown below.
The user can augment this "handles" structure with any data. Taking advantage of this feature, redAnTSuses the handles structure to store information about the mesh, material properties, displacements, strains, stresses, etc. In other words, the handles structure is the container that is used to store this FEA data. This data can be accessed and modified using the guidata function as is explained below.
Handles structure in redAnTS
Download and unpack redAnTS if you haven't done so already. Bring up PostProcessMenuFiles/CalcStrainStress.min the MATLAB editor. This function is used to calculate the element strain and stress values from the nodal displacements. This is one of the functions that you need to modify to add post-processing capabilities to your version of redAnTS. Let's take a closer look at the following two statements in this function.
function sigepsstruct=CalcStrainStress(fighandle)
handles=guidata(fighandle);
The variable fighandle is the handle to the main redAnTS window and is passed into this function. The second statement passes this handle on to the guidata command to create a variable called handles. This variable handles is our exalted handles structure associated with the main redAnTSwindow (bow to it a few times in respect). Its fields contain all data required to calculate the element strain and stress as discussed below.
The data fields of interest in the handles structure are listed in the redAnTS main help. To see this, type Help redAnTS
at the MATLAB command line. Below is a snapshot from the help.
Thus, the handles structure has a field called mesh that is also a structure. The mesh field in turn contains the xcoords and other fields. The statement
x= handles.mesh.xcoords
will give you a row vector containing the x-coordinates of all the nodes. You can visualize the handles structure as per the figure below.
Investigate thehandles structure using the debugger
You can set use the debugger to investigate further what the fields of the handles structure look like. In the MATLAB editor, add a breakpoint in CalcStrainStress.m at the statement handles=guidata(fighandle).
You can add a breakpoint by clicking to the left of the line. A red circle should appear as shown below.
We'll run a problem in redAnTS in order to force the program to stop execution at this statement. Run through the first four steps of the Introductory redAnTS Tutorial. This can be accessed from within the redAnTS folder at: redAnTS_tutorial/redAnTS_tutorial.htm. Next, calculate σxxas per the first item in Step 5 of the tutorial. Program execution should stop at the above statement. Check the Workspace. Then, step through this statement using the step icon.
In the Workspace, you should see that handles structure has been created. Double-click on this variable to see what the fields of the structure look like. Reconcile what you see with the fields listed in the main redAnTS help page.
Type the following at the command line to see what the nodal x-coordinates are:
x= handles.mesh.xcoords
Note that the strain and stress fields, eps and sig, respectively, don't yet exist. When you update the structure sigepsstruct in CalcStrainStress.m, these fields will be added to the handles structure by the function that calls CalcStrainStress.m.
After you are done investigating the handles structure in the debugger, exit the debug mode by clicking on the Exit debug mode icon in the editor.
You should now have enough background to provide post-processing capabilities in redAnTS by modifying the following functions:
CalcStrainStress.m
CalcPrincipals.m
CalcEffectiveStress.m
Happy computing!