00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
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
00044 ImposedMotionSP::ImposedMotionSP()
00045 :SP_Constraint(CNSTRNT_TAG_ImposedMotionSP),
00046 theGroundMotion(0), theNode(0), theNodeResponse(0),
00047 theGroundMotionResponse(3), destroyMotion(0)
00048 {
00049
00050 }
00051
00052
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
00080 return theGroundMotionResponse(0);
00081 }
00082
00083
00084 int
00085 ImposedMotionSP::applyConstraint(double time)
00086 {
00087
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
00106 theGroundMotionResponse = theGroundMotion->getDispVelAccel(time);
00107
00108
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