QuadCell.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.3 $
00022 // $Date: 2003/05/02 18:34:56 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/material/section/repres/cell/QuadCell.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: QuadCell.C
00027 // Written by Remo M. de Souza
00028 // December 1998
00029 
00030 #include <Matrix.h>
00031 #include <Vector.h>
00032 
00033 #include <QuadCell.h>
00034 
00035 
00036 QuadCell::QuadCell(void):
00037                    vertCoord(4,2), Centroid(2)                 
00038 {
00039 
00040 }
00041 
00042 
00043 QuadCell::QuadCell(const Matrix &vertexCoords): 
00044                    vertCoord(vertexCoords), Centroid(2)
00045 {
00046 
00047 }
00048 
00049 
00050 QuadCell::~QuadCell()
00051 {
00052 
00053 }
00054 
00055 const Matrix &
00056 QuadCell::getVertCoords (void) const
00057 {
00058    return vertCoord;
00059 }
00060 
00061 void QuadCell::setVertCoords (const Matrix &vertexCoords)
00062 {
00063    vertCoord = vertexCoords;
00064 }
00065 
00066 
00067 double QuadCell::getArea (void) const
00068 {
00069    double area;
00070    double x0, y0, x1, y1, x2, y2, x3, y3;
00071 
00072 //   opserr << "cell vertCoord: " << vertCoord;
00073  
00074    x0 = vertCoord(0,0);
00075    y0 = vertCoord(0,1);
00076    x1 = vertCoord(1,0);
00077    y1 = vertCoord(1,1);
00078    x2 = vertCoord(2,0);
00079    y2 = vertCoord(2,1);
00080    x3 = vertCoord(3,0);
00081    y3 = vertCoord(3,1);
00082 
00083    area = ((x2-x1)*(y0-y1) - (x0-x1)*(y2-y1) +
00084            (x0-x3)*(y2-y3) - (x2-x3)*(y0-y3)) / 2.0; 
00085 
00086 //   opserr << "area1=" << area;
00087 
00088    int i, i1;
00089    double yi, zi, yi1, zi1;
00090    area = 0;
00091 
00092    for (i = 0; i < 4; i++)
00093    {
00094       i1 = (i+1)%4;
00095       yi  = vertCoord(i,0);
00096       zi  = vertCoord(i,1);
00097       yi1 = vertCoord(i1,0);
00098       zi1 = vertCoord(i1,1);
00099 
00100       area += (zi1 - zi) * (yi1 + yi); 
00101    }
00102    area /= 2.0;
00103 
00104 //   opserr << "area2= " << area << endln;
00105 
00106    return area;
00107                 
00108 }
00109 
00110 
00111 const Vector & 
00112 QuadCell::getCentroidPosition(void)
00113 {
00114    int i, i1;
00115    double yi, zi, yi1, zi1, dyi, dzi;
00116    double area, integ;
00117    double CGy = 0.0, CGz = 0.0;
00118 
00119    area = this->getArea();
00120 
00121    for (i = 0; i < 4; i++)
00122    {
00123       i1 = (i+1)%4;
00124         
00125       yi  = vertCoord(i,0);
00126       zi  = vertCoord(i,1);
00127       yi1 = vertCoord(i1,0);
00128       zi1 = vertCoord(i1,1);
00129 
00130       dyi = yi1 - yi;
00131       dzi = zi1 - zi;
00132    
00133       integ = yi*zi + (yi*dzi + zi*dyi)/2.0 + dyi*dzi/3.0;
00134 
00135       CGy -= dyi * integ;
00136       CGz += dzi * integ;
00137    }
00138    
00139    CGy /= area;
00140    CGz /= area;
00141 
00142    Centroid(0) = CGy;
00143    Centroid(1) = CGz;
00144 
00145 //   opserr << "\narea : " << area << " centroid: " << Centroid;
00146  
00147    return Centroid;
00148 }
00149 
00150 
00151 
00152 void QuadCell::Print(OPS_Stream &s, int flag) const
00153 {
00154    s << "\nCell Type: QuadCell";
00155    s << "\nVertex Coordinates: " << vertCoord;
00156 }
00157 
00158 
00159 OPS_Stream &operator<<(OPS_Stream &s, const QuadCell &quadCell)
00160 {
00161    quadCell.Print(s);
00162    return s;
00163 }    
00164 

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