00001
00012 #ifndef _STRUCTURAL_FORUMULATION_BASSO_H_
00013 #define _STRUCTURAL_FORUMULATION_BASSO_H_
00014
00015
00016 #include <list>
00017
00018
00019 #include "basso.h"
00020 #include "Formulation.h"
00021 #include "StressState.h"
00022
00023 namespace basso {
00024
00025 enum StressStateType { kSTRESS_1D, kPLANE_STRAIN, kPLANE_STRESS, kAXISYMMETRIC, kSTRESS_3D };
00026
00032 class StructuralFormulation : public Formulation {
00033
00034 public:
00035
00036
00037
00038
00040 StructuralFormulation( list< Element > &elem, const Array< Node > &nodes, StressStateType ss=kSTRESS_3D )
00041 : Formulation( elem, nodes )
00042 {
00043 switch (ss)
00044 {
00045 case kSTRESS_1D:
00046 fStressState = new StressState1D;
00047 break;
00048
00049 case kPLANE_STRAIN:
00050 fStressState = new PlaneStrainState;
00051 break;
00052
00053 case kPLANE_STRESS:
00054 fStressState = new PlaneStressState;
00055 break;
00056
00057 case kAXISYMMETRIC:
00058 fStressState = new AxisymmetricState;
00059 break;
00060
00061 default:
00062 fStressState = new StressState3D;
00063 break;
00064
00065 }
00066 this->mVdim = this->fStressState->VoigtDimension();
00067 resize( this->mCmat, this->mVdim, this->mVdim );
00068 }
00069
00070 virtual ~StructuralFormulation() { }
00071
00072
00073
00074
00075
00077 virtual int NumLocalDofs() const { return this->mSdim; }
00078
00084 virtual void NodalAvgStress( const nArray &d, Array< nArray > &stress, Array< nArray > &strain );
00085
00086 protected:
00087 virtual void SetCMatrix() = 0;
00088
00090 virtual void GetElementStiffnessMatrix( nMatrix &ke, list< Element >::const_iterator eItr );
00091
00099 virtual Numeric SetBMatrix( list< Element >::const_iterator eItr, const Point &pt )
00100 {
00101 Numeric jac = this->SetDNx( eItr, pt );
00102 form_bmatrix( this->mDNx, this->mBmat );
00103 return jac;
00104 }
00105
00106 protected:
00107
00108 virtual bool SetElementParameters( list<Element>::const_iterator eItr, int qorder=2 );
00109
00110 protected:
00111
00112 const Material *fMat;
00113 StressState *fStressState;
00114
00115 nMatrix mBmat, mCmat;
00116 int mVdim, mEdim;
00117
00118 };
00119
00120 void StructuralFormulation::NodalAvgStress(
00121 const nArray &d, Array< nArray > &stress, Array< nArray > &strain )
00122 {
00123 if ( fDofMap==0 )
00124 {
00125 WarningMessage("StructuralFormulation::NodalAvgStress","DofMap not set");
00126 return;
00127 }
00128
00129 if ( stress.size()!=d.size() )
00130 resize( stress, d.size() );
00131 if ( strain.size()!=d.size() )
00132 resize( strain, d.size() );
00133
00134 iArray navg( d.size() ); clear( navg );
00135 nArray de, estrain(mVdim), estress(mVdim);
00136 Array<Point> pts;
00137 list< Element >::const_iterator eItr;
00138
00139 for ( eItr=this->fElement->begin(); eItr!=this->fElement->end(); ++eItr )
00140 {
00141
00142 if ( SetElementParameters( eItr ) ) {
00143 resize( de, mNne*NumLocalDofs() );
00144 eItr->ParentCoord( pts );
00145 }
00146
00147 fDofMap->Gather( eItr->Connectivity(), ActiveDofs(), d, de );
00148 for ( int n=0; n<this->mNne; ++n )
00149 {
00150 SetBMatrix( eItr, pts[n] );
00151 mult( mBmat, de, estrain );
00152 mult( mCmat, estrain, estress );
00153 int I=eItr->NodeId(n);
00154 if ( navg[ I ]==0 )
00155 {
00156 if ( stress[I].size()!=estress.size() )
00157 resize( stress[I], estress.size() );
00158 if ( strain[I].size()!=estrain.size() )
00159 resize( strain[I], estrain.size() );
00160 stress[I]=estress;
00161 strain[I]=estrain;
00162 }
00163 else
00164 {
00165 stress[I]=estress;
00166 strain[I]=estrain;
00167 }
00168 ++navg[I];
00169
00170 }
00171 }
00172
00173 for ( int I=0; I<d.size(); ++I )
00174 for ( int i=0; i<stress[I].size(); ++i )
00175 {
00176 stress[I][i] = stress[I][i]/navg[I];
00177 strain[I][i] = strain[I][i]/navg[I];
00178 }
00179
00180 }
00181
00182 bool StructuralFormulation::SetElementParameters( list<Element>::const_iterator eItr, int qorder )
00183 {
00184 if ( this->mLastElemType == eItr->Type() )
00185 return false;
00186 this->mNne = eItr->NumNodes();
00187 this->mEdim = eItr->Dimension();
00188 resize( this->mDNxi, this->mNne, this->mEdim );
00189 resize( this->mDNx, this->mNne, this->mSdim );
00190 resize( this->mNa, this->mNne );
00191 resize( this->mCoord, this->mNne, this->mSdim );
00192 resize( this->mBmat, this->mVdim, this->mSdim*this->mNne );
00193 eItr->Quadrature( qorder, this->mQuadrature );
00194 this->mLastElemType = eItr->Type();
00195 return true;
00196 }
00197
00198 void StructuralFormulation::GetElementStiffnessMatrix( nMatrix &ke, list<Element>::const_iterator eItr )
00199 {
00200 SetElementParameters( eItr, 2*(eItr->Order()-1) );
00201 int kdim = eItr->NumNodes()*NumLocalDofs();
00202 resize( ke, kdim, kdim );
00203 clear(ke);
00204 Numeric jac;
00205 QuadratureRule::const_iterator qItr;
00206 SetCMatrix();
00207 for ( qItr=QuadratureBegin(); qItr!=QuadratureEnd(); ++qItr )
00208 {
00209 jac = SetBMatrix( eItr, qItr->Pt() );
00210 femmult_add( transposed(this->mBmat), mCmat, this->mBmat, jac*qItr->Wt(), ke );
00211 }
00212
00213 }
00214
00215 }
00216
00217 #endif
00218
00219
00220