SectionForceDeformation.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.12 $
00022 // $Date: 2006/09/05 21:39:33 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/material/section/SectionForceDeformation.cpp,v $
00024                                                                         
00025                                                                         
00026 // Written: MHS 
00027 // Created: Feb 2000
00028 // Revision: A
00029 //
00030 // Description: This file contains the class implementation for SectionForceDeformation.
00031 //
00032 // What: "@(#) SectionForceDeformation.C, revA"
00033 
00034 #include <SectionForceDeformation.h>
00035 #include <Information.h>
00036 #include <Matrix.h>
00037 #include <Vector.h>
00038 #include <MaterialResponse.h>
00039 
00040 #include <string.h>
00041 
00042 double invert2by2Matrix(const Matrix &a, Matrix &b);
00043 double invert3by3Matrix(const Matrix &a, Matrix &b);
00044 void invertMatrix(int n, const Matrix &a, Matrix &b);
00045 
00046 SectionForceDeformation::SectionForceDeformation(int tag, int classTag)
00047   :Material(tag,classTag), fDefault(0), sDefault(0)
00048 {
00049 
00050 }
00051 
00052 SectionForceDeformation::~SectionForceDeformation()
00053 {
00054   if (fDefault != 0)
00055     delete fDefault;
00056   if (sDefault != 0)
00057     delete sDefault;
00058 }
00059 
00060 const Matrix&
00061 SectionForceDeformation::getSectionFlexibility ()
00062 {
00063   int order = this->getOrder();
00064   
00065   if (fDefault == 0) {          
00066     fDefault = new Matrix(order,order);
00067     if (fDefault == 0) {
00068       opserr << "SectionForceDeformation::getSectionFlexibility -- failed to allocate flexibility matrix\n";
00069       exit(-1);
00070     }
00071   }
00072 
00073   const Matrix &k = this->getSectionTangent();
00074   
00075   switch(order) {
00076   case 1:
00077     if (k(0,0) != 0.0)
00078       (*fDefault)(0,0) = 1.0/k(0,0);
00079     break;
00080   case 2:
00081     invert2by2Matrix(k,*fDefault);
00082     break;
00083   case 3:
00084     invert3by3Matrix(k,*fDefault);
00085     break;
00086   default:
00087     invertMatrix(order,k,*fDefault);
00088     break;
00089   }
00090 
00091   return *fDefault;
00092 }
00093 
00094 const Matrix&
00095 SectionForceDeformation::getInitialFlexibility ()
00096 {
00097   int order = this->getOrder();
00098   
00099   if (fDefault == 0) {          
00100     fDefault = new Matrix(order,order);
00101     if (fDefault == 0) {
00102       opserr << "SectionForceDeformation::getInitialFlexibility -- failed to allocate flexibility matrix\n";
00103       exit(-1);
00104     }
00105   }
00106   
00107   const Matrix &k = this->getInitialTangent();
00108   
00109   switch(order) {
00110   case 1:
00111     if (k(0,0) != 0.0)
00112       (*fDefault)(0,0) = 1.0/k(0,0);
00113     break;
00114   case 2:
00115     invert2by2Matrix(k,*fDefault);
00116     break;
00117   case 3:
00118     invert3by3Matrix(k,*fDefault);
00119     break;
00120   default:
00121     invertMatrix(order,k,*fDefault);
00122     break;
00123   }
00124   
00125   return *fDefault;
00126 }
00127 
00128 double 
00129 SectionForceDeformation::getRho(void) 
00130 {
00131   return 0.0 ;
00132 }
00133 
00134 Response*
00135 SectionForceDeformation::setResponse(const char **argv, int argc,
00136                                      Information &sectInfo, OPS_Stream &output)
00137 {
00138   const ID &type = this->getType();
00139   int typeSize = this->getOrder();
00140   
00141   Response *theResponse =0;
00142 
00143   output.tag("SectionOutput");
00144   output.attr("secType", this->getClassType());
00145   output.attr("secTag", this->getTag());
00146 
00147   // deformations
00148   if (strcmp(argv[0],"deformations") == 0 || strcmp(argv[0],"deformation") == 0) {
00149     for (int i=0; i<typeSize; i++) {
00150       int code = type(i);
00151       switch (code){
00152       case SECTION_RESPONSE_MZ:
00153         output.tag("ResponseType","kappaZ");
00154         break;
00155       case SECTION_RESPONSE_P:
00156         output.tag("ResponseType","eps");
00157         break;
00158       case SECTION_RESPONSE_VY:
00159         output.tag("ResponseType","gammaY");
00160         break;
00161       case SECTION_RESPONSE_MY:
00162         output.tag("ResponseType","kappaY");
00163         break;
00164       case SECTION_RESPONSE_VZ:
00165         output.tag("ResponseType","gammaZ");
00166         break;
00167       case SECTION_RESPONSE_T:
00168         output.tag("ResponseType","theta");
00169         break;
00170       default:
00171         output.tag("ResponseType","Unknown");
00172       }
00173     }
00174     theResponse =  new MaterialResponse(this, 1, this->getSectionDeformation());
00175   
00176   // forces
00177   } else if (strcmp(argv[0],"forces") == 0 || strcmp(argv[0],"force") == 0) {
00178     for (int i=0; i<typeSize; i++) {
00179       int code = type(i);
00180       switch (code){
00181       case SECTION_RESPONSE_MZ:
00182         output.tag("ResponseType","Mz");
00183         break;
00184       case SECTION_RESPONSE_P:
00185         output.tag("ResponseType","P");
00186         break;
00187       case SECTION_RESPONSE_VY:
00188         output.tag("ResponseType","Vy");
00189         break;
00190       case SECTION_RESPONSE_MY:
00191         output.tag("ResponseType","My");
00192         break;
00193       case SECTION_RESPONSE_VZ:
00194         output.tag("ResponseType","Vz");
00195         break;
00196       case SECTION_RESPONSE_T:
00197         output.tag("ResponseType","T");
00198         break;
00199       default:
00200         output.tag("ResponseType","Unknown");
00201       }
00202     }
00203     theResponse =  new MaterialResponse(this, 2, this->getStressResultant());
00204   
00205   // force and deformation
00206   } else if (strcmp(argv[0],"forceAndDeformation") == 0) { 
00207     for (int i=0; i<typeSize; i++) {
00208       int code = type(i);
00209       switch (code){
00210       case SECTION_RESPONSE_MZ:
00211         output.tag("ResponseType","kappaZ");
00212         break;
00213       case SECTION_RESPONSE_P:
00214         output.tag("ResponseType","eps");
00215         break;
00216       case SECTION_RESPONSE_VY:
00217         output.tag("ResponseType","gammaY");
00218         break;
00219       case SECTION_RESPONSE_MY:
00220         output.tag("ResponseType","kappaY");
00221         break;
00222       case SECTION_RESPONSE_VZ:
00223         output.tag("ResponseType","gammaZ");
00224         break;
00225       case SECTION_RESPONSE_T:
00226         output.tag("ResponseType","theta");
00227         break;
00228       default:
00229         output.tag("ResponseType","Unknown");
00230       }
00231     }
00232     for (int j=0; j<typeSize; j++) {
00233       int code = type(j);
00234       switch (code){
00235       case SECTION_RESPONSE_MZ:
00236         output.tag("ResponseType","Mz");
00237         break;
00238       case SECTION_RESPONSE_P:
00239         output.tag("ResponseType","P");
00240         break;
00241       case SECTION_RESPONSE_VY:
00242         output.tag("ResponseType","Vy");
00243         break;
00244       case SECTION_RESPONSE_MY:
00245         output.tag("ResponseType","My");
00246         break;
00247       case SECTION_RESPONSE_VZ:
00248         output.tag("ResponseType","Vz");
00249         break;
00250       case SECTION_RESPONSE_T:
00251         output.tag("ResponseType","T");
00252         break;
00253       default:
00254         output.tag("ResponseType","Unknown");
00255       }
00256     }
00257 
00258     theResponse =  new MaterialResponse(this, 4, Vector(2*this->getOrder()));
00259   
00260   }  
00261 
00262   output.endTag(); // SectionOutput
00263   return theResponse;
00264 }
00265 
00266 int 
00267 SectionForceDeformation::getResponse(int responseID, Information &secInfo)
00268 {
00269   switch (responseID) {
00270   case 1:
00271     return secInfo.setVector(this->getSectionDeformation());
00272     
00273   case 2:
00274     return secInfo.setVector(this->getStressResultant());
00275     
00276   case 4: {
00277     Vector &theVec = *(secInfo.theVector);
00278     const Vector &e = this->getSectionDeformation();
00279     const Vector &s = this->getStressResultant();
00280     int order = this->getOrder();
00281     for (int i = 0; i < order; i++) {
00282       theVec(i) = e(i);
00283       theVec(i+order) = s(i);
00284     }
00285     
00286     return secInfo.setVector(theVec);
00287   }
00288   default:
00289     return -1;
00290   }
00291 }
00292 
00293 int 
00294 SectionForceDeformation::getResponseSensitivity(int responseID, int gradNumber,
00295                                                 Information &secInfo)
00296 {
00297   Vector &theVec = *(secInfo.theVector);
00298 
00299   switch (responseID) {
00300   case 1:
00301     theVec = this->getSectionDeformationSensitivity(gradNumber);
00302     return secInfo.setVector(theVec);
00303     
00304   case 2: {
00305     const Matrix &ks = this->getSectionTangent();
00306     const Vector &dedh = this->getSectionDeformationSensitivity(gradNumber);
00307     const Vector &dsdh = this->getStressResultantSensitivity(gradNumber, true);
00308     theVec.addMatrixVector(0.0, ks, dedh, 1.0);
00309     theVec.addVector(1.0, dsdh, 1.0);
00310     return secInfo.setVector(theVec);
00311   }
00312 
00313   default:
00314     return -1;
00315   }
00316 }
00317 
00318 // AddingSensitivity:BEGIN ////////////////////////////////////////
00319 const Vector &
00320 SectionForceDeformation::getStressResultantSensitivity(int gradNumber, bool conditional)
00321 {
00322   if (sDefault == 0)
00323     sDefault = new Vector (this->getOrder());
00324   return *sDefault;
00325 }
00326 
00327 const Vector &
00328 SectionForceDeformation::getSectionDeformationSensitivity(int gradNumber)
00329 {
00330   if (sDefault == 0)
00331     sDefault = new Vector (this->getOrder());
00332   return *sDefault;
00333 }
00334 
00335 const Matrix &
00336 SectionForceDeformation::getSectionTangentSensitivity(int gradNumber)
00337 {
00338   int order = this->getOrder();
00339   
00340   if (fDefault == 0) {          
00341     fDefault = new Matrix(order,order);
00342     if (fDefault == 0) {
00343       opserr << "SectionForceDeformation::getSectionTangentSensitivity -- failed to allocate matrix\n";
00344       exit(-1);
00345     }
00346   }
00347 
00348   fDefault->Zero();
00349 
00350   return *fDefault;
00351 }
00352 
00353 const Matrix &
00354 SectionForceDeformation::getInitialTangentSensitivity(int gradNumber)
00355 {
00356   int order = this->getOrder();
00357   
00358   if (fDefault == 0) {          
00359     fDefault = new Matrix(order,order);
00360     if (fDefault == 0) {
00361       opserr << "SectionForceDeformation::getInitialTangentSensitivity -- failed to allocate matrix\n";
00362       exit(-1);
00363     }
00364   }
00365 
00366   fDefault->Zero();
00367 
00368   return *fDefault;
00369 }
00370 
00371 const Matrix&
00372 SectionForceDeformation::getSectionFlexibilitySensitivity(int gradNumber)
00373 {
00374   int order = this->getOrder();
00375   
00376   if (fDefault == 0) {          
00377     fDefault = new Matrix(order,order);
00378     if (fDefault == 0) {
00379       opserr << "SectionForceDeformation::getSectionFlexibilitySensitivity -- failed to allocate matrix\n";
00380       exit(-1);
00381     }
00382   }
00383 
00384   const Matrix &dksdh = this->getSectionTangentSensitivity(gradNumber);
00385   
00386   const Matrix &fs = this->getSectionFlexibility();
00387 
00388   *fDefault = (fs * dksdh * fs) * -1;
00389 
00390   return *fDefault;
00391 }
00392 
00393 const Matrix&
00394 SectionForceDeformation::getInitialFlexibilitySensitivity(int gradNumber)
00395 {
00396   int order = this->getOrder();
00397   
00398   if (fDefault == 0) {          
00399     fDefault = new Matrix(order,order);
00400     if (fDefault == 0) {
00401       opserr << "SectionForceDeformation::getInitialFlexibilitySensitivity -- failed to allocate matrix\n";
00402       exit(-1);
00403     }
00404   }
00405   
00406   const Matrix &dksdh = this->getInitialTangentSensitivity(gradNumber);
00407   
00408   const Matrix &fs = this->getInitialFlexibility();
00409 
00410   *fDefault = (fs * dksdh * fs) * -1;
00411   
00412   return *fDefault;
00413 }
00414 
00415 double
00416 SectionForceDeformation::getRhoSensitivity(int gradNumber)
00417 {
00418   return 0.0;
00419 }
00420 
00421 int
00422 SectionForceDeformation::commitSensitivity(const Vector& defSens,
00423                                            int gradNumber, int numGrads)
00424 {
00425   return -1;
00426 }
00427 // AddingSensitivity:END ///////////////////////////////////////////

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