/Users/jack/Code/basso_dev/inc/StressState.h

Go to the documentation of this file.
00001 
00012 #ifndef _STRESS_STATE_BASSO_H_
00013 #define _STRESS_STATE_BASSO_H_
00014 
00015 // std includes
00016 
00017 // Basso includes
00018 #include "basso.h"
00019 
00020 namespace basso {
00021 
00022         
00024 void voigt2tensor( const nArray &vstress, nMatrix &tstress ) 
00025 {
00026         tstress(0,0)=vstress[0]; tstress(0,1)=vstress[5]; tstress(0,2)=vstress[4];
00027         tstress(1,0)=vstress[5]; tstress(1,1)=vstress[1]; tstress(1,2)=vstress[3];
00028         tstress(2,0)=vstress[4]; tstress(2,1)=vstress[3]; tstress(2,2)=vstress[2];
00029 }
00030 
00032 void tensor2voigt( const nMatrix &tstress, nArray &vstress ) 
00033 {
00034         vstress[0]=tstress(0,0);
00035         vstress[1]=tstress(1,1);
00036         vstress[2]=tstress(2,2);
00037         vstress[3]=tstress(1,2);
00038         vstress[4]=tstress(2,0);
00039         vstress[5]=tstress(0,1);
00040 }
00041 
00042 class VoigtStress
00043 {
00044 
00045 public:
00046         VoigtStress() : vs(6) { }
00047         
00048         Numeric &operator() ( int i ) { return vs[i]; }
00049         Numeric &operator() ( int i, int j ) 
00050         {
00051                 if ( i==j )
00052                         return vs[i];
00053                 else if ( ( i==1 && j==0 ) || ( i==0 && j==1 ) )
00054                         return vs[5];
00055                 else if ( ( i==2 && j==1 ) || ( i==1 && j==2 ) )
00056                         return vs[3];
00057                 else  // if ( ( i==2 && j==0 ) || ( i==0 && j==2 ) )
00058                         return vs[4];
00059         }
00060         
00061         void FillTensor( nMatrix &T ) const
00062         {
00063                 T(0,0)=vs[0]; T(0,1)=vs[5]; T(0,2)=vs[4]; 
00064                 T(1,0)=vs[5]; T(1,1)=vs[1]; T(1,2)=vs[3];
00065                 T(1,0)=vs[4]; T(2,1)=vs[3]; T(2,2)=vs[2];
00066         }
00067         
00068 private:
00069         nArray vs;
00070         
00071 };
00072 
00073 class VoigtStrain 
00074 {
00075 public:
00076         VoigtStrain() : vs(6) { }
00077         
00078         Numeric operator() ( int i ) { return vs[i]; }
00079         Numeric operator() ( int i, int j ) 
00080         {
00081                 if ( i==j )
00082                         return vs[i];
00083                 else if ( ( i==1 && j==0 ) || ( i==0 && j==1 ) )
00084                         return 0.5*vs[5];
00085                 else if ( ( i==2 && j==1 ) || ( i==1 && j==2 ) )
00086                         return 0.5*vs[3];
00087                 else  // if ( ( i==2 && j==0 ) || ( i==0 && j==2 ) )
00088                         return 0.5*vs[4];
00089         }
00090         
00091         void FillTensor( nMatrix &T ) const
00092         {
00093                 T(0,0)=vs[0]; T(0,1)=0.5*vs[5]; T(0,2)=0.5*vs[4]; 
00094                 T(1,0)=0.5*vs[5]; T(1,1)=vs[1]; T(1,2)=0.5*vs[3];
00095                 T(1,0)=vs[4]; T(2,1)=0.5*vs[3]; T(2,2)=0.5*vs[2];
00096         }
00097         
00098 private:
00099         nArray vs;
00100         
00101 };
00102 
00103 
00106 class StressState
00107 {
00108 public:
00109         StressState() { }
00110         
00111         virtual ~StressState() { }
00112         
00118         virtual void Convert( const nMatrix &C, nMatrix &Cmat ) const = 0;
00119         
00121         virtual int VoigtDimension() const = 0;
00122         
00124         virtual int Dimension() const = 0;
00125         
00126 };
00127 
00132 class PlaneStrainState : public StressState
00133 {
00134 
00135 public:
00136         PlaneStrainState(   ) : StressState() { }
00137         
00143         virtual void Convert( const nMatrix &C, nMatrix &Cmat ) const 
00144         {
00145 #ifdef ALLOW_DYNAMIC_RESIZE
00146                 if ( mat_nrows(Cmat)!=3 || mat_ncols(Cmat)!=3 )
00147                         resize(Cmat,3,3);
00148 #elif EXPLICIT_BOUNDS_CHECK
00149                 if (  ( mat_nrows(Cmat)!=3 || mat_ncols(Cmat)!=3 ) ||
00150                         ( mat_nrows(C)!=6 || mat_ncols(C)!=6 ) )
00151                         ErrorMessage("PlaneStrainState.Convert()","incorrct matrix size");
00152 #endif
00153                 Cmat(0,0)=C(0,0); Cmat(0,1)=C(0,1); Cmat(0,2)=C(0,5);
00154                 Cmat(1,0)=C(1,0); Cmat(1,1)=C(1,1); Cmat(1,2)=C(1,5);
00155                 Cmat(2,0)=C(5,0); Cmat(2,1)=C(5,1); Cmat(2,2)=C(5,5);           
00156         }
00157         
00159         virtual int VoigtDimension() const { return 3; }
00160         
00162         virtual int Dimension() const { return 2; }
00163          
00164 };
00165 
00170 class PlaneStressState : public StressState
00171 {
00172 
00173 public:
00174         PlaneStressState( ) : StressState() { }
00175         
00181         virtual void Convert( const nMatrix &C, nMatrix &Cmat ) const 
00182         {
00183 #ifdef ALLOW_DYNAMIC_RESIZE
00184                 if ( mat_nrows(Cmat)!=3 || mat_ncols(Cmat)!=3 )
00185                         resize(Cmat,3,3);
00186 #elif EXPLICIT_BOUNDS_CHECK
00187                 if (  ( mat_nrows(Cmat)!=3 || mat_ncols(Cmat)!=3 ) ||
00188                         ( mat_nrows(C)!=6 || mat_ncols(C)!=6 ) )
00189                         ErrorMessage("PlaneStressState.Convert()","incorrct matrix size");
00190 #endif
00191                 Numeric a=1.0/C(2,2);
00192                 Cmat(0,0)=C(0,0)-C(0,2)*C(2,0)*a; Cmat(0,1)=C(0,1)-C(0,2)*C(2,1)*a; Cmat(0,2)=C(0,5);
00193                 Cmat(1,0)=C(1,0)-C(1,2)*C(2,0)*a; Cmat(1,1)=C(1,1)-C(1,2)*C(2,1)*a; Cmat(1,2)=C(1,5);
00194                 Cmat(2,0)=C(5,0); Cmat(2,1)=C(5,1); Cmat(2,2)=C(5,5);           
00195         }
00196         
00198         virtual int VoigtDimension() const { return 3; }
00199         
00201         virtual int Dimension() const { return 2; }
00202         
00203 private:
00204          
00205 };
00206 
00210 class AxisymmetricState : public StressState
00211 {
00212 
00213 public:
00214         AxisymmetricState(   ) : StressState() {  }
00215         
00221         virtual void Convert( const nMatrix &C, nMatrix &Cmat ) const 
00222         {
00223 #ifdef ALLOW_DYNAMIC_RESIZE
00224                 if ( mat_nrows(Cmat)!=4 || mat_ncols(Cmat)!=4 )
00225                         resize(Cmat,4,4);
00226 #elif EXPLICIT_BOUNDS_CHECK
00227                 if (  ( mat_nrows(Cmat)!=4 || mat_ncols(Cmat)!=4 ) ||
00228                         ( mat_nrows(C)!=6 || mat_ncols(C)!=6 ) )
00229                         ErrorMessage("PlaneStrainState.Convert()","incorrct matrix size");
00230 #endif
00231                 Cmat(0,0)=C(0,0); Cmat(0,1)=C(0,1); Cmat(0,2)=0.0;    Cmat(0,3)=C(0,5);
00232                 Cmat(1,0)=C(1,0); Cmat(1,1)=C(1,1); Cmat(0,2)=0.0;    Cmat(0,3)=C(0,5);
00233                 Cmat(2,0)=0.0;    Cmat(2,1)=0.0;    Cmat(2,2)=C(5,5); Cmat(2,3)=0.0;
00234                 Cmat(3,0)=C(5,0); Cmat(3,1)=C(5,1); Cmat(3,2)=0.0;    Cmat(3,3)=1.0;    
00235         }
00236         
00238         virtual int VoigtDimension() const { return 4; }
00239         
00241         virtual int Dimension() const { return 2; }
00242         
00243 private:
00244 
00245          
00246 };
00247 
00249 class StressState3D : public StressState
00250 {
00251 
00252 public:
00253         StressState3D(   ) : StressState() { }
00254 
00260         virtual void Convert( const nMatrix &C, nMatrix &Cmat ) const 
00261         { 
00262 #ifdef ALLOW_DYNAMIC_RESIZE
00263                 if ( mat_nrows(Cmat)!=6 || mat_ncols(Cmat)!=6 )
00264                         resize(Cmat,6,6);
00265 #elif EXPLICIT_BOUNDS_CHECK
00266                 if (  ( mat_nrows(Cmat)!=6 || mat_ncols(Cmat)!=6 ) ||
00267                         ( mat_nrows(C)!=6 || mat_ncols(C)!=6 ) )
00268                         ErrorMessage("StressState3D.Convert()","incorrct matrix size");
00269 #endif
00270                 copy(C,Cmat);   
00271         }
00272         
00274         virtual int VoigtDimension() const { return 6; }
00275         
00277         virtual int Dimension() const { return 3; }
00278         
00279 private:
00280          
00281 };
00282 
00287 class StressState1D : public StressState
00288 {
00289 
00290 public:
00291         StressState1D(   ) : StressState() { }
00292 
00298         virtual void Convert( const nMatrix &C, nMatrix &Cmat ) const 
00299         { 
00300 #ifdef ALLOW_DYNAMIC_RESIZE
00301                 if ( mat_nrows(Cmat)!=1 || mat_ncols(Cmat)!=1 )
00302                         resize(Cmat,1,1);
00303 #elif EXPLICIT_BOUNDS_CHECK
00304                 if (  ( mat_nrows(Cmat)!=1 || mat_ncols(Cmat)!=1 ) ||
00305                         ( mat_nrows(C)!=1 || mat_ncols(C)!=1 ) )
00306                         ErrorMessage("StressState1D.Convert()","incorrct matrix size");
00307 #endif
00308                 Cmat(0,0)=C(0,0)+2*C(0,1)*C(0,1)/(C(1,1)+C(1,2));       
00309         }
00310         
00312         virtual int VoigtDimension() const { return 1; }
00313         
00315         virtual int Dimension() const { return 1; }
00316         
00317 private:
00318          
00319 };
00320 
00321 } // end namespace
00322 
00323 #endif
00324 
00325 

Generated on Sat Jan 19 09:03:57 2008 for Basso by  doxygen 1.5.2