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

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.2 $
00022 // $Date: 2001/01/11 06:46:01 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/domain/constraints/ImposedMotionSP.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/domain/constraints/ImposedMotionSP.C
00027 //
00028 // Written: fmk 
00029 // Created: 11/00
00030 // Revision: A
00031 //
00032 // Purpose: This file contains the implementation of class ImposedMotionSP.
00033 
00034 #include <ImposedMotionSP.h>
00035 #include <classTags.h>
00036 #include <Vector.h>
00037 #include <Channel.h>
00038 #include <FEM_ObjectBroker.h>
00039 #include <GroundMotion.h>
00040 #include <Node.h>
00041 #include <Domain.h>
00042 
00043 // constructor for FEM_ObjectBroker
00044 ImposedMotionSP::ImposedMotionSP()
00045 :SP_Constraint(CNSTRNT_TAG_ImposedMotionSP),
00046  theGroundMotion(0), theNode(0), theNodeResponse(0), 
00047  theGroundMotionResponse(3), destroyMotion(0) 
00048 {
00049     // does nothing else
00050 }
00051 
00052 // constructor for a subclass to use
00053 ImposedMotionSP::ImposedMotionSP(int tag, int node, int ndof, 
00054      GroundMotion &theMotion, bool killMotion)
00055 :SP_Constraint(tag, node, ndof, CNSTRNT_TAG_ImposedMotionSP),
00056  theNode(0), theNodeResponse(0), theGroundMotionResponse(3), destroyMotion(0)
00057 {
00058   theGroundMotion = &theMotion;
00059   
00060   if (killMotion == true)
00061     destroyMotion = 1;
00062 }
00063 
00064 
00065 ImposedMotionSP::~ImposedMotionSP()
00066 {
00067   if (theNodeResponse != 0)
00068     delete theNodeResponse;
00069 
00070   if (destroyMotion == 1)
00071     delete theGroundMotion;
00072 }
00073 
00074 
00075 
00076 double
00077 ImposedMotionSP::getValue(void)
00078 {
00079   // no longer return 0 for TransformationConstraints also set response at nodes
00080     return theGroundMotionResponse(0);    
00081 }
00082 
00083 
00084 int
00085 ImposedMotionSP::applyConstraint(double time)
00086 {
00087     // on first 
00088     if (theNode == 0 || theNodeResponse) {
00089  Domain *theDomain = this->getDomain();
00090 
00091  theNode = theDomain->getNode(nodeTag);
00092  if (theNode == 0) {
00093      
00094      return -1;
00095  }
00096 
00097  theNodeResponse = new Vector(theNode->getNumberDOF());
00098  if (theNodeResponse == 0) {
00099      
00100      return -2;
00101  }
00102 
00103     }
00104 
00105     // now get the response from the ground motion
00106     theGroundMotionResponse = theGroundMotion->getDispVelAccel(time);
00107     
00108     // now set the responses at the node
00109     *theNodeResponse = theNode->getTrialDisp();
00110     (*theNodeResponse)(dofNumber) = theGroundMotionResponse(0);
00111     theNode->setTrialDisp(*theNodeResponse);
00112 
00113     *theNodeResponse = theNode->getTrialVel();
00114     (*theNodeResponse)(dofNumber) = theGroundMotionResponse(1);
00115     theNode->setTrialVel(*theNodeResponse);    
00116     
00117     *theNodeResponse = theNode->getTrialAccel();
00118     (*theNodeResponse)(dofNumber) = theGroundMotionResponse(2);
00119     theNode->setTrialAccel(*theNodeResponse);        
00120 
00121     return 0;
00122 }
00123 
00124 
00125 bool
00126 ImposedMotionSP::isHomogeneous(void) const
00127 {
00128   return true;
00129 }
00130 
00131 
00132 int 
00133 ImposedMotionSP::sendSelf(int cTag, Channel &theChannel)
00134 {
00135   return -1;
00136 }
00137 
00138 int 
00139 ImposedMotionSP::recvSelf(int cTag, Channel &theChannel, 
00140    FEM_ObjectBroker &theBroker)
00141 {
00142   return -1;
00143 }
00144 
00145 void
00146 ImposedMotionSP::Print(ostream &s, int flag) 
00147 {
00148     s << "ImposedMotionSP: " << this->getTag();
00149     s << "\t Node: " << this->getNodeTag();
00150     s << " DOF: " << this->getDOF_Number() << endl;
00151 }
00152 
00153 
00154 
00155 
00156 
00157 
00158 
00159 
Copyright Contact Us