/* * ========================================================================== * Compute internal forces and reactions in cantilever truss structure. * * Matrices : spTruss = Represents truss geometry and element connectivity. * : spLoad = External forces acting on the truss nodes. * : spForce = Internal member forces acting in truss elements. * : spSupport = Relationship between truss and support reactions * : spSupport = Matrix of support reaction forces. * ========================================================================== * Copyright (C) 1996 by Mark Austin and David Mazzoni. * * This software is provided "as is" without express or implied warranty. * Permission is granted to use this software on any computer system, * and to redistribute it freely, subject to the following restrictions: * * 1. The authors are not responsible for the consequences of use of * this software, even if they arise from defects in the software. * 2. The origin of this software must not be misrepresented, either * by explicit claim or by omission. * 3. Altered versions must be plainly marked as such, and must not * be misrepresented as being the original software. * 4. This notice is to remain intact. * * Written By: Mark Austin July 1996 * ========================================================================== */ #include #include #include "matrix.h" #include "miscellaneous.h" int main( void ) { MATRIX *spTruss, *spLoad, *spForce, *spSupport, *spReactions; enum { NoElmts = 6, NoReactions = 4 }; int ii, ij; /* [a] : Setup matrix for "truss connectivity" */ spTruss = matAllocIndirect( "Truss Connectivity", DoubleArray, NoElmts, NoElmts ); spTruss->uMatrix.dpp[ 0 ][ 0 ] = 1; spTruss->uMatrix.dpp[ 0 ][ 1 ] = -1; spTruss->uMatrix.dpp[ 1 ][ 3 ] = 1; spTruss->uMatrix.dpp[ 2 ][ 1 ] = 1; spTruss->uMatrix.dpp[ 2 ][ 2 ] = 1/sqrt(2); spTruss->uMatrix.dpp[ 3 ][ 2 ] = 1/sqrt(2); spTruss->uMatrix.dpp[ 4 ][ 2 ] = 1/sqrt(2); spTruss->uMatrix.dpp[ 4 ][ 4 ] = -1/sqrt(2); spTruss->uMatrix.dpp[ 4 ][ 5 ] = -1; spTruss->uMatrix.dpp[ 5 ][ 2 ] = 1/sqrt(2); spTruss->uMatrix.dpp[ 5 ][ 3 ] = 1; spTruss->uMatrix.dpp[ 5 ][ 4 ] = 1/sqrt(2); /* [b] : Setup matrix for "external loads" on truss nodes */ spLoad = matAllocIndirect( "External Loads", DoubleArray, NoElmts, 1); spLoad->uMatrix.dpp[ 1 ][ 0 ] = 10; spLoad->uMatrix.dpp[ 3 ][ 0 ] = 10; /* [c] : Print matrices for "truss connectivity" and "external loads" */ matPrint( spTruss ); matPrint( spLoad ); /* [d] : Solve equations and print "internal member" forces */ spForce = matSolve( spTruss, spLoad ); spForce->cpName = saveString( "Member Forces", __FILE__, __LINE__ ); matPrint( spForce ); /* [e] : Setup matrix for "support reactions" */ spSupport = matAllocIndirect( "Truss/Support Reactions Connectivity", DoubleArray, NoReactions, NoElmts ); spSupport->uMatrix.dpp[ 0 ][ 0 ] = -1; spSupport->uMatrix.dpp[ 0 ][ 4 ] = -1/sqrt(2); spSupport->uMatrix.dpp[ 1 ][ 4 ] = -1/sqrt(2); spSupport->uMatrix.dpp[ 2 ][ 5 ] = -1; /* [f] : Compute and print "support reactions" */ spReactions = matMult( spSupport, spForce ); spReactions->cpName = saveString( "Support Reactions", __FILE__, __LINE__ ); matPrint( spReactions ); /* [g] : Clean up */ matFree( spTruss ); matFree( spLoad ); matFree( spForce ); matFree( spSupport ); matFree( spReactions ); }