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

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