Adding a new Finite Element to Aladdin.

[ Introduction ]
[ Finite element source code files ]
[ Adding Content to the Finite Element Code ]
[ Linking the finite element code to Aladdin ]

This page contains step-by-step instructions for adding a new finite element to Aladdin.


INTRODUCTION

Before diving into the details on how a new finite element can be added to Aladdin, we need to quickly review the key steps involved in formulating and solving a typical finite element problem:

  1. Discretize and Select the Element Types : A body is divided into an equivalent system of finite elements will associated nodes and relevant element types.

    For this most part, this step requires judgement on the part of an engineer. Lots of examples of this step can be found in the finite element literature.

  2. Select a Displacement Function : The displacement throughout the element is expressed in terms of nodal displacements.

  3. Define Strain/Displacement and Stress/Strain Relationships : These relationships capture the constituitive behavior of a particular material.

  4. Element-Level Stiffness and Mass Matrices : Energy methods and/or principles of virtual work are commonly used in the formulation of element-level stiffness matrices and mass matrices.

    Steps 2, 3 and 4 require an understanding of structural mechanics, structural analysis, and structural dynamics procedures.

  5. Assemble the Global Stiffness, Mass and Nodal Load Matrices : Using the method of superposition, the individual element level stiffness and mass matrices are added together to form global stiffness and global mass matrices for the whole structure. The results of this step is:
           [ K ] = Global Stiffness Matrix.
           [ M ] = Global Mass Matrix.
           [ F ] = Matrix of Externally Applied Nodal Loads.
    

    In Aladdin these steps are handled by the functions Stiff(), Mass() and Load() .

  6. Compute the Generalized Displacements : The displacements of the Global Degrees of Freedom [ X ] correspond to the solution of:
           [ K ].[ X ] = [ F ]
    

    In Aladdin this step is handled by the function Solve().

  7. Solve for the Element Level Stresses and Strains : Element level stresses and strains are determined directly from the global displacements computed in the previous step.

    In Aladdin this step is computed by the functions Stress(), GetStress() and GetDispl().

  8. Interpret the Results : This step involves the identification of locations in a structure subject to the largest displacements and bending moments/axial forces.

    A good way of handling this step in Aladdin is to gather the the displacement/stress results into a single matrix, and save the matrix in a format suitable for plotting with MATLAB.

From the standpoint of adding a new finite element to Aladdin, the most important steps are 2-3-4 and 7. Aladdin has been carefully designed so that a new element can be inserted into the program without worrying about steps 5 and 6. With steps 1 through 7 in place, step 8 is one of interpretation.


FINITE ELEMENT SOURCE CODE FILES

The Aladdin finite element libraray has been designed so that "nearly all" of the code associated with a new element is located in one file.

Example

Let us suppose that we want to add a three node constant strain triangle (cst) to Aladdin. The following diagram shows a single finite element together with its six degrees of freedom, and the element being used in the analysis of a cantilever structure.

Figure 1 : Constant Strain Triangle FE and Cantilever Application

Most of the code associated with this element should go in a new file called elmt_XXX.c, where XXX is a suitable name for the finite element file under development. For this example the file name

 
    elmt_cst.c

makes sense. This file must contain the functions:

    elmt_cst ( ARRAY *p, int isw )
    print_property_cst();

Here ARRAY *p is a pointer to the working array data structure that transfers information between the ALADDIN database and the finite element library functions (note this data structure is used for all of the finite elements!), and "isw" is simply a constant for the task to be accomplished.

The structure of elmt_cst.c should be similar to all of the other finite element library files in Aladdin. The skeleton structure for this file is:

/*
 *  =================================================================== 
 *  ALADDIN Version 2.0 :
 *                                                                     
 *  elmt_cst.c : Three node constant strain triangle finite element.
 *                                                                     
 *  -------------------------------------------------------------------
 *  Convention for Nodal Forces
 *         
 *  .... fill in details here ....        
 *        
 *  Convention for Member End  Forces
 *       
 *  .... fill in details here ....        
 *                                                                    
 *  Author : .... fill in details here ....        
 *  =================================================================== 
 */

#include 
#include "defs.h"
#include "units.h"
#include "matrix.h"
#include "fe_database.h"
#include "symbol.h"
#include "fe_functions.h"
#include "elmt.h"

/* 
 *  ============================================================== 
 *  Element_CST
 *
 *  Description of Input Properties:                                      
 *
 *  ..... fill in details here ....
 * 
 *  Input  :  ARRAY *p  -- pointer to working ARRAY data structure
 *         :  int isw   -- flag for task to be computed.
 *  Output :  ARRAY *p  -- pointer to working ARRAY data structure
 *  ============================================================== 
 */

ARRAY *elmt_cst ( ARRAY *p, int isw ) {

    /* [a] : Jump to Task Case */

    UNITS_SWITCH = CheckUnits();
    switch(isw) {
        case PROPTY:      /* CST material properties  */

             ..... add details of CST material properties ....

             break;
	case LOAD_MATRIX: /* compute equivalent nodal loads  */
	case STRESS:      /* compute internal nodal loads    */

             ..... fill in details here .... 

             break;
        case STIFF:       /* compute element-level stiffness matrix */

             ..... put details of element stiffness matrix here ....

             break;
        case MASS_MATRIX: /* compute element-level mass matrix      */

             ..... put details of element mass matrix here ....

             break;
        default:
             break;
    }

    return(p);
}

