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 <MultiSupportPattern.h>
00032 #include <GroundMotion.h>
00033
00034 #include <Domain.h>
00035 #include <SP_Constraint.h>
00036 #include <SP_ConstraintIter.h>
00037 #include <stdlib.h>
00038 #include <Channel.h>
00039 #include <ErrorHandler.h>
00040
00041 MultiSupportPattern::MultiSupportPattern(int tag, int _classTag)
00042 :LoadPattern(tag, _classTag),
00043 theMotions(0), theMotionTags(0,16), numMotions(0)
00044 {
00045
00046 }
00047
00048
00049 MultiSupportPattern::MultiSupportPattern(int tag)
00050 :LoadPattern(tag, PATTERN_TAG_MultiSupportPattern),
00051 theMotions(0), theMotionTags(0,16), numMotions(0)
00052 {
00053
00054 }
00055
00056
00057 MultiSupportPattern::~MultiSupportPattern()
00058 {
00059
00060 for (int i=0; i<numMotions; i++)
00061 delete theMotions[i];
00062
00063 if (theMotions != 0)
00064
00065 delete [] theMotions;
00066 }
00067
00068
00069
00070 void
00071 MultiSupportPattern::applyLoad(double time)
00072 {
00073 SP_Constraint *sp;
00074 SP_ConstraintIter &theIter = this->getSPs();
00075 while ((sp = theIter()) != 0)
00076 sp->applyConstraint(time);
00077 }
00078
00079
00080 int
00081 MultiSupportPattern::addMotion(GroundMotion &theMotion, int tag)
00082 {
00083
00084 if (theMotionTags.getLocation(tag) >= 0) {
00085 cerr << "MultiSupportPattern::addMotion - could not add new, motion wih same tag exists\n";
00086 return -1;
00087 }
00088
00089
00090 GroundMotion **newMotions = new GroundMotion *[numMotions+1];
00091
00092 if (newMotions == 0) {
00093 cerr << "MultiSupportPattern::addMotion - could not add new, out of mem\n";
00094 return -1;
00095 }
00096
00097
00098 for (int i=0; i<numMotions; i++)
00099 newMotions[i] = theMotions[i];
00100
00101
00102 newMotions[numMotions] = &theMotion;
00103
00104
00105 if (theMotions != 0)
00106 delete [] theMotions;
00107
00108
00109 theMotions = newMotions;
00110 theMotionTags[numMotions] = tag;
00111 numMotions++;
00112
00113 return 0;
00114 }
00115
00116
00117
00118 GroundMotion *
00119 MultiSupportPattern::getMotion(int tag)
00120 {
00121 int loc = theMotionTags.getLocation(tag);
00122 if (loc < 0)
00123 return 0;
00124 else
00125 return theMotions[loc];
00126
00127 }
00128
00129
00130 bool
00131 MultiSupportPattern::addNodalLoad(NodalLoad *)
00132 {
00133 cerr << "MultiSupportPattern::addNodalLoad() - cannot add NodalLoad to EQ pattern\n";
00134 return false;
00135 }
00136
00137 bool
00138 MultiSupportPattern::addElementalLoad(ElementalLoad *)
00139 {
00140 cerr << "MultiSupportPattern::addElementalLoad() - cannot add ElementalLoad to EQ pattern\n";
00141 return false;
00142 }
00143
00144
00145
00146 int
00147 MultiSupportPattern::sendSelf(int commitTag, Channel &theChannel)
00148 {
00149 return -1;
00150 }
00151
00152 int
00153 MultiSupportPattern::recvSelf(int commitTag, Channel &theChannel,
00154 FEM_ObjectBroker &theBroker)
00155 {
00156 return -1;
00157 }
00158
00159 void
00160 MultiSupportPattern::Print(ostream &s, int flag)
00161 {
00162 s << "MultiSupportPattern tag: " << this->getTag() << endl;
00163 SP_Constraint *sp;
00164 SP_ConstraintIter &theIter = this->getSPs();
00165 while ((sp = theIter()) != 0)
00166 sp->Print(s, flag);
00167 }
00168
00169 LoadPattern *
00170 MultiSupportPattern::getCopy(void)
00171 {
00172 LoadPattern *theCopy = new MultiSupportPattern(this->getTag());
00173 return theCopy;
00174 }