00001
00002
00004
00005 #include "Attalla2D.h"
00006 #include <math.h>
00007
00008 #define ATTALLA_CLASS_TAG -1
00009
00011
00013
00014 Attalla2D::Attalla2D(int tag, double xmax, double ymax,
00015 YS_Evolution &model,
00016 double a01, double a02, double a03,
00017 double a04, double a05, double a06)
00018 :YieldSurface_BC2D(tag, ATTALLA_CLASS_TAG, xmax, ymax, model),
00019 a1(a01), a2(a02), a3(a03), a4(a04), a5(a05), a6(a06), driftAlgo(0)
00020
00021 {
00022
00023 }
00024
00025 Attalla2D::~Attalla2D()
00026 {
00027
00028 }
00029
00031
00033 void Attalla2D::setExtent()
00034 {
00035
00036 xPos = 1;
00037 xNeg = -1;
00038 yPos = 0.98;
00039 yNeg = -0.98;
00040 }
00041
00042
00043 void Attalla2D::getGradient(double &gx, double &gy, double x, double y)
00044 {
00045
00046 double drift = getDrift(x, y);
00047 double loc = forceLocation(drift);
00048 double capx = capXdim;
00049 double capy = capYdim;
00050
00051 if(loc != 0)
00052 {
00053 opserr << "ERROR - Attalla2D::getGradient(double &gx, double &gy, double x, double y)\n";
00054 opserr << "Force point not on yield surface, drift = " << drift << " loc = " << loc <<"\n";
00055 opserr << "\a";
00056 }
00057 else
00058 {
00059 double a = 10.277;
00060 double yt = 0.95;
00061
00062 if(y > yt)
00063 {
00064 gx = 2*a*x/capx;
00065 gy = 1;
00066 }
00067 else if(y < -yt)
00068 {
00069 gx = 2*a*x/capx;
00070 gy = -1;
00071 }
00072 else
00073 {
00074 gx = 6*a2*pow(x,5)/capx + 4*a4*pow(x,3)/capx + 2*a6*x/capx;
00075 gy = 6*a1*pow(y,5)/capy + 4*a3*pow(y,3)/capy + 2*a5*y/capy;
00076 }
00077 }
00078
00079 }
00080
00081 double Attalla2D::getSurfaceDrift(double x, double y)
00082 {
00083 double phi;
00084 double a = 10.277;
00085 double yt = 0.95, xt = 0.054029;
00086
00087 if(y > yt && fabs(x) < fabs(y)*xt/yt)
00088 {
00089 phi = a*x*x + y + 0.02;
00090 }
00091 else if(y < -yt && fabs(x) < fabs(y)*xt/yt)
00092 {
00093 phi = a*x*x - y + 0.02;
00094 }
00095 else
00096 {
00097 phi = a1*pow(y,6) + a2*pow(x,6) + a3*pow(y,4) + a4*pow(x,4) + a5*y*y + a6*x*x;
00098 }
00099
00100 double drift = phi - 1;
00101 return drift;
00102 }
00103
00104
00105 void Attalla2D::customizeInterpolate(double &xi, double &yi, double &xj, double &yj)
00106 {
00107 this->YieldSurface_BC2D::customizeInterpolate(xi, yi, xj, yj);
00108
00109 double yt = 0.95, xt = 0.054029;
00110
00111 if(fabs(yj) >= yt && fabs(xj) < fabs(yj)*xt/yt)
00112 {
00113 xi = 0;
00114 yi = 0;
00115 }
00116 }
00117
00118
00119 YieldSurface_BC *Attalla2D::getCopy(void)
00120 {
00121 Attalla2D *theCopy = new Attalla2D(this->getTag(), capX, capY, *hModel,
00122 a1, a2, a3, a4, a5, a6);
00123
00124 return theCopy;
00125 }
00126
00127 int Attalla2D::displaySelf(Renderer &theViewer, int displayMode, float fact)
00128 {
00129 this->YieldSurface_BC2D::displaySelf(theViewer, displayMode, fact);
00130
00131
00132
00133 Vector pOld(3), pCurr(3);
00134 Vector rgb(3);
00135 rgb(0) = 0.1; rgb(1) = 0.5; rgb(2) = 0.5;
00136 double incr = 0.02;
00137 double x1, y1, xOld, yOld, x2, y2;
00138 double t;
00139
00140 if(fact < 1) incr = fact;
00141 xOld = 0;
00142
00143
00144 t = interpolate(0, 0, 0, 1);
00145 yOld = t*1;
00146
00147 double x, y = 0;
00148 double err = 1e-5;
00149
00150 for(double xc = 0; xc <= 1+err; xc = xc+incr)
00151 {
00152 if(xc > 1) xc = int(1);
00153 double yc = sqrt(1 - xc*xc);
00154
00155 t = interpolate(0, 0, xc, yc);
00156 x = t*xc;
00157 y = t*yc;
00158
00159 if( fact >=1 && x > 0.9) incr = 0.005;
00160
00161 if(x < 0.06 || x > 0.9)
00162 {
00163
00165 x1 = x;
00166 y1 = y;
00167 hModel->toDeformedCoord(x1, y1);
00168 if(displayMode==100)
00169 {
00170 opserr << " x = " << x << ", y = " << y << " ";
00171 opserr << " x1 = " << x1 << ", y1 = " << y1 << "\n";
00172 }
00173 pCurr(0) = x1;
00174 pCurr(1) = y1;
00175
00176 x2 = xOld;
00177 y2 = yOld;
00178 hModel->toDeformedCoord(x2, y2);
00179 pOld(0) = x2;
00180 pOld(1) = y2;
00181 theViewer.drawLine(pOld, pCurr, rgb, rgb);
00182
00183
00185 x1 = -1*x;
00186 y1 = y;
00187 hModel->toDeformedCoord(x1, y1);
00188 pCurr(0) = x1;
00189 pCurr(1) = y1;
00190
00191 x2 = -1*xOld;
00192 y2 = yOld;
00193 hModel->toDeformedCoord(x2, y2);
00194 pOld(0) = x2;
00195 pOld(1) = y2;
00196
00197 theViewer.drawLine(pOld, pCurr, rgb, rgb);
00198
00200 x1 = x;
00201 y1 = -1*y;
00202 hModel->toDeformedCoord(x1, y1);
00203 pCurr(0) = x1;
00204 pCurr(1) = y1;
00205
00206 x2 = xOld;
00207 y2 = -1*yOld;
00208 hModel->toDeformedCoord(x2, y2);
00209 pOld(0) = x2;
00210 pOld(1) = y2;
00211
00212 theViewer.drawLine(pOld, pCurr, rgb, rgb);
00213
00215 x1 = -1*x;
00216 y1 = -1*y;
00217 hModel->toDeformedCoord(x1, y1);
00218 pCurr(0) = x1;
00219 pCurr(1) = y1;
00220
00221 x2 = -1*xOld;
00222 y2 = -1*yOld;
00223 hModel->toDeformedCoord(x2, y2);
00224 pOld(0) = x2;
00225 pOld(1) = y2;
00226
00227 theViewer.drawLine(pOld, pCurr, rgb, rgb);
00228
00229
00230 xOld = x;
00231 yOld = y;
00232 }
00233
00234 }
00235
00236
00237 return 0;
00238 }
00239
00240 void Attalla2D::Print(OPS_Stream &s, int flag)
00241 {
00242 s << "\nYield Surface No: " << this->getTag() << " type: Attalla2D\n";
00243 }
00244