RigidRod.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.4 $
00022 // $Date: 2005/01/08 01:22:41 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/domain/constraints/RigidRod.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/model/constraints/RigidRod.C
00027 //
00028 // Written: fmk 12/99
00029 // Revised:
00030 //
00031 // Purpose: This file contains the class implementation for RigidRod.
00032 #include <stdlib.h>
00033 
00034 #include <OPS_Globals.h>
00035 #include <Domain.h>
00036 #include <Node.h>
00037 #include <MP_Constraint.h>
00038 #include <Matrix.h>
00039 #include <ID.h>
00040 #include <RigidRod.h>
00041 
00042 
00043 RigidRod::RigidRod(Domain &theDomain, int nR, int nC, int mPtag) {
00044 
00045     
00046     // get a pointer to the retained node and constrained nodes - ensure these exist
00047     Node *nodeR = theDomain.getNode(nR);
00048     if (nodeR == 0) {
00049       opserr << "RigidRod::RigidRod - retained Node" <<  nR <<  "not in domain\n";
00050       return;
00051     }
00052     Node *nodeC = theDomain.getNode(nC);
00053     if (nodeR == 0) {
00054       opserr << "RigidRod::RigidRod - constrained Node" <<  nC <<  "not in domain\n";
00055       return;
00056     }
00057 
00058     // get the coordinates of the two nodes - check dimensions are the same
00059     const Vector &crdR = nodeR->getCrds();
00060     const Vector &crdC = nodeC->getCrds();
00061     int dimR = crdR.Size();
00062     int dimC = crdC.Size();
00063     if (dimR != dimC) {
00064       opserr << "RigidRod::RigidRod - mismatch in dimension " <<
00065         "between constrained Node " <<  nC <<  " and Retained node " << nR << endln;
00066       return;
00067     }
00068     
00069     // check the number of dof at each node is the same 
00070     int numDOF = nodeR->getNumberDOF();
00071     if (numDOF != nodeC->getNumberDOF()){ 
00072       opserr << "RigidRod::RigidRod - mismatch in numDOF " <<
00073         "between constrained Node " <<  nC <<  " and Retained node " << nR << endln;
00074       return;
00075     }
00076 
00077     // check the number of dof at the nodes >= dimension of problem
00078     if(numDOF < dimR){    
00079       opserr << "RigidRod::RigidRod - numDOF at nodes " << nR << " and " << nC <<
00080         "must be >= dimension of problem\n";
00081 
00082       return;
00083     }
00084 
00085     
00086     // create the ID to identify the constrained dof 
00087     ID id(dimR);
00088 
00089     // construct the tranformation matrix Ccr, where  Uc = Ccr Ur & set the diag
00090     Matrix mat(dimR,dimR);
00091     mat.Zero();
00092 
00093     // set the values
00094     for (int i=0; i<dimR; i++) {
00095       mat(i,i) = 1.0;
00096       id(i) = i;
00097     }
00098 
00099     // create the MP_Constraint
00100     MP_Constraint *newC = new MP_Constraint(mPtag, nR, nC, mat, id, id);
00101                                             
00102     if (newC == 0) {
00103       opserr << "RigidRod::RigidRod - for nodes " << nR << " and " << nC << " out of memory\n";
00104       exit(-1);
00105     } else {
00106       // add the constraint to the domain
00107       if (theDomain.addMP_Constraint(newC) == false) {
00108         opserr << "RigidRod::RigidRod - for nodes " << nC << " and " << nR << " could not add to domain\n",
00109         delete newC;
00110       }
00111     }
00112 }
00113         
00114     
00115 RigidRod::~RigidRod()
00116 {
00117     // does nothing
00118 }
00119 
00120  
00121 

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