T2Vector.cpp

Go to the documentation of this file.
00001 // $Revision: 1.10 $
00002 // $Date: 2003/02/14 23:01:32 $
00003 // $Source: /usr/local/cvs/OpenSees/SRC/material/nD/soil/T2Vector.cpp,v $
00004                                                                         
00005 // Written: ZHY
00006 // Created: August 2000
00007 
00008 //
00009 // T2Vector.cpp
00010 // ----------
00011 //
00012 #include <math.h>
00013 #include <float.h>
00014 #include <stdlib.h>
00015 #include <T2Vector.h>
00016 
00017 
00018 Vector T2Vector::engrgStrain(6);
00019 
00020 double operator && (const Vector & a, const Vector & b)
00021 {
00022   if (a.Size() !=6 || b.Size() !=6) {
00023     opserr << "FATAL:operator && (Vector &, Vector &): vector size not equal 6" << endln;
00024     exit(-1);
00025   }
00026 
00027   double result = 0.;  
00028 
00029   for (int i=0; i<3; i++)
00030     result += a[i]*b[i] + 2*a[i+3]*b[i+3];
00031   return result;
00032 }
00033 
00034 
00035 // T2Vector class methods
00036 T2Vector::T2Vector() 
00037 :theT2Vector(6), theDeviator(6), theVolume(0.0)
00038 {
00039         
00040 }
00041 
00042 
00043 T2Vector::T2Vector(const Vector &init, int isEngrgStrain)
00044 :theT2Vector(6), theDeviator(6), theVolume(0)
00045 {
00046   if (init.Size() != 6) {
00047     opserr << "FATAL:T2Vector::T2Vector(Vector &): vector size not equal to 6" << endln;
00048     exit(-1);
00049   }
00050   theT2Vector = init;
00051 
00052   theVolume = (theT2Vector[0]+theT2Vector[1]+theT2Vector[2])/3.0;
00053   for(int i=0; i<3; i++){
00054     theDeviator[i] = theT2Vector[i] - theVolume;
00055     theDeviator[i+3] = theT2Vector[i+3];
00056     if (isEngrgStrain==1) {
00057       theDeviator[i+3] /= 2.;
00058       theT2Vector[i+3] /= 2.;
00059     }
00060   }
00061 }
00062 
00063 
00064 T2Vector::T2Vector(const Vector & deviat_init, double volume_init)
00065  : theT2Vector(6), theDeviator(6), theVolume(volume_init)
00066 {
00067   if (deviat_init.Size() != 6) {
00068     opserr << "FATAL:T2Vector::T2Vector(Vector &, double): vector size not equal 6" << endln;
00069     exit(-1);
00070   }
00071 
00072   //make sure the deviator has truely volume=0 
00073   double devolum = (deviat_init[0]+deviat_init[1]+deviat_init[2])/3.;
00074 
00075   for(int i=0; i<3; i++){
00076     theDeviator[i] = deviat_init[i] - devolum;
00077     theDeviator[i+3] = deviat_init[i+3];
00078     theT2Vector[i] = theDeviator[i] + theVolume;
00079     theT2Vector[i+3] = theDeviator[i+3]; 
00080   }
00081 }
00082 
00083 
00084 T2Vector::~T2Vector()
00085 {
00086 
00087 }
00088 
00089 
00090 void
00091 T2Vector::setData(const Vector &init, int isEngrgStrain)
00092 {
00093   if ( init.Size() != 6) {
00094     opserr << "FATAL:T2Vector::T2Vector(Vector &): vector size not equal to 6" << endln;
00095     exit(-1);
00096   }
00097   theT2Vector = init;
00098 
00099   theVolume = (theT2Vector[0]+theT2Vector[1]+theT2Vector[2])/3.0;
00100   for(int i=0; i<3; i++){
00101     theDeviator[i] = theT2Vector[i] - theVolume;
00102     theDeviator[i+3] = theT2Vector[i+3];
00103     if (isEngrgStrain==1) {
00104       theDeviator[i+3] /= 2.;
00105       theT2Vector[i+3] /= 2.;
00106     }
00107   }
00108 }
00109 
00110 void
00111 T2Vector::setData(const Vector & deviat, double volume)
00112 {
00113   theVolume = volume;
00114   
00115   if (deviat.Size() != 6) {
00116     opserr << "FATAL:T2Vector::T2Vector(Vector &, double): vector size not equal 6" << endln;
00117     exit(-1);
00118   }
00119 
00120   //make sure the deviator has truely volume=0 
00121   double devolum = (deviat[0]+deviat[1]+deviat[2])/3.;
00122 
00123   for(int i=0; i<3; i++){
00124     theDeviator[i] = deviat[i] - devolum;
00125     theDeviator[i+3] = deviat[i+3];
00126     theT2Vector[i] = theDeviator[i] + theVolume;
00127     theT2Vector[i+3] = theDeviator[i+3]; 
00128   }
00129 }
00130 
00131 const Vector & 
00132 T2Vector::t2Vector(int isEngrgStrain) const
00133 {
00134   if (isEngrgStrain==0) return theT2Vector;
00135 
00136   engrgStrain = theT2Vector;
00137   for(int i=0; i<3; i++){
00138     engrgStrain[i+3] *= 2.;
00139   }
00140   return engrgStrain;
00141 }
00142 
00143 
00144 const Vector & T2Vector::deviator(int isEngrgStrain) const
00145 {
00146   if (isEngrgStrain==0) return theDeviator;
00147 
00148   engrgStrain = theDeviator;
00149   for(int i=0; i<3; i++){
00150     engrgStrain[i+3] *= 2.;
00151   }
00152   return engrgStrain;
00153 }
00154 
00155 
00156 double 
00157 T2Vector::t2VectorLength() const
00158 {
00159   return sqrt(theT2Vector && theT2Vector);
00160 }
00161 
00162 
00163 double 
00164 T2Vector::deviatorLength() const
00165 {
00166   return sqrt(theDeviator && theDeviator);
00167 }
00168 
00169 
00170 double 
00171 T2Vector::octahedralShear(int isEngrgStain) const
00172 {
00173   if (isEngrgStain) 
00174     return 2.* sqrt(1. / 3.) * deviatorLength();
00175   else
00176     return sqrt(1. / 3.) * deviatorLength();
00177 }
00178 
00179 
00180 double 
00181 T2Vector::deviatorRatio(double residualPress) const
00182 {
00183   if ((fabs(theVolume)+fabs(residualPress)) <= LOW_LIMIT) {
00184         opserr << "FATAL:T2Vector::deviatorRatio(): volume <=" << LOW_LIMIT << endln;
00185         exit(-1);
00186   }
00187   return sqrt(3./2.* (theDeviator && theDeviator)) / (fabs(theVolume)+fabs(residualPress));
00188 }
00189 
00190 
00191 const Vector &
00192 T2Vector::unitT2Vector() const
00193 {
00194   engrgStrain = theT2Vector;    
00195   double length = this->t2VectorLength();
00196   if (length <= LOW_LIMIT) {
00197     opserr << "WARNING:T2Vector::unitT2Vector(): vector length <=" << LOW_LIMIT << endln;
00198     engrgStrain /= LOW_LIMIT;
00199   } else
00200     engrgStrain /= length;
00201 
00202   return engrgStrain;
00203 }
00204 
00205 
00206 const Vector &
00207 T2Vector::unitDeviator() const
00208 {
00209 
00210   engrgStrain = theDeviator;;   
00211   double length = this->deviatorLength();
00212   if (length <= LOW_LIMIT) {
00213     opserr << "WARNING:T2Vector::unitT2Vector(): vector length <=" << LOW_LIMIT << endln;
00214     engrgStrain /= LOW_LIMIT;
00215   } else
00216     engrgStrain /= length;
00217 
00218   return engrgStrain;
00219 }
00220 
00221 
00222 double 
00223 T2Vector::angleBetweenT2Vector(const T2Vector & a) const
00224 {
00225   if (t2VectorLength() <= LOW_LIMIT || a.t2VectorLength() <= LOW_LIMIT) {
00226     opserr << "FATAL:T2Vector::angleBetweenT2Vector(T2Vector &): vector length <=" << LOW_LIMIT << endln;
00227     exit(-1);
00228   }
00229 
00230   double angle = (theT2Vector && a.theT2Vector) / (t2VectorLength() * a.t2VectorLength());
00231   if(angle > 1.) angle = 1.;
00232   if(angle < -1.) angle = -1.;
00233 
00234   return acos(angle);
00235 }
00236 
00237 
00238 double 
00239 T2Vector::angleBetweenDeviator(const T2Vector & a) const
00240 {
00241   if (deviatorLength() <= LOW_LIMIT || a.deviatorLength() <= LOW_LIMIT) {
00242     opserr << "FATAL:T2Vector::angleBetweenDeviator(T2Vector &): vector length <=" << LOW_LIMIT << endln;
00243     exit(-1);
00244   }
00245 
00246   double angle = (theDeviator && a.theDeviator) / (deviatorLength() * a.deviatorLength());
00247   if(angle > 1.) angle = 1.;
00248   if(angle < -1.) angle = -1.;
00249 
00250   return acos(angle);
00251 }
00252 
00253 
00254 int 
00255 T2Vector::operator == (const T2Vector & a) const
00256 {
00257   for(int i=0; i<6; i++)
00258     if(theT2Vector[i] != a.theT2Vector[i]) return 0;
00259 
00260   return 1;
00261 }
00262 
00263 int 
00264 T2Vector::isZero(void) const
00265 {
00266   for(int i=0; i<6; i++)
00267     if(theT2Vector[i] != 0.0) return 0;
00268 
00269   return 1;
00270 }
00271 
00272 
00273 /*********************
00274 ostream & operator<< (ostream & os, const T2Vector & a)
00275 {
00276   os.precision(16);
00277   os.setf(ios::showpoint);
00278 
00279   os << "theT2Vector = " << a.t2Vector() << endln;
00280   os << "theDeviator = " << a.deviator() << endln;
00281   os << "theVolume = " << a.volume() << endln;
00282 
00283   return os;
00284 }
00285 
00286 
00287 istream & operator>> (istream & is, T2Vector & a)
00288 {
00289   Vector temp;
00290 
00291   is >> temp;
00292   a = T2Vector(temp);
00293 
00294   return is;
00295 }
00296 */
00297 
00298 
00299 
00300 
00301 
00302 
00303 
00304 

Generated on Mon Oct 23 15:05:16 2006 for OpenSees by doxygen 1.5.0