Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

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.1.1.1 $
00022 // $Date: 2000/09/15 08:23:19 $
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   g3ErrorHandler->warning("%s -- input period is zero, setting period to PI",
00052   "TrigSeries::TrigSeries");
00053   period = 2*asin(1.0);
00054  }
00055 }
00056 
00057 TrigSeries::TrigSeries()
00058   :TimeSeries(TSERIES_TAG_TrigSeries),
00059    tStart(0.0),tFinish(0.0),period(1.0),shift(0.0),cFactor(1.0)
00060 {
00061   // does nothing
00062 }
00063 
00064 
00065 TrigSeries::~TrigSeries()
00066 {
00067   // does nothing
00068 }
00069 
00070 double
00071 TrigSeries::getFactor(double pseudoTime)
00072 {
00073  static double twopi = 4*asin(1.0);
00074 
00075  if (pseudoTime >= tStart && pseudoTime <= tFinish)
00076   return cFactor*sin(twopi*(pseudoTime-tStart)/period + shift);
00077  else
00078   return 0.0;
00079 }
00080 
00081 int
00082 TrigSeries::sendSelf(int commitTag, Channel &theChannel)
00083 {
00084   int dbTag = this->getDbTag();
00085   Vector data(5);
00086   data(0) = cFactor;
00087   data(1) = tStart; 
00088   data(2) = tFinish;
00089   data(3) = period;
00090   data(4) = shift;
00091   int result = theChannel.sendVector(dbTag,commitTag, data);
00092   if (result < 0) {
00093     cerr << "TrigSeries::sendSelf() - channel failed to send data\n";
00094     return result;
00095   }
00096   return 0;
00097 }
00098 
00099 
00100 int 
00101 TrigSeries::recvSelf(int commitTag, Channel &theChannel, 
00102          FEM_ObjectBroker &theBroker)
00103 {
00104   int dbTag = this->getDbTag();
00105   Vector data(5);
00106   int result = theChannel.recvVector(dbTag,commitTag, data);
00107   if (result < 0) {
00108     cerr << "TrigSeries::sendSelf() - channel failed to receive data\n";
00109     cFactor = 1.0;
00110     tStart= 0.0;
00111     tFinish = 0.0;
00112  period = 1.0;
00113  shift = 0.0;
00114     return result;
00115   }
00116   cFactor = data(0);
00117   tStart = data(1);
00118   tFinish = data(2);
00119   period = data(3);
00120   shift = data(4);
00121 
00122   return 0;    
00123 }
00124 
00125 void
00126 TrigSeries::Print(ostream &s, int flag)
00127 {
00128     s << "Trig Series" << endl;
00129  s << "\tFactor: " << cFactor << endl;
00130  s << "\ttStart: " << tStart << endl;
00131  s << "\ttFinish: " << tFinish << endl;
00132  s << "\tPeriod: " << period << endl;
00133  s << "\tPhase Shift: " << shift << endl;
00134 }
Copyright Contact Us