/*
 *  ===================================================
 *  print_property_cst() : print CST element properties
 *  ===================================================
 */

void print_property_cst( EFRAME *frp, int i ) {

   ... print element properties of CST finite element .....

}

Points to note:

  1. The constants PROPTY, CHERROR, STIFF, LOAD_MATRIX, MASS_MATRIX and so forth are constants for the various tasks computed inside the elmt_cst() function. These constants are defined inside the header file defs.h.

  2. The results of your element level computations saved in the data structure ARRAY p.


ADDING CONTENT TO THE FINITE ELEMENT FUNCTIONS

There are a couple of things you will need to know before content can be added to your new finite element file.

Data Structures

Aladdin employs two data structures to transfer information between the finite element library routines and the ALADDIN kernel/database.

ARRAY : ARRAY is a working data structure that contains links to:

  1. Information needed by the finite element library functions (e.g., section and material properties).
  2. Information computed by the finite element library functions (e.g., pointers to the element stiffness and mass matrices).

The abbreviated details of ARRAY, as defined in the header file fe_database.h, are:

typedef struct array {
    int             no_dimen;  /* No dimensions in Problem              */
    int              elmt_no;  /* Element no                            */
    int         elmt_attr_no;  /* Elmt Attribute No, as stored in frame */
    char          *elmt_type;  /* Element Type                          */
    int       nodes_per_elmt;  /* Max no nodes per element              */
    int         dof_per_node;  /* Dof per node                          */
    int        size_of_stiff;  /* Size of stiffness (mass) matrix       */
    int                 type;  /* Flag for type of mass matrix          */
    int             *d_array;  /* Destination Array                     */
    char      *material_name;  /* Material used in the element          */
    QUANTITY  *work_material;  /* Section/Material working array        */
    QUANTITY   *work_section;  /* Section/Material working array        */
    QUANTITY         **coord;  /* Nodal coordinates                     */
    int        *node_connect;  /* Array of Nodal Connectivities         */
    QUANTITY    *nodal_loads;  /* Array of Point Loads                  */

    .... members of the ARRAY data structure removed ....

    MATRIX            *stiff;  /* Stiffness (and Mass) Matrix ???       */
    MATRIX *equiv_nodal_load;  /* Equivalant nodal loads                */
    MATRIX            *displ;  /* Element Level Displacements           */

    .... members of the ARRAY data structure removed ....

} ARRAY;

Most of the entries in this data structures are physical quantities, pointers to matrices that have been dynamically allocated, or pointers to "character strings" for the name of a section or material property. The latter can be used to retrieve section/material properties stored in the Aladdin symbol table.

Dynamic Memory Allocation


LINKING THE FINITE ELEMENT CODE TO ALADDIN

The new finite element file is linked to Aladdin by editing the following files:

elmt.h

This header file contains the declarations of functions in the element library. The following lines should be added to elmt.h:

/* Element library functions */

ARRAY     *elmt_cst();          /* CST Element */

/* Element properties handling */

void       print_property_cst();

/* Generic Template for Item in Finite Element Library */

static struct {
    char                 *name; /* name of elment type                  */
    ARRAY  *(*elmt_lib_func)(); /* ptr to elmt library function         */
    void       (*elmt_print)(); /* ptr to elmt library print function   */
    int                 no_dof; /* No dof per node                      */
    int       no_node_per_elmt; /* No nodes per element                 */
    int               no_dimen; /* No dimension of problem              */
} elmt_library[] = {

           ....... details of other finite elements removed .....

           "CST"  elmt_cst, print_property_cst,  2, 3, 2,
};

Points to note:

  1. The name "CST" is the name you will use to reference the constant strain triangle finite element. In an input file, for example, the element attributes will be written:
      ElementAttr("elmt_attr1") { type     = "CST";
                                  section  = "section1";
                                  material = "material1"; }
    
    

    In the finite element attributes set called "elmt_attr1", "section1" is the name of the element section attributes, and "material1" is the name of the material attributes.

Makefile

The Makefile needs to modified so that elmt_cst.c is compiled and linked with the rest of the program. The required modification is:

# ==========================================================
# Makefile for ALADDIN
# ==========================================================

..... details removed from the ALADDIN Makefile ....

ELEMENTS =  	elmt_set_attr.o	elmt_library.o	elmt_lamina_sys.o \
        	elmt_frame2d.o	elmt_frame3d.o	elmt_psps.o 	  \
		elmt_shell_4n.o	elmt_shell_8n.o elmt_shell_4n_q.o \
        	elmt_fiber2d.o	elmt_fiber3d.o  elmt_cst.o

..... details removed from the ALADDIN Makefile ....

# ALADDIN header file dependencies

..... details removed from the ALADDIN Makefile ....

$(MATRIX) elmt_cst.o elmt_frame3d.o elmt_psps.o elmt_shell_4n.o \
          elmt_shell_4n_q.o elmt_shell_8n.o fe_checkmemory.o    \
          fe_matrix.o fe_mesh.o fe_print.o fe_profile.o : vector.h

Points to note:

  1. The object file naame elmt_cst.o is added to the list of files under the ELEMENTS macro, and to the dependency list of files that will be recompiled when "vector.h" is changed.


Developed in November 1997 by Mark Austin
Last Modified November 24, 1997
Copyright © 1997, Mark Austin, Department of Civil Engineering, University of Maryland