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 #include <DistHingeIntegration.h>
00026 #include <ElementalLoad.h>
00027
00028 #include <Matrix.h>
00029 #include <Vector.h>
00030 #include <Channel.h>
00031 #include <FEM_ObjectBroker.h>
00032 #include <Information.h>
00033 #include <Parameter.h>
00034
00035 DistHingeIntegration::DistHingeIntegration(double lpi,
00036 double lpj,
00037 BeamIntegration &bi):
00038 BeamIntegration(BEAM_INTEGRATION_TAG_HingeMidpoint),
00039 lpI(lpi), lpJ(lpj), beamInt(0)
00040 {
00041 beamInt = bi.getCopy();
00042 if (beamInt == 0) {
00043 opserr << "DistHingeIntegration::DistHingeIntegration -- failed to get copy of BeamIntegration" << endln;
00044 }
00045 }
00046
00047 DistHingeIntegration::DistHingeIntegration():
00048 BeamIntegration(BEAM_INTEGRATION_TAG_HingeMidpoint),
00049 lpI(0.0), lpJ(0.0), beamInt(0)
00050 {
00051
00052 }
00053
00054 DistHingeIntegration::~DistHingeIntegration()
00055 {
00056 if (beamInt != 0)
00057 delete beamInt;
00058 }
00059
00060 void
00061 DistHingeIntegration::getSectionLocations(int numSections, double L,
00062 double *xi)
00063 {
00064 int numPerHinge = numSections/2;
00065
00066 beamInt->getSectionLocations(numPerHinge, L, xi);
00067
00068 double betaI = lpI/L;
00069 double betaJ = lpJ/L;
00070
00071
00072 for (int i = 0; i < numPerHinge; i++) {
00073 xi[numSections-1-i] = 1.0-betaJ*xi[i];
00074 xi[i] *= betaI;
00075 }
00076
00077 opserr << "DistHingeIntegration::getSectionLocations -- implementation for interior not yet finished" << endln;
00078 }
00079
00080 void
00081 DistHingeIntegration::getSectionWeights(int numSections, double L,
00082 double *wt)
00083 {
00084 int numPerHinge = numSections/2;
00085
00086 beamInt->getSectionWeights(numPerHinge, L, wt);
00087
00088 double betaI = lpI/L;
00089 double betaJ = lpJ/L;
00090
00091
00092 for (int i = 0; i < numPerHinge; i++) {
00093 wt[numSections-1-i] = betaJ*wt[i];
00094 wt[i] *= betaI;
00095 }
00096
00097 opserr << "DistHingeIntegration::getSectionWeights -- implementation for interior not yet finished" << endln;
00098 }
00099
00100 BeamIntegration*
00101 DistHingeIntegration::getCopy(void)
00102 {
00103 return new DistHingeIntegration(lpI, lpJ, *beamInt);
00104 }
00105
00106 int
00107 DistHingeIntegration::sendSelf(int cTag, Channel &theChannel)
00108 {
00109 static Vector data(2);
00110
00111 data(0) = lpI;
00112 data(1) = lpJ;
00113
00114 int dbTag = this->getDbTag();
00115
00116 if (theChannel.sendVector(dbTag, cTag, data) < 0) {
00117 opserr << "DistHingeIntegration::sendSelf() - failed to send Vector data\n";
00118 return -1;
00119 }
00120
00121 return 0;
00122 }
00123
00124 int
00125 DistHingeIntegration::recvSelf(int cTag, Channel &theChannel,
00126 FEM_ObjectBroker &theBroker)
00127 {
00128 static Vector data(2);
00129
00130 int dbTag = this->getDbTag();
00131
00132 if (theChannel.recvVector(dbTag, cTag, data) < 0) {
00133 opserr << "DistHingeIntegration::recvSelf() - failed to receive Vector data\n";
00134 return -1;
00135 }
00136
00137 lpI = data(0);
00138 lpJ = data(1);
00139
00140 return 0;
00141 }
00142
00143 int
00144 DistHingeIntegration::setParameter(const char **argv, int argc,
00145 Parameter ¶m)
00146 {
00147 if (argc < 1)
00148 return -1;
00149
00150 if (strcmp(argv[0],"lpI") == 0)
00151 return param.addObject(1, this);
00152
00153 if (strcmp(argv[0],"lpJ") == 0)
00154 return param.addObject(2, this);
00155
00156 if (strcmp(argv[0],"lp") == 0)
00157 return param.addObject(3, this);
00158
00159 return -1;
00160 }
00161
00162 int
00163 DistHingeIntegration::updateParameter(int parameterID, Information &info)
00164 {
00165 switch (parameterID) {
00166 case 1:
00167 lpI = info.theDouble;
00168 return 0;
00169 case 2:
00170 lpJ = info.theDouble;
00171 return 0;
00172 case 3:
00173 lpI = lpJ = info.theDouble;
00174 return 0;
00175 default:
00176 return -1;
00177 }
00178 }
00179
00180 int
00181 DistHingeIntegration::activateParameter(int paramID)
00182 {
00183 parameterID = paramID;
00184
00185 return 0;
00186 }
00187
00188 void
00189 DistHingeIntegration::Print(OPS_Stream &s, int flag)
00190 {
00191 s << "DistHinge" << endln;
00192 s << " lpI = " << lpI;
00193 s << " lpJ = " << lpJ << endln;
00194
00195 beamInt->Print(s, flag);
00196
00197 return;
00198 }
00199
00200 void
00201 DistHingeIntegration::getLocationsDeriv(int numSections, double L,
00202 double dLdh, double *dptsdh)
00203 {
00204 int numPerHinge = numSections/2;
00205
00206 double oneOverL = 1/L;
00207 double betaI = lpI*oneOverL;
00208 double betaJ = lpJ*oneOverL;
00209
00210 beamInt->getSectionLocations(numPerHinge, L, dptsdh);
00211
00212 if (parameterID == 1) {
00213 for (int i = 0; i < numPerHinge; i++) {
00214 dptsdh[i] = oneOverL*dptsdh[i];
00215 dptsdh[numSections-1-i] = 0.0;
00216 }
00217 }
00218 else if (parameterID == 2) {
00219 for (int i = 0; i < numPerHinge; i++) {
00220 dptsdh[numSections-1-i] = -oneOverL*dptsdh[i];
00221 dptsdh[i] = 0.0;
00222 }
00223 }
00224 else if (dLdh != 0.0) {
00225 for (int i = 0; i < numPerHinge; i++) {
00226 dptsdh[numSections-1-i] = betaJ*oneOverL*dLdh*dptsdh[i];
00227 dptsdh[i] = -betaI*oneOverL*dLdh*dptsdh[i];
00228 }
00229 }
00230 else {
00231 for (int i = 0; i < numSections; i++)
00232 dptsdh[i] = 0.0;
00233 }
00234
00235 return;
00236 }
00237
00238 void
00239 DistHingeIntegration::getWeightsDeriv(int numSections, double L,
00240 double dLdh, double *dwtsdh)
00241 {
00242 int numPerHinge = numSections/2;
00243
00244 double oneOverL = 1/L;
00245 double betaI = lpI*oneOverL;
00246 double betaJ = lpJ*oneOverL;
00247
00248 beamInt->getSectionWeights(numPerHinge, L, dwtsdh);
00249
00250 if (parameterID == 1) {
00251 for (int i = 0; i < numPerHinge; i++) {
00252 dwtsdh[i] = oneOverL*dwtsdh[i];
00253 dwtsdh[numSections-1-i] = 0.0;
00254 }
00255 }
00256 else if (parameterID == 2) {
00257 for (int i = 0; i < numPerHinge; i++) {
00258 dwtsdh[numSections-1-i] = oneOverL*dwtsdh[i];
00259 dwtsdh[i] = 0.0;
00260 }
00261 }
00262 else if (dLdh != 0.0) {
00263 for (int i = 0; i < numPerHinge; i++) {
00264 dwtsdh[numSections-1-i] = -betaJ*oneOverL*dLdh*dwtsdh[i];
00265 dwtsdh[i] = -betaI*oneOverL*dLdh*dwtsdh[i];
00266 }
00267 }
00268 else {
00269 for (int i = 0; i < numSections; i++)
00270 dwtsdh[i] = 0.0;
00271 }
00272
00273 return;
00274 }