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 #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
00043 ImposedMotionSP1::ImposedMotionSP1()
00044 :SP_Constraint(CNSTRNT_TAG_ImposedMotionSP1),
00045 theGroundMotion(0), theNode(0), theGroundMotionResponse(3), destroyMotion(0)
00046 {
00047
00048 }
00049
00050
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
00071 return theGroundMotionResponse(0);
00072 }
00073
00074
00075 int
00076 ImposedMotionSP1::applyConstraint(double time)
00077 {
00078
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
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