00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
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
00061 }
00062
00063
00064 TrigSeries::~TrigSeries()
00065 {
00066
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 }