ImposedMotionSP1.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/11/22 19:41:17 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/domain/constraints/ImposedMotionSP1.cpp,v $
00024                                                                         
00025 // Written: fmk 
00026 // Created: 11/00
00027 // Revision: A
00028 //
00029 // Purpose: This file contains the implementation of class ImposedMotionSP1.
00030 
00031 #include <ImposedMotionSP1.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 ImposedMotionSP1::ImposedMotionSP1()
00044 :SP_Constraint(CNSTRNT_TAG_ImposedMotionSP1),
00045  theGroundMotion(0), theNode(0), theGroundMotionResponse(3), destroyMotion(0)
00046 {
00047     // does nothing else
00048 }
00049 
00050 // constructor for a subclass to use
00051 ImposedMotionSP1::ImposedMotionSP1(int tag, int node, int ndof, int pattern, int motion)
00052 :SP_Constraint(tag, node, ndof, CNSTRNT_TAG_ImposedMotionSP1),
00053  groundMotionTag(motion), patternTag(pattern),
00054  theGroundMotion(0), theNode(0), theGroundMotionResponse(3)
00055 {
00056 
00057 }
00058 
00059 
00060 ImposedMotionSP1::~ImposedMotionSP1()
00061 {
00062 
00063 }
00064 
00065 
00066 
00067 double
00068 ImposedMotionSP1::getValue(void)
00069 {
00070   // always return 0.0 - applyConstraint() sets the values at Node 
00071     return theGroundMotionResponse(0);
00072 }
00073 
00074 
00075 int
00076 ImposedMotionSP1::applyConstraint(double time)
00077 {
00078   // on first 
00079   if (theGroundMotion == 0 || theNode == 0) {
00080     Domain *theDomain = this->getDomain();
00081     
00082     theNode = theDomain->getNode(nodeTag);
00083     if (theNode == 0) {
00084       
00085       return -1;
00086     }
00087     LoadPattern *theLoadPattern = theDomain->getLoadPattern(patternTag);
00088     if (theLoadPattern == 0)
00089       return -3;
00090     
00091     theGroundMotion = theLoadPattern->getMotion(groundMotionTag);
00092     if (theGroundMotion == 0)
00093       return -4;
00094     }
00095 
00096     // now get the response from the ground motion
00097     theGroundMotionResponse = theGroundMotion->getDispVelAccel(time);
00098 
00099     return 0;
00100 }
00101 
00102 
00103 bool
00104 ImposedMotionSP1::isHomogeneous(void) const
00105 {
00106   return false;
00107 }
00108 
00109 
00110 int 
00111 ImposedMotionSP1::sendSelf(int cTag, Channel &theChannel)
00112 {
00113   int dbTag = this->getDbTag();
00114   int result = 0;
00115   result = this->SP_Constraint::sendSelf(cTag, theChannel);
00116   if (result < 0) {
00117     opserr << "ImposedMotionSP1::sendSelf() - base SP_Constraint class failed\n";
00118     return -1;
00119   }
00120   
00121   static ID myExtraData(2);
00122   myExtraData(0) = groundMotionTag;
00123   myExtraData(1) = patternTag;
00124   if (theChannel.sendID(dbTag, cTag, myExtraData) < 0) {
00125     opserr << "ImposedMotionSP1::sendSelf() - failed to send extra data\n";
00126     return -1;
00127   }
00128 
00129   return 0;
00130 }
00131 
00132 int 
00133 ImposedMotionSP1::recvSelf(int cTag, Channel &theChannel, 
00134                         FEM_ObjectBroker &theBroker)
00135 {
00136   int dbTag = this->getDbTag();
00137   int result = 0;
00138   result = this->SP_Constraint::recvSelf(cTag, theChannel, theBroker);
00139   if (result < 0) {
00140     opserr << "ImposedMotionSP1::recvSelf() - base SP_Constraint class failed\n";
00141     return -1;
00142   }
00143   
00144   static ID myExtraData(2);
00145   if (theChannel.recvID(dbTag, cTag, myExtraData) < 0) {
00146     opserr << "ImposedMotionSP::sendSelf() - failed to send extra data\n";
00147     return -1;
00148   }
00149   groundMotionTag = myExtraData(0);
00150   patternTag = myExtraData(1);
00151 
00152   return 0;
00153 }
00154 
00155 void
00156 ImposedMotionSP1::Print(OPS_Stream &s, int flag) 
00157 {
00158     s << "ImposedMotionSP1: " << this->getTag();
00159     s << "\t Node: " << this->getNodeTag();
00160     s << " DOF: " << this->getDOF_Number() << endln;    
00161 }
00162 
00163 
00164 
00165 
00166 
00167 
00168 
00169 

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