UniformExcitation.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.7 $
00022 // $Date: 2005/11/07 21:36:34 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/domain/pattern/UniformExcitation.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/domain/load/UniformExcitation.h
00027 //
00028 // Written: fmk 11/98
00029 // Revised:
00030 //
00031 // Purpose: This file contains the class definition for UniformExcitation.
00032 // UniformExcitation is an abstract class.
00033 
00034 #include <UniformExcitation.h>
00035 #include <GroundMotion.h>
00036 #include <Domain.h>
00037 #include <NodeIter.h>
00038 #include <Node.h>
00039 #include <ElementIter.h>
00040 #include <Element.h>
00041 #include <Channel.h>
00042 #include <FEM_ObjectBroker.h>
00043 
00044 UniformExcitation::UniformExcitation()
00045 :EarthquakePattern(0, PATTERN_TAG_UniformExcitation), 
00046   theMotion(0), theDof(0), vel0(0.0)
00047 {
00048 
00049 }
00050 
00051 
00052 UniformExcitation::UniformExcitation(GroundMotion &_theMotion, 
00053                                    int dof, int tag, double velZero)
00054 :EarthquakePattern(tag, PATTERN_TAG_UniformExcitation), 
00055   theMotion(&_theMotion), theDof(dof), vel0(velZero)
00056 {
00057   // add the motion to the list of ground motions
00058   this->addMotion(*theMotion);
00059 }
00060 
00061 
00062 UniformExcitation::~UniformExcitation()
00063 {
00064 
00065 }
00066 
00067 
00068 void
00069 UniformExcitation::setDomain(Domain *theDomain) 
00070 {
00071   this->LoadPattern::setDomain(theDomain);
00072 
00073   // now we go through and set all the node velocities to be vel0
00074   if (vel0 != 0.0) {
00075     NodeIter &theNodes = theDomain->getNodes();
00076     Node *theNode;
00077     Vector newVel(1);
00078     int currentSize = 1;
00079     while ((theNode = theNodes()) != 0) {
00080       int numDOF = theNode->getNumberDOF();
00081       if (numDOF != currentSize) 
00082         newVel.resize(numDOF);
00083       
00084       newVel = theNode->getVel();
00085       newVel(theDof) = vel0;
00086       theNode->setTrialVel(newVel);
00087       theNode->commitState();
00088     }
00089   }
00090 }
00091 
00092 void
00093 UniformExcitation::applyLoad(double time)
00094 {
00095   Domain *theDomain = this->getDomain();
00096   if (theDomain == 0)
00097     return;
00098 
00099 //  if (numNodes != theDomain->getNumNodes()) {
00100     NodeIter &theNodes = theDomain->getNodes();
00101     Node *theNode;
00102     while ((theNode = theNodes()) != 0) {
00103       theNode->setNumColR(1);
00104       theNode->setR(theDof, 0, 1.0);
00105     }
00106 //  }
00107 
00108   this->EarthquakePattern::applyLoad(time);
00109 
00110   return;
00111 }
00112 
00113 
00114 void
00115 UniformExcitation::applyLoadSensitivity(double time)
00116 {
00117   Domain *theDomain = this->getDomain();
00118   if (theDomain == 0)
00119     return;
00120 
00121 //  if (numNodes != theDomain->getNumNodes()) {
00122     NodeIter &theNodes = theDomain->getNodes();
00123     Node *theNode;
00124     while ((theNode = theNodes()) != 0) {
00125       theNode->setNumColR(1);
00126       theNode->setR(theDof, 0, 1.0);
00127     }
00128 //  }
00129 
00130   this->EarthquakePattern::applyLoadSensitivity(time);
00131 
00132   return;
00133 }
00134 
00135 
00136 
00137 int 
00138 UniformExcitation::sendSelf(int commitTag, Channel &theChannel)
00139 {
00140   int dbTag = this->getDbTag();
00141 
00142   static Vector data(5);
00143   data(0) = this->getTag();
00144   data(1) = theDof;
00145   data(2) = vel0;
00146   data(3) = theMotion->getClassTag();
00147   
00148   int motionDbTag = theMotion->getDbTag();
00149   if (motionDbTag == 0) {
00150     motionDbTag = theChannel.getDbTag();
00151     theMotion->setDbTag(motionDbTag);
00152   }
00153   data(4) = motionDbTag;
00154 
00155   int res = theChannel.sendVector(dbTag, commitTag, data);
00156   if (res < 0) {
00157     opserr << "UniformExcitation::sendSelf() - channel failed to send data\n";
00158     return res;
00159   }
00160       
00161   res = theMotion->sendSelf(commitTag, theChannel);
00162   if (res < 0) {
00163     opserr << "UniformExcitation::sendSelf() - ground motion to send self\n";
00164     return res;
00165   }
00166 
00167   return 0;
00168 }
00169 
00170 
00171 int 
00172 UniformExcitation::recvSelf(int commitTag, Channel &theChannel, 
00173                            FEM_ObjectBroker &theBroker)
00174 {
00175   int dbTag = this->getDbTag();
00176 
00177   static Vector data(5);
00178   int res = theChannel.recvVector(dbTag, commitTag, data);
00179   if (res < 0) {
00180     opserr << "UniformExcitation::recvSelf() - channel failed to recv data\n";
00181     return res;
00182   }
00183 
00184   this->setTag(data(0));
00185   theDof = data(1);
00186   vel0 = data(2);
00187   int motionClassTag = data(3);
00188   int motionDbTag = data(4);
00189 
00190   if (theMotion == 0 || theMotion->getClassTag() != motionClassTag) {
00191     if (theMotion != 0)
00192       delete theMotion;
00193     theMotion = theBroker.getNewGroundMotion(motionClassTag);
00194     if (theMotion == 0) {
00195       opserr << "UniformExcitation::recvSelf() - could not create a grond motion\n";
00196       return -3;
00197     }
00198 
00199     // have to set the motion in EarthquakePattern base class
00200     if (numMotions == 0) 
00201       this->addMotion(*theMotion);
00202     else
00203       theMotions[0] = theMotion;
00204   }
00205 
00206   theMotion->setDbTag(motionDbTag);
00207   res = theMotion->recvSelf(commitTag, theChannel, theBroker);
00208   if (res < 0) {
00209       opserr << "UniformExcitation::recvSelf() - motion could not receive itself \n";
00210       return res;
00211   }
00212 
00213   return 0;
00214 }
00215 
00216 
00217 void 
00218 UniformExcitation::Print(OPS_Stream &s, int flag)
00219 {
00220   s << "UniformExcitation  " << this->getTag() << " - Not Printing the GroundMotion\n";
00221 }
00222 
00223 LoadPattern *
00224 UniformExcitation::getCopy(void)
00225 {
00226   LoadPattern *theCopy = new UniformExcitation(*theMotion, theDof, this->getTag());
00227    return theCopy;
00228 }
00229 //  LocalWords:  OpenSees

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