QuadPatch.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/QuadPatch.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: QuadPatch.C
00027 // Written by Remo M. de Souza
00028 // December 1998
00029 
00030 #include <Matrix.h>
00031 #include <Patch.h>
00032 #include <QuadPatch.h>
00033 #include <QuadCell.h>
00034 
00035 
00036 QuadPatch::QuadPatch():
00037                        matID(0), nDivIJ(1), nDivJK(1), vertCoord(4,2)
00038 {
00039 
00040 }
00041 
00042 
00043 QuadPatch::QuadPatch(int materialID, int numSubdivIJ, int numSubdivJK,
00044                      const Matrix &vertexCoords):
00045                        matID(materialID), 
00046                        nDivIJ(numSubdivIJ), nDivJK(numSubdivJK),
00047                        vertCoord(vertexCoords)
00048 
00049 {
00050 
00051 }  
00052 
00053 
00054 QuadPatch::~QuadPatch()
00055 {
00056 
00057 }
00058 
00059 void QuadPatch::setMaterialID(int materialID)
00060 {
00061    matID = materialID;
00062 }
00063 
00064 
00065 void QuadPatch::setDiscretization(int numSubdivIJ, int numSubdivJK)
00066 {
00067    nDivIJ = numSubdivIJ;
00068    nDivJK = numSubdivJK;
00069 }
00070 
00071 void QuadPatch::setVertCoords(const Matrix &vertexCoords)
00072 {
00073    vertCoord = vertexCoords;
00074 }
00075 
00076 int QuadPatch::getMaterialID(void) const
00077 {
00078    return matID;
00079 }
00080  
00081 void QuadPatch::getDiscretization(int &numSubdivIJ, int &numSubdivJK) const
00082 {
00083    numSubdivIJ = nDivIJ;
00084    numSubdivJK = nDivJK;
00085 }
00086 
00087 const Matrix & QuadPatch::getVertCoords (void) const
00088 {
00089    return vertCoord;
00090 }
00091 
00092 int QuadPatch::getNumCells (void) const
00093 {
00094    return nDivIJ * nDivJK;
00095 }
00096 
00097 Cell **
00098 QuadPatch::getCells (void) const
00099 {
00100    double deltaXi;
00101    double deltaEta; 
00102    Matrix cellVertCoord(4,2);
00103    Vector N(4);
00104    double xi, eta;
00105    int i, j, k, r, s;
00106    int numCells;
00107    Cell **cells;
00108    int error = 0;
00109   
00110    if (nDivIJ > 0  && nDivJK > 0)
00111    {
00112       numCells  = this->getNumCells();
00113 
00114       cells = new Cell*  [numCells];
00115       
00116       if (!cells)
00117          return 0;
00118 
00119       deltaXi  = 2.0 / nDivIJ;
00120       deltaEta = 2.0 / nDivJK;
00121 
00122       k = 0;
00123       for (j = 0; j < nDivJK; j++)
00124          for (i = 0; i < nDivIJ; i++)
00125          {
00126             // compute natural coordinates
00127 
00128             cellVertCoord(0,0) = -1.0 + deltaXi  * i;
00129             cellVertCoord(0,1) = -1.0 + deltaEta * j;
00130             cellVertCoord(1,0) = -1.0 + deltaXi  * (i+1);
00131             cellVertCoord(1,1) = cellVertCoord(0,1);
00132             cellVertCoord(2,0) = cellVertCoord(1,0);
00133             cellVertCoord(2,1) = -1.0 + deltaEta * (j+1);
00134             cellVertCoord(3,0) = cellVertCoord(0,0);
00135             cellVertCoord(3,1) = cellVertCoord(2,1);
00136 
00137             // map to cartesian coordinates using bilinear
00138             // shape functions
00139 
00140             for (r = 0; r < 4; r++)
00141             {
00142                xi  = cellVertCoord(r,0);
00143                eta = cellVertCoord(r,1);
00144  
00145                N(0) = (1.0 - xi)*(1.0 - eta)/4.0;
00146                N(1) = (1.0 + xi)*(1.0 - eta)/4.0;
00147                N(2) = (1.0 + xi)*(1.0 + eta)/4.0;
00148                N(3) = (1.0 - xi)*(1.0 + eta)/4.0;
00149 
00150                cellVertCoord(r,0) = 0.0;
00151                cellVertCoord(r,1) = 0.0;
00152 
00153                for (s = 0; s < 4; s++)
00154                {
00155                   cellVertCoord(r,0) += N(s) * vertCoord(s,0);
00156                   cellVertCoord(r,1) += N(s) * vertCoord(s,1);
00157                }
00158             }  
00159 
00160             cells[k] = new QuadCell(cellVertCoord); 
00161             //opserr << "\ncreating cells Cell " << k << " :" << cells[k];
00162             k++; 
00163          }
00164    }
00165    else
00166       return 0;
00167 
00168    return cells;
00169 }
00170 
00171 
00172 Patch * 
00173 QuadPatch::getCopy (void) const
00174 {
00175    QuadPatch *theCopy = new QuadPatch (matID, nDivIJ, nDivJK, vertCoord);
00176    return theCopy;
00177 }
00178  
00179 void QuadPatch::Print(OPS_Stream &s, int flag) const
00180 {
00181    s << "\nPatch Type: QuadPatch";
00182    s << "\nMaterial Id: " << matID;
00183    s << "\nNumber of subdivisions in the IJ direction: " << nDivIJ;
00184    s << "\nNumber of subdivisions in the JK direction: " << nDivJK;
00185    s << "\nVertex Coordinates: " << vertCoord;
00186 }
00187 
00188 
00189 OPS_Stream &operator<<(OPS_Stream &s, QuadPatch &quadPatch)
00190 {
00191    quadPatch.Print(s);
00192    return s;
00193 }

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