CircPatch.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.2 $
00022 // $Date: 2003/02/14 23:01:36 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/material/section/repres/patch/CircPatch.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: CircPatch.C
00027 // Written by Remo M. de Souza
00028 // December 1998
00029 
00030 #include <math.h>
00031 #include <Matrix.h>
00032 #include <Patch.h>
00033 #include <CircPatch.h>
00034 #include <QuadCell.h>
00035 
00036 
00037 CircPatch::CircPatch(): matID(0), nDivCirc(1), nDivRad(1), centerPosit(2),
00038                         intRad(0.0), extRad(0.0), initAng(0.0), finalAng(0.0)
00039 {
00040 
00041 }
00042 
00043 
00044 CircPatch::CircPatch(int materialID, int numSubdivCircunf, int numSubdivRadial,
00045                      const Vector &centerPosition, double internRadius, 
00046                      double externRadius, double initialAngle, double finalAngle):
00047                      matID(materialID), 
00048                      nDivCirc(numSubdivCircunf), nDivRad(numSubdivRadial),
00049                      centerPosit(centerPosition),
00050                      intRad(internRadius), extRad(externRadius), 
00051                      initAng(initialAngle), finalAng(finalAngle)
00052 {
00053 
00054 }
00055 
00056 
00057 CircPatch::~CircPatch()
00058 {
00059 
00060 }
00061 
00062 void CircPatch::setMaterialID(int materialID)
00063 {
00064    matID = materialID;
00065 }
00066 
00067 
00068 void CircPatch::setDiscretization(int numSubdivCircunf, int numSubdivRadial)
00069 {
00070    nDivRad  = numSubdivRadial;
00071    nDivCirc = numSubdivCircunf;
00072 }
00073 
00074 void CircPatch::setCenterPosition(const Vector &centerPosition)
00075 {
00076    centerPosit = centerPosition;
00077 }
00078 
00079 void CircPatch::setRadii(double internRadius, double externRadius)
00080 {
00081    intRad = internRadius;
00082    extRad = externRadius;
00083 }
00084 
00085 void CircPatch::setAngles(double initialAngle, double finalAngle)
00086 {
00087    initAng  = initialAngle;
00088    finalAng = finalAngle;
00089 }
00090 
00091 
00092 int CircPatch::getMaterialID(void) const
00093 {
00094    return matID;
00095 }
00096  
00097 void CircPatch::getDiscretization(int &numSubdivCircunf, int &numSubdivRadial) const
00098 {
00099    numSubdivCircunf = nDivCirc;
00100    numSubdivRadial  = nDivRad;
00101 }
00102 
00103 void CircPatch::getRadii(double &internRadius, double &externRadius) const
00104 {
00105    internRadius = intRad;
00106    externRadius = extRad;
00107 }
00108 
00109 void CircPatch::getAngles(double &initialAngle, double &finalAngle) const
00110 {
00111    initialAngle = initAng;
00112    finalAngle   = finalAng;
00113 }
00114 
00115 const Vector & CircPatch::getCenterPosition (void) const
00116 {
00117    return centerPosit;
00118 }
00119 
00120 int CircPatch::getNumCells (void) const
00121 {
00122    return nDivCirc * nDivRad;
00123 }
00124 
00125 Cell **
00126 CircPatch::getCells (void) const
00127 {
00128    double pi = acos(-1.0);
00129    double deltaRad, deltaTheta; 
00130    double initAngRadians, finalAngRadians;
00131    double rad_j, rad_j1, theta_i, theta_i1;
00132    Matrix cellVertCoord(4,2);
00133 
00134    int    i, j, k;
00135    int    numCells;
00136    Cell   **cells;
00137 
00138    if (nDivRad > 0  && nDivCirc > 0)
00139    {
00140       numCells  = this->getNumCells();
00141 
00142       //opserr << "\nnumCells: " << numCells;
00143 
00144       cells = new Cell* [numCells];
00145       
00146       if (!cells)
00147          return 0;
00148 
00149       initAngRadians  = pi * initAng  / 180.0;
00150       finalAngRadians = pi * finalAng / 180.0;
00151 
00152       deltaRad   = (extRad - intRad) / nDivRad;
00153       deltaTheta = (finalAngRadians - initAngRadians) / nDivCirc;
00154 
00155       //opserr << "\ndeltaRad: " << deltaRad;
00156 
00157       k = 0;
00158       for (j = 0; j < nDivRad; j++)
00159       {
00160          rad_j  = intRad + deltaRad*j;
00161          rad_j1 = rad_j + deltaRad;
00162 
00163          for (i = 0; i < nDivCirc; i++)
00164          {
00165             // compute coordinates
00166                        
00167             theta_i  = initAngRadians + deltaTheta*i;
00168             theta_i1 = theta_i + deltaTheta;
00169 
00170             //opserr << "\n theta_i: "<< theta_i;
00171 
00172             cellVertCoord(0,0) = centerPosit(0) + rad_j  * cos(theta_i1);
00173             cellVertCoord(0,1) = centerPosit(1) + rad_j  * sin(theta_i1);
00174             cellVertCoord(1,0) = centerPosit(0) + rad_j  * cos(theta_i);
00175             cellVertCoord(1,1) = centerPosit(1) + rad_j  * sin(theta_i);
00176             cellVertCoord(2,0) = centerPosit(0) + rad_j1 * cos(theta_i);
00177             cellVertCoord(2,1) = centerPosit(1) + rad_j1 * sin(theta_i);
00178             cellVertCoord(3,0) = centerPosit(0) + rad_j1 * cos(theta_i1);
00179             cellVertCoord(3,1) = centerPosit(1) + rad_j1 * sin(theta_i1);
00180 
00181             cells[k] = new QuadCell(cellVertCoord); 
00182             //opserr << "\ncreating cells Cell " << k << " :" << cells[k];
00183             k++; 
00184          }
00185       }
00186    }
00187    else
00188       return 0;
00189 
00190    return cells;
00191 }
00192 
00193 
00194 Patch * 
00195 CircPatch::getCopy (void) const
00196 {
00197    CircPatch *theCopy = new CircPatch (matID, nDivCirc, nDivRad,
00198                                        centerPosit,  intRad, extRad,
00199                                        initAng, finalAng);
00200    return theCopy;
00201 }
00202  
00203 void CircPatch::Print(OPS_Stream &s, int flag) const
00204 {
00205    s << "\nPatch Type: CircPatch";
00206    s << "\nMaterial Id: " << matID;
00207    s << "\nNumber of subdivisions in the radial direction: " << nDivRad;
00208    s << "\nNumber of subdivisions in the circunferential direction: " << nDivCirc;
00209    s << "\nCenter Position: " << centerPosit;
00210    s << "\nInternal Radius: " << intRad << "\tExternal Radius: " << extRad;
00211    s << "\nInitial Angle: " << initAng << "\tFinal Angle: " << finalAng;
00212 }
00213 
00214 
00215 OPS_Stream &operator<<(OPS_Stream &s, CircPatch &CircPatch)
00216 {
00217    CircPatch.Print(s);
00218    return s;
00219 }

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