DP_YF.cpp

Go to the documentation of this file.
00001 
00002 //   COPYLEFT (C): Woody's viral GPL-like license (by BJ):
00003 //                 ``This    source  code is Copyrighted in
00004 //                 U.S.,  for  an  indefinite  period,  and anybody
00005 //                 caught  using it without our permission, will be
00006 //                 mighty good friends of ourn, cause we don't give
00007 //                 a  darn.  Hack it. Compile it. Debug it. Run it.
00008 //                 Yodel  it.  Enjoy it. We wrote it, that's all we
00009 //                 wanted to do.''
00010 //
00011 //
00012 // COPYRIGHT (C):     :-))
00013 // PROJECT:           Object Oriented Finite Element Program
00014 // FILE:              
00015 // CLASS:             
00016 // MEMBER FUNCTIONS:
00017 //
00018 // MEMBER VARIABLES
00019 //
00020 // PURPOSE:           
00021 //
00022 // RETURN:
00023 // VERSION:
00024 // LANGUAGE:          C++
00025 // TARGET OS:         
00026 // DESIGNER:          Zhao Cheng, Boris Jeremic
00027 // PROGRAMMER:        Zhao Cheng, 
00028 // DATE:              Fall 2005
00029 // UPDATE HISTORY:    
00030 //
00032 //
00033 
00034 #ifndef DP_YF_CPP
00035 #define DP_YF_CPP
00036 
00037 #include "DP_YF.h"
00038 
00039 stresstensor DP_YF::DPst;
00040 
00041 //================================================================================
00042 DP_YF::DP_YF(int a_which_in, int index_a_in, 
00043              int k_which_in, int index_k_in, 
00044              int alpha_which_in, int index_alpha_in)
00045 : a_which(a_which_in), index_a(index_a_in), 
00046   k_which(k_which_in), index_k(index_k_in),
00047   alpha_which(alpha_which_in), index_alpha(index_alpha_in)
00048 {
00049 
00050 }
00051 
00052 //================================================================================
00053 DP_YF::~DP_YF() 
00054 {
00055 
00056 }
00057 
00058 //================================================================================
00059 YieldFunction* DP_YF::newObj() 
00060 {
00061         YieldFunction  *new_YF = new DP_YF(a_which, index_a, 
00062                                            k_which, index_k, 
00063                                            alpha_which, index_alpha);
00064 
00065         return new_YF;
00066 }
00067 
00068 //================================================================================
00069 double DP_YF::YieldFunctionValue( const stresstensor& Stre, 
00070                                  const MaterialParameter &MaterialParameter_in ) const
00071 {
00072         // f = a*I1 + [0.5(sij-p*aij)(sij-p*aij)]^0.5 - k = 0
00073     if (a_which == -1) {
00074                 opserr << "DP_YF: Invalid Input Parameter. " << endln;
00075                 exit(1);
00076         }
00077         if (alpha_which == -1)
00078                 return Stre.Iinvariant1() * geta(MaterialParameter_in) 
00079                      + sqrt(Stre.Jinvariant2()) 
00080                      - getk(MaterialParameter_in);
00081         else {
00082                 double temp1 = Stre.Iinvariant1() * geta(MaterialParameter_in) - getk(MaterialParameter_in);
00083                 double p = Stre.p_hydrostatic();
00084                 stresstensor s_back = getalpha(MaterialParameter_in);
00085                 stresstensor sigma_b = Stre - (s_back * p);
00086                 stresstensor s_bar = sigma_b.deviator();
00087                 double temp2 = ( s_bar("ij") * s_bar("ij") ).trace();
00088                 return temp1 + sqrt(0.5*temp2);
00089         }
00090 }
00091 
00092 //================================================================================
00093 const stresstensor& DP_YF::StressDerivative(const stresstensor& Stre, 
00094                                             const MaterialParameter &MaterialParameter_in) const
00095 {
00096         double eps = pow( d_macheps(), 0.5 );
00097         BJtensor KroneckerI("I", 2, def_dim_2);
00098         if (alpha_which == -1) {
00099                 double temp0 = Stre.Jinvariant2();
00100         temp0 = sqrt(temp0);
00101                 if (fabs(temp0) < eps) {
00102                         DPst = KroneckerI *geta(MaterialParameter_in);
00103                         return DPst;
00104                 }
00105                 DPst = KroneckerI *geta(MaterialParameter_in) + ( Stre.deviator() *(0.5/temp0) );
00106                 return DPst;
00107         }
00108         else {
00109                 double p = Stre.p_hydrostatic();
00110                 stresstensor s_back = getalpha(MaterialParameter_in);
00111                 stresstensor sigma_b = Stre - (s_back * p);
00112                 stresstensor s_bar = sigma_b.deviator();
00113                 double temp1 = ( s_bar("ij") * s_bar("ij") ).trace();
00114         temp1 = sqrt(0.5*temp1);
00115                 if (fabs(temp1) < eps) {
00116                         DPst = KroneckerI *geta(MaterialParameter_in);
00117                         return DPst;
00118                 }
00119                 double temp2 = ( s_bar("ij") * s_back("ij") ).trace();
00120                 DPst = s_bar + ( KroneckerI * (temp2/3.0) );
00121                 DPst = DPst*(0.5/temp1);
00122         DPst += ( KroneckerI *(geta(MaterialParameter_in)/3.0) );
00123                 return DPst;
00124         }
00125 }
00126 
00127 //================================================================================
00128 double DP_YF::InScalarDerivative(const stresstensor& Stre, 
00129                                  const MaterialParameter &MaterialParameter_in, 
00130                                  int which) const
00131 {
00132         if (a_which == 1 && which == index_a)
00133                 return Stre.Iinvariant1();
00134         
00135         if (k_which == 1 && which == index_k)
00136                 return -1.0;
00137                 
00138         return 0.0;
00139 }
00140 
00141 //================================================================================
00142 const stresstensor& DP_YF::InTensorDerivative(const stresstensor& Stre, 
00143                                               const MaterialParameter &MaterialParameter_in, 
00144                                               int which) const
00145 {
00146         double eps = pow( d_macheps(), 0.5 );
00147         if (alpha_which != 2 || which != 1){
00148                 opserr << "DP_YF: Invalid Input Parameter. " << endln;
00149                 exit (1);
00150         }
00151         
00152         double p = Stre.p_hydrostatic();
00153         stresstensor s_back = getalpha(MaterialParameter_in);
00154         stresstensor sigma_b = Stre - (s_back * p);
00155         stresstensor s_bar = sigma_b.deviator();
00156         double temp1 = ( s_bar("ij") * s_bar("ij") ).trace();
00157         temp1 = sqrt(0.5*temp1);
00158         if (temp1 < eps) {
00159                 DPst = DPst*0.0;
00160                 return DPst;
00161         }
00162         DPst = s_bar *(-0.5*p/temp1);
00163         return DPst;
00164 }
00165 
00166 //================================================================================
00167 int DP_YF::getNumInternalScalar() const
00168 {
00169         int Numyf = 0;
00170         
00171         if ( a_which == 1)
00172                 Numyf++;
00173         
00174         if ( k_which == 1)
00175                 Numyf++;
00176         
00177         return Numyf;
00178 }
00179 
00180 //================================================================================
00181 int DP_YF::getNumInternalTensor() const
00182 {
00183         if (alpha_which == 2)
00184                 return 1;
00185         else
00186                 return 0;
00187 }
00188 
00189 //================================================================================   
00190 int DP_YF::getYieldFunctionRank() const
00191 {
00192         return 1;
00193 }
00194 
00195 //================================================================================   
00196 double DP_YF::geta(const MaterialParameter &MaterialParameter_in) const
00197 {
00198         // to get a
00199         if ( a_which == 0) {
00200                 if ( index_a <= MaterialParameter_in.getNum_Material_Parameter() && index_a > 0)
00201                         return MaterialParameter_in.getMaterial_Parameter(index_a-1); 
00202                 else {
00203                         opserr << "DP_YF: Invalid Input. " << endln;
00204                         exit (1);
00205                 }
00206         }
00207         else if ( a_which == 1) {
00208                 if ( index_a <= MaterialParameter_in.getNum_Internal_Scalar() && index_a > 0)
00209                         return MaterialParameter_in.getInternal_Scalar(index_a-1); 
00210                 else {
00211                         opserr << "DP_YF: Invalid Input. " << endln;
00212                         exit (1);
00213                 }
00214     }
00215         else {
00216                 opserr << "DP_YF: Invalid Input. " << endln;
00217                 exit(1);
00218         }
00219 }
00220 
00221 //================================================================================   
00222 double DP_YF::getk(const MaterialParameter &MaterialParameter_in) const
00223 {
00224         // to get k
00225         if ( k_which == 0) {
00226                 if ( index_k <= MaterialParameter_in.getNum_Material_Parameter() && index_k > 0)
00227                         return MaterialParameter_in.getMaterial_Parameter(index_k-1); 
00228                 else {
00229                         opserr << "DP_YF: Invalid Input. " << endln;
00230                         exit (1);
00231                 }
00232         }
00233         else if ( k_which == 1) {
00234                 if ( index_k <= MaterialParameter_in.getNum_Internal_Scalar() && index_k > 0)
00235                         return MaterialParameter_in.getInternal_Scalar(index_k-1); 
00236                 else {
00237                         opserr << "DP_YF: Invalid Input. " << endln;
00238                         exit (1);
00239                 }
00240     }
00241         else {
00242                 opserr << "DP_YF: Invalid Input. " << endln;
00243                 exit(1);
00244         }
00245 }
00246 
00247 //================================================================================ 
00248 const stresstensor& DP_YF::getalpha(const MaterialParameter &MaterialParameter_in) const
00249 {
00250         //to get alpha
00251         if ( alpha_which == 2 && index_alpha <= MaterialParameter_in.getNum_Internal_Tensor() && index_alpha > 0) {
00252                 DPst = MaterialParameter_in.getInternal_Tensor(index_alpha-1);
00253                 return DPst;
00254         }
00255         else {
00256                 opserr << "DP_YF: Invalid Input. " << endln;
00257                 exit (1);
00258         }
00259 }
00260 
00261 
00262 #endif
00263 

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