Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

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.1.1.1 $
00022 // $Date: 2000/09/15 08:23:18 $
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 
00033 #include <G3Globals.h>
00034 #include <Domain.h>
00035 #include <Node.h>
00036 #include <MP_Constraint.h>
00037 #include <Matrix.h>
00038 #include <ID.h>
00039 #include <RigidRod.h>
00040 
00041 
00042 RigidRod::RigidRod(Domain &theDomain, int nR, int nC, int startMPtag) {
00043 
00044     
00045     // get a pointer to the retained node and constrained nodes - ensure these exist
00046     Node *nodeR = theDomain.getNode(nR);
00047     if (nodeR == 0) {
00048       g3ErrorHandler->warning("RigidRod::RigidRod - %s %d %s\n",
00049          "retained Node", nR, "not in domain");
00050       return;
00051     }
00052     Node *nodeC = theDomain.getNode(nC);
00053     if (nodeR == 0) {
00054       g3ErrorHandler->warning("RigidRod::RigidRod - %s %d %s\n",
00055          "constrained Node", nC, "not in domain");
00056       return;
00057     }
00058 
00059     // get the coordinates of the two nodes - check dimensions are the same
00060     const Vector &crdR = nodeR->getCrds();
00061     const Vector &crdC = nodeC->getCrds();
00062     int dimR = crdR.Size();
00063     int dimC = crdC.Size();
00064     if (dimR != dimC) {
00065       g3ErrorHandler->warning("RigidRod::RigidRod - mismatch in dimension %s %d %s %d\n",
00066          "between constrained Node", nC, "and Retained node",nR);
00067       return;
00068     }
00069     
00070     // check the number of dof at each node is the same 
00071     int numDOF = nodeR->getNumberDOF();
00072     if (numDOF != nodeC->getNumberDOF()){ 
00073       g3ErrorHandler->warning("RigidRod::RigidRod - mismatch in numDOF %s %d %s %d\n",
00074          "between constrained Node", nC, "and Retained node",nR);
00075       return;
00076     }
00077 
00078     // check the number of dof at the nodes >= dimension of problem
00079     if(numDOF < dimR){    
00080       g3ErrorHandler->warning("RigidRod::RigidRod - numDOF at nodes %d %d %s\n",
00081          nR, nC, "must be >= dimension of problem");
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(startMPtag+1, nR, nC, 
00101          mat, id, id);
00102     if (newC == 0) {
00103       g3ErrorHandler->warning("RigidRod::RigidRod - for nodes %d %d, out of memory\n",
00104          nC, nR);
00105     } else {
00106       // add the constraint to the domain
00107       if (theDomain.addMP_Constraint(newC) == false) {
00108  g3ErrorHandler->warning("RigidRod::RigidRod - for nodes %d %d, could not add to domain\n",
00109     nC, nR);
00110  delete newC;
00111       }
00112     }
00113 }
00114  
00115     
00116 RigidRod::~RigidRod()
00117 {
00118     // does nothing
00119 }
00120 
00121  
00122 
Copyright Contact Us