[ 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.
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:
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.
Steps 2, 3 and 4 require an understanding of structural mechanics, structural analysis, and structural dynamics procedures.
[ 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() .
[ K ].[ X ] = [ F ]
In Aladdin this step is handled by the function Solve().
In Aladdin this step is computed by the functions Stress(), GetStress() and GetDispl().
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.
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.
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:
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:
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
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:
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: