ImposedMotionSP.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.5 $
00022 // $Date: 2005/11/22 19:41:17 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/domain/constraints/ImposedMotionSP.cpp,v $
00024                                                                         
00025 // Written: fmk 
00026 // Created: 11/00
00027 // Revision: A
00028 //
00029 // Purpose: This file contains the implementation of class ImposedMotionSP.
00030 
00031 #include <ImposedMotionSP.h>
00032 #include <classTags.h>
00033 #include <Vector.h>
00034 #include <Channel.h>
00035 #include <FEM_ObjectBroker.h>
00036 #include <GroundMotion.h>
00037 #include <Node.h>
00038 #include <Domain.h>
00039 #include <LoadPattern.h>
00040 #include <ID.h>
00041 
00042 // constructor for FEM_ObjectBroker
00043 ImposedMotionSP::ImposedMotionSP()
00044 :SP_Constraint(CNSTRNT_TAG_ImposedMotionSP),
00045  groundMotionTag(0), patternTag(0),
00046  theGroundMotion(0), theNode(0), theNodeResponse(0), theGroundMotionResponse(3)
00047 
00048 {
00049     // does nothing else
00050 }
00051 
00052 // constructor for a subclass to use
00053 ImposedMotionSP::ImposedMotionSP(int tag, int node, int ndof, int pattern, int motion)
00054 :SP_Constraint(tag, node, ndof, CNSTRNT_TAG_ImposedMotionSP),
00055  groundMotionTag(motion), patternTag(pattern),
00056  theGroundMotion(0), theNode(0), theNodeResponse(0), theGroundMotionResponse(3)
00057 {
00058 
00059 }
00060 
00061 
00062 ImposedMotionSP::~ImposedMotionSP()
00063 {
00064   if (theNodeResponse != 0)
00065     delete theNodeResponse;
00066 }
00067 
00068 
00069 
00070 double
00071 ImposedMotionSP::getValue(void)
00072 {
00073   // no longer return 0 for TransformationConstraints also set response at nodes
00074     return theGroundMotionResponse(0);    
00075 }
00076 
00077 
00078 int
00079 ImposedMotionSP::applyConstraint(double time)
00080 {
00081   // on first 
00082   if (theGroundMotion == 0 || theNode == 0 || theNodeResponse) {
00083     Domain *theDomain = this->getDomain();
00084     
00085     theNode = theDomain->getNode(nodeTag);
00086     if (theNode == 0) {
00087         return -1;
00088     }
00089     theNodeResponse = new Vector(theNode->getNumberDOF());
00090     if (theNodeResponse == 0) {
00091       return -2;
00092     }
00093     
00094     LoadPattern *theLoadPattern = theDomain->getLoadPattern(patternTag);
00095     if (theLoadPattern == 0)
00096       return -3;
00097 
00098     theGroundMotion = theLoadPattern->getMotion(groundMotionTag);
00099     if (theGroundMotion == 0)
00100       return -4;
00101   }
00102   
00103   // now get the response from the ground motion
00104   theGroundMotionResponse = theGroundMotion->getDispVelAccel(time);
00105   
00106   
00107   //
00108   // now set the responses at the node
00109   //
00110   
00111   /* ***********************************************************
00112    * disp response the responsibility of constraint handler
00113    
00114    *theNodeResponse = theNode->getTrialDisp();
00115    (*theNodeResponse)(dofNumber) = theGroundMotionResponse(0);
00116    theNode->setTrialDisp(*theNodeResponse);
00117   *************************************************************/
00118   
00119   *theNodeResponse = theNode->getTrialVel();
00120   (*theNodeResponse)(dofNumber) = theGroundMotionResponse(1);
00121   theNode->setTrialVel(*theNodeResponse);    
00122   
00123   *theNodeResponse = theNode->getTrialAccel();
00124   (*theNodeResponse)(dofNumber) = theGroundMotionResponse(2);
00125   theNode->setTrialAccel(*theNodeResponse);        
00126   
00127   return 0;
00128 }
00129 
00130 
00131 bool
00132 ImposedMotionSP::isHomogeneous(void) const
00133 {
00134   return true;
00135 }
00136 
00137 
00138 int 
00139 ImposedMotionSP::sendSelf(int cTag, Channel &theChannel)
00140 {
00141   int dbTag = this->getDbTag();
00142   int result = 0;
00143   result = this->SP_Constraint::sendSelf(cTag, theChannel);
00144   if (result < 0) {
00145     opserr << "ImposedMotionSP::sendSelf() - base SP_Constraint class failed\n";
00146     return -1;
00147   }
00148   
00149   static ID myExtraData(2);
00150   myExtraData(0) = groundMotionTag;
00151   myExtraData(1) = patternTag;
00152   if (theChannel.sendID(dbTag, cTag, myExtraData) < 0) {
00153     opserr << "ImposedMotionSP::sendSelf() - failed to send extra data\n";
00154     return -1;
00155   }
00156 
00157   return 0;
00158 }
00159 
00160 int 
00161 ImposedMotionSP::recvSelf(int cTag, Channel &theChannel, 
00162                         FEM_ObjectBroker &theBroker)
00163 {
00164   int dbTag = this->getDbTag();
00165   int result = 0;
00166   result = this->SP_Constraint::recvSelf(cTag, theChannel, theBroker);
00167   if (result < 0) {
00168     opserr << "ImposedMotionSP::recvSelf() - base SP_Constraint class failed\n";
00169     return -1;
00170   }
00171   
00172   static ID myExtraData(2);
00173   if (theChannel.recvID(dbTag, cTag, myExtraData) < 0) {
00174     opserr << "ImposedMotionSP::sendSelf() - failed to send extra data\n";
00175     return -1;
00176   }
00177   groundMotionTag = myExtraData(0);
00178   patternTag = myExtraData(1);
00179 
00180   return 0;
00181 }
00182 
00183 void
00184 ImposedMotionSP::Print(OPS_Stream &s, int flag) 
00185 {
00186     s << "ImposedMotionSP: " << this->getTag();
00187     s << "\t Node: " << this->getNodeTag();
00188     s << " DOF: " << this->getDOF_Number() << endln;
00189 }
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 

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