RigidBeam.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.3 $
00022 // $Date: 2005/01/08 01:22:41 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/domain/constraints/RigidBeam.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/model/constraints/RigidBeam.C
00027 //
00028 // Written: fmk 12/99
00029 // Revised:
00030 //
00031 // Purpose: This file contains the class implementation for RigidBeam.
00032 
00033 #include <OPS_Globals.h>
00034 #include <Domain.h>
00035 #include <Node.h>
00036 #include <MP_Constraint.h>
00037 #include <Matrix.h>
00038 #include <ID.h>
00039 #include <RigidBeam.h>
00040 
00041 
00042 RigidBeam::RigidBeam(Domain &theDomain, int nR, int nC, int mPtag) {
00043 
00044     
00045     // get a pointer to the retained and constrained nodes - make sure they exist
00046     Node *nodeR = theDomain.getNode(nR);
00047     if (nodeR == 0) {
00048       opserr << "RigidBeam::RigidBeam - retained Node" <<  nR <<  "not in domain\n";
00049       return;
00050     }
00051     Node *nodeC = theDomain.getNode(nC);
00052     if (nodeR == 0) {
00053       opserr << "RigidBeam::RigidBeam - constrained Node" <<  nC <<  "not in domain\n";
00054       return;
00055     }
00056 
00057     // get the coordinates of the two nodes - check dimensions are the same FOR THE MOMENT
00058     const Vector &crdR = nodeR->getCrds();
00059     const Vector &crdC = nodeC->getCrds();
00060     int dimR = crdR.Size();
00061     int dimC = crdC.Size();
00062     if (dimR != dimC) {
00063       opserr << "RigidBeam::RigidBeam - mismatch in dimension "  <<
00064         "between constrained Node " <<  nC <<  " and Retained node" << nR << endln;
00065       return;
00066     }
00067     
00068     // check the number of dof at each node is the same
00069     int numDOF = nodeR->getNumberDOF();
00070     if (numDOF != nodeC->getNumberDOF()){ 
00071       opserr << "RigidBeam::RigidBeam - mismatch in numDOF "  <<
00072         "between constrained Node " <<  nC <<  " and Retained node" << nR << endln;
00073       return;
00074     }
00075 
00076     // check the number of dof at the nodes >= dimension of problem
00077     if(numDOF < dimR){    
00078       opserr << "RigidBeam::RigidBeam - numDOF at nodes " << 
00079         nR << " and " <<  nC <<  "must be >= dimension of problem\n";
00080       return;
00081     }
00082 
00083     
00084     // create the ID to identify the constrained dof 
00085     ID id(numDOF);
00086 
00087     // construct the tranformation matrix Ccr, where  Uc = Ccr Ur & set the diag, Ccr = I
00088     Matrix mat(numDOF,numDOF);
00089     mat.Zero();
00090 
00091     // set the values
00092     for (int i=0; i<numDOF; i++) {
00093       mat(i,i) = 1.0;
00094       id(i) = i;
00095     }
00096 
00097     // if there are rotational dof - we must modify Ccr DONE ASSUMING SMALL ROTATIONS
00098     if (dimR != numDOF) {
00099       if (dimR == 2 && numDOF == 3) {
00100         double deltaX = crdC(0) - crdR(0);
00101         double deltaY = crdC(1) - crdR(1);          
00102         mat(0,2) = -deltaY;
00103         mat(1,2) = deltaX;
00104       } else if (dimR == 3 && numDOF == 6) {
00105         double deltaX = crdC(0) - crdR(0);
00106         double deltaY = crdC(1) - crdR(1);          
00107         double deltaZ = crdC(2) - crdR(2);
00108         // rotation about z/3 axis
00109         mat(0,5) = -deltaY;
00110         mat(1,5) = deltaX;      
00111 
00112         // rotation about y/2 axis
00113         mat(0,4) = deltaZ;
00114         mat(2,4) = -deltaX;
00115 
00116         // rotation about x/1 axis
00117         mat(1,3) = -deltaZ;
00118         mat(2,3) = deltaY;
00119       } else { // not valid
00120         opserr << "RigidBeam::RigidBeam -  for nodes " << 
00121           nR << "and " << nC <<  "nodes do not have valid numDOF for their dimension\n";
00122         return;
00123       }
00124         
00125     }   
00126     
00127     // create the MP_Constraint
00128     MP_Constraint *newC = new MP_Constraint(mPtag, nR, nC, mat, id, id);
00129                                             
00130     if (newC == 0) {
00131       opserr << "RigidBeam::RigidBeam - for nodes " << nC << " and " << nR << ", out of memory\n";
00132     } else {
00133       // add the constraint to the domain
00134       if (theDomain.addMP_Constraint(newC) == false) {
00135         opserr << "RigidBeam::RigidBeam - for nodes " << nC << " and " << nR << ", could not add to domain\n";
00136         delete newC;
00137       }
00138     }
00139 }
00140         
00141     
00142 RigidBeam::~RigidBeam()
00143 {
00144     // does nothing
00145 }
00146 
00147  
00148 

Generated on Mon Oct 23 15:05:00 2006 for OpenSees by doxygen 1.5.0