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 #include <ThreePointCurve.h>
00030 #include <G3Globals.h>
00031 #include <math.h>
00032 #include <ElementResponse.h>
00033 #include <Element.h>
00034 #include <Node.h>
00035 #include <Domain.h>
00036 #include <Vector.h>
00037 #include <float.h>
00038
00039 #include <DummyStream.h>
00040
00041 ThreePointCurve::ThreePointCurve(int tag, int eTag, Domain *theDom,
00042 double a1, double b1, double a2, double b2,
00043 double a3, double b3, double Kd, double Fr,
00044 int dType, int fType,
00045 int ni, int nj, int df, int dirn):
00046 LimitCurve(tag, TAG_ThreePointCurve), eleTag(eTag), theDomain(theDom), theElement(0),
00047 Kdeg(Kd), Fres(Fr), defType(dType), forType(fType),
00048 x1(a1), y1(b1), x2(a2), y2(b2), x3(a3), y3(b3),
00049 ndI(ni), ndJ(nj), dof(df), perpDirn(dirn)
00050 {
00051 stateFlag = 0;
00052 count = 0;
00053
00054 }
00055
00056 ThreePointCurve::ThreePointCurve():
00057 LimitCurve(0, TAG_ThreePointCurve), eleTag(0), theDomain(0), theElement(0),
00058 Kdeg(0), Fres(0), defType(0), forType(0),
00059 x1(0), y1(0), x2(0), y2(0), x3(0), y3(0)
00060 {
00061
00062 }
00063
00064 ThreePointCurve::~ThreePointCurve()
00065 {
00066
00067 }
00068
00069
00070 LimitCurve*
00071 ThreePointCurve::getCopy(void)
00072 {
00073 ThreePointCurve *theCopy = new ThreePointCurve(this->getTag(),
00074 eleTag, theDomain, x1, y1, x2, y2, x3, y3,
00075 Kdeg, Fres, defType, forType, ndI, ndJ, dof, perpDirn);
00076
00077 theCopy->stateFlag = stateFlag;
00078
00079 return theCopy;
00080 }
00081
00082
00083
00084 int
00085 ThreePointCurve::checkElementState(double springForce)
00086 {
00087 DummyStream dummy;
00088
00089 if (theElement == 0)
00090 {
00091 theElement = theDomain->getElement(eleTag);
00092
00093 if (theElement == 0)
00094
00095
00096
00097 if (defType == 2)
00098 {
00099 Node *nodeI = theDomain->getNode(ndI);
00100 Node *nodeJ = theDomain->getNode(ndJ);
00101
00102 const Vector &crdI = nodeI->getCrds();
00103 const Vector &crdJ = nodeJ->getCrds();
00104
00105 if (crdI(perpDirn) == crdJ(perpDirn)) {
00106
00107
00108
00109 oneOverL = 0.0;
00110 }
00111 else
00112 oneOverL = 1.0/fabs(crdJ(perpDirn) - crdI(perpDirn));
00113 }
00114 }
00115
00116 double deform;
00117 double force;
00118 int result;
00119
00120
00121
00122
00123 if (defType == 1)
00124 {
00125
00126 Response *theRotations =0;
00127
00128
00129 const char *r[1] = {"basicDeformations"};
00130 Information *rotInfoObject =0;
00131 Vector *rotVec;
00132
00133
00134 theRotations = theElement->setResponse(r, 1, *rotInfoObject, dummy);
00135
00136
00137 result = theRotations->getResponse();
00138
00139
00140 Information &theInfo = theRotations->getInformation();
00141 rotVec = (theInfo.theVector);
00142
00143 deform = (fabs((*rotVec)(1)) > fabs((*rotVec)(2))) ?
00144 fabs((*rotVec)(1)) : fabs((*rotVec)(2));
00145 }
00146 else if (defType == 2)
00147 {
00148
00149 Node *nodeI = theDomain->getNode(ndI);
00150 Node *nodeJ = theDomain->getNode(ndJ);
00151
00152
00153 const Vector &dispI = nodeI->getTrialDisp();
00154 const Vector &dispJ = nodeJ->getTrialDisp();
00155
00156
00157 double dx = fabs(dispJ(dof)-dispI(dof));
00158 deform = dx*oneOverL;
00159 }
00160 else {
00161
00162 }
00163
00164 Response *theForces =0;
00165 const char *f[1] = {"localForce"};
00166 Information *forInfoObject =0;
00167 Vector *forceVec;
00168
00169
00170 theForces = theElement->setResponse(f, 1, *forInfoObject, dummy);
00171
00172
00173 result += theForces->getResponse();
00174
00175
00176 Information &theInfo = theForces->getInformation();
00177 forceVec = (theInfo.theVector);
00178
00179
00180 if (forType == 0)
00181 force = fabs(springForce);
00182 else if (forType == 1)
00183 force = fabs((*forceVec)(1));
00184 else if (forType == 2)
00185 force = fabs((*forceVec)(0));
00186 else {
00187
00188 }
00189
00190
00191
00192
00193
00194 double forceSurface = findLimit(deform);
00195
00196 count += 1;
00197
00198 if (stateFlag == 0)
00199 {
00200 if (force >= forceSurface)
00201 {
00202 stateFlag = 1;
00203
00204
00205 }
00206 else
00207 {
00208 stateFlag = 0;
00209 }
00210 }
00211 else
00212 {
00213 if (force >= forceSurface)
00214 {
00215 stateFlag = 2;
00216
00217 }
00218 else
00219 {
00220 stateFlag = 3;
00221 }
00222 }
00223
00224 return stateFlag;
00225 }
00226
00227
00228 double
00229 ThreePointCurve::getDegSlope(void)
00230 {
00231 return Kdeg;
00232 }
00233
00234
00235 double
00236 ThreePointCurve::getResForce(void)
00237 {
00238 return Fres;
00239 }
00240
00241 double
00242 ThreePointCurve::getUnbalanceForce(void)
00243 {
00244
00245 return 0.0;
00246 }
00247
00248 int
00249 ThreePointCurve::sendSelf(int commitTag, Channel &theChannel)
00250 {
00251 return -1;
00252 }
00253
00254 int
00255 ThreePointCurve::recvSelf(int commitTag, Channel &theChannel,
00256 FEM_ObjectBroker &theBroker)
00257 {
00258 return -1;
00259 }
00260
00261 void
00262 ThreePointCurve::Print(OPS_Stream &s, int flag)
00263 {
00264 s << "Three-Point Limit Curve, tag: " << this->getTag() << endln;
00265 s << "x1,y1: " << x1 <<", "<< y1 << endln;
00266 s << "x2,y2: " << x2 <<", "<< y2 << endln;
00267 s << "x3,y3: " << x3 <<", "<< y3 << endln;
00268 s << "eleTag: " << eleTag << endln;
00269 s << "nodeI: " << ndI << endln;
00270 s << "nodeJ: " << ndJ << endln;
00271 s << "deform: " << defType << endln;
00272 s << "force: " << forType << endln;
00273 }
00274
00275
00276
00277
00278
00279 double
00280 ThreePointCurve::findLimit(double x)
00281 {
00282 double y = 0.0;
00283
00284 if (x < x1) {
00285
00286 }
00287 else if (x < x2)
00288 y = y1+(y2-y1)/(x2-x1)*(x-x1);
00289 else if (x < x3)
00290 y = y2+(y3-y2)/(x3-x2)*(x-x2);
00291 else
00292 y = y3;
00293
00294 return y;
00295 }
00296
00297
00298
00299 int ThreePointCurve::revertToStart ()
00300 {
00301 return 0;
00302 }