PulseSeries.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.1 $
00022 // $Date: 2005/12/15 00:35:47 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/domain/pattern/PulseSeries.cpp,v $
00024 
00025 // Written: Andreas Schellenberg (andreas.schellenberg@gmx.net)
00026 // Created: 02/04
00027 // Revision: A
00028 //
00029 // Purpose: This file contains the class implementation of PulseSeries.
00030 //
00031 // What: "@(#) PulseSeries.cpp, revA"
00032 
00033 
00034 #include <PulseSeries.h>
00035 #include <Vector.h>
00036 #include <Channel.h>
00037 #include <classTags.h>
00038 
00039 #include <math.h>
00040 
00041 
00042 PulseSeries::PulseSeries(double startTime, double finishTime,
00043     double T, double pulseWidth, double phi, double theFactor)
00044     : TimeSeries(TSERIES_TAG_PulseSeries),
00045     tStart(startTime),tFinish(finishTime),
00046     period(T),pWidth(pulseWidth),shift(phi),cFactor(theFactor)
00047 {
00048         if (period == 0.0)  {
00049                 opserr << "PulseSeries::PulseSeries -- input period is zero, setting period to 1\n";
00050                 period = 1;
00051         }
00052 }
00053 
00054 
00055 PulseSeries::PulseSeries()
00056     : TimeSeries(TSERIES_TAG_PulseSeries),
00057     tStart(0.0),tFinish(0.0),
00058     period(1.0),pWidth(0.5),shift(0.0),cFactor(1.0)
00059 {
00060         // does nothing
00061 }
00062 
00063 
00064 PulseSeries::~PulseSeries()
00065 {
00066         // does nothing
00067 }
00068 
00069 
00070 double PulseSeries::getFactor(double pseudoTime)
00071 {       
00072         if (tStart <= pseudoTime && pseudoTime <= tFinish)  {
00073                 double k = (pseudoTime+shift)/period - floor((pseudoTime+shift)/period);
00074                 if (k < pWidth)
00075                         return cFactor;
00076                 else if (k < 1.00)
00077                         return 0;
00078                 else
00079                         return 0;
00080         }
00081         else
00082                 return 0;
00083 }
00084 
00085 
00086 int PulseSeries::sendSelf(int commitTag, Channel &theChannel)
00087 {
00088         int dbTag = this->getDbTag();
00089         Vector data(6);
00090         data(0) = cFactor;
00091         data(1) = tStart;       
00092         data(2) = tFinish;
00093         data(3) = period;
00094         data(4) = pWidth;
00095         data(5) = shift;
00096         int result = theChannel.sendVector(dbTag,commitTag, data);
00097         if (result < 0)  {
00098                 opserr << "PulseSeries::sendSelf() - channel failed to send data\n";
00099                 return result;
00100         }
00101         return 0;
00102 }
00103 
00104 
00105 int PulseSeries::recvSelf(int commitTag, Channel &theChannel, 
00106                                                   FEM_ObjectBroker &theBroker)
00107 {
00108         int dbTag = this->getDbTag();
00109         Vector data(6);
00110         int result = theChannel.recvVector(dbTag,commitTag, data);
00111         if (result < 0)  {
00112                 opserr << "PulseSeries::sendSelf() - channel failed to receive data\n";
00113                 cFactor = 1.0;
00114                 tStart  = 0.0;
00115                 tFinish = 0.0;
00116                 period  = 1.0;
00117                 pWidth  = 0.5;
00118                 shift   = 0.0;
00119                 return result;
00120         }
00121         cFactor = data(0);
00122         tStart  = data(1);
00123         tFinish = data(2);
00124         period  = data(3);
00125         pWidth  = data(4);
00126         shift   = data(5);
00127         
00128         return 0;    
00129 }
00130 
00131 
00132 void PulseSeries::Print(OPS_Stream &s, int flag)
00133 {
00134         s << "Pulse Series" << endln;
00135         s << "\tFactor: " << cFactor << endln;
00136         s << "\ttStart: " << tStart << endln;
00137         s << "\ttFinish: " << tFinish << endln;
00138         s << "\tPeriod: " << period << endln;
00139         s << "\tPulse Width: " << pWidth << endln;
00140         s << "\tPhase Shift: " << shift << endln;
00141 }

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