InterpolatedGroundMotion.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:00:57 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/domain/groundMotion/InterpolatedGroundMotion.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/earthquake/InterpolatedGroundMotion.C
00027 // 
00028 // Written: fmk 
00029 // Created: 11/00
00030 // Revision: A
00031 //
00032 // Description: This file contains the class definition for 
00033 // InterpolatedGroundMotion. 
00034 //
00035 // What: "@(#) InterpolatedGroundMotion.C, revA"
00036 
00037 #include <InterpolatedGroundMotion.h>
00038 #include <stdlib.h>
00039 #include <math.h>
00040 #include <classTags.h>
00041 #include <Vector.h>
00042 #include <Channel.h>
00043 
00044 InterpolatedGroundMotion::InterpolatedGroundMotion()
00045 :GroundMotion(GROUND_MOTION_TAG_InterpolatedGroundMotion),
00046  theMotions(0), factors(0),
00047  destroyMotions(0), data(3), deltaPeak(0.0)
00048 {
00049     
00050 }
00051 
00052 InterpolatedGroundMotion::InterpolatedGroundMotion(GroundMotion **groundMotions, 
00053                                                    const Vector &fact,
00054                                                    bool destroyMotions,
00055                                                    double dT)
00056 :GroundMotion(GROUND_MOTION_TAG_InterpolatedGroundMotion),
00057  theMotions(0), factors(0),
00058  destroyMotions(0), data(3), deltaPeak(dT)
00059 {
00060   factors = new Vector(fact);
00061   theMotions = new GroundMotion *[fact.Size()];
00062 
00063   for (int i=0; i<fact.Size(); i++)
00064       theMotions[i] = groundMotions[i];
00065   
00066   if (destroyMotions == true)
00067     destroyMotions = 1;
00068 
00069 
00070 }
00071 
00072 
00073 InterpolatedGroundMotion::~InterpolatedGroundMotion()
00074 {
00075   if (destroyMotions == 1) {
00076       for (int i=0; i<factors->Size(); i++)
00077           delete theMotions[i];
00078   }  
00079   
00080   delete [] theMotions;
00081   delete factors;
00082 }
00083 
00084 double 
00085 InterpolatedGroundMotion::getDuration(void)
00086 {
00087   double value = 0.0;
00088   int numMotions = factors->Size();
00089   for (int i=0; i<numMotions; i++) {
00090       double motionValue = theMotions[i]->getDuration();
00091       if (motionValue > value)
00092           value = motionValue;
00093   }
00094   return value;
00095 }
00096 
00097 double 
00098 InterpolatedGroundMotion::getPeakAccel(void)
00099 {
00100   double value = 0.0;
00101   double duration = this->getDuration();
00102   double time = 0.0;
00103   while (time < duration) {
00104     double accel = this->getAccel(time);
00105     if (accel > value)
00106       value = accel;
00107     time += deltaPeak;
00108   }
00109   return value;
00110 }
00111 
00112 double 
00113 InterpolatedGroundMotion::getPeakVel(void)
00114 {
00115   double value = 0.0;
00116   double duration = this->getDuration();
00117   double time = 0.0;
00118   while (time < duration) {
00119     double accel = this->getVel(time);
00120     if (accel > value)
00121       value = accel;
00122     time += deltaPeak;
00123   }
00124   return value;
00125 }
00126 
00127 double 
00128 InterpolatedGroundMotion::getPeakDisp(void)
00129 {
00130   double value = 0.0;
00131   double duration = this->getDuration();
00132   double time = 0.0;
00133   while (time < duration) {
00134     double accel = this->getDisp(time);
00135     if (accel > value)
00136       value = accel;
00137     time += deltaPeak;
00138   }
00139   return value;
00140 }
00141 
00142 double 
00143 InterpolatedGroundMotion::getAccel(double time)
00144 {
00145   if (time < 0.0)
00146     return 0.0;
00147 
00148   double value = 0.0;
00149   int numMotions = factors->Size();
00150   for (int i=0; i<numMotions; i++) {
00151       value += (*factors)(i) * theMotions[i]->getAccel(time);
00152   }
00153 
00154   return value;
00155 
00156 }     
00157 
00158 double 
00159 InterpolatedGroundMotion::getVel(double time)
00160 {
00161   if (time < 0.0)
00162     return 0.0;
00163 
00164   double value = 0.0;
00165   int numMotions = factors->Size();
00166   for (int i=0; i<numMotions; i++) {
00167       value += (*factors)(i) * theMotions[i]->getVel(time);
00168   }
00169 
00170 
00171   return value;
00172 }
00173 
00174 double 
00175 InterpolatedGroundMotion::getDisp(double time)
00176 {
00177   if (time < 0.0)
00178     return 0.0;
00179 
00180   double value = 0.0;
00181   int numMotions = factors->Size();
00182   for (int i=0; i<numMotions; i++) {
00183       value += (*factors)(i) * theMotions[i]->getDisp(time);
00184   }
00185 
00186   return value;
00187 }
00188 
00189 const Vector &
00190 InterpolatedGroundMotion::getDispVelAccel(double time)
00191 {
00192   if (time < 0.0) {
00193     data(0) = 0.0;
00194     data(1) = 0.0;
00195     data(2) = 0.0;
00196     return data;
00197   }
00198 
00199   data.Zero();
00200   static Vector motionData(3);
00201 
00202   int numMotions = factors->Size();
00203   for (int i=0; i<numMotions; i++) {
00204       motionData = theMotions[i]->getDispVelAccel(time);
00205       motionData *= (*factors)(i);
00206       data += motionData;
00207   }
00208   
00209   return data;
00210 }
00211 
00212 
00213 int 
00214 InterpolatedGroundMotion::sendSelf(int commitTag, Channel &theChannel)
00215 {
00216   opserr << "InterpolatedGroundMotion::sendSelf() -- not yet implemented" << endln;
00217   return -1;
00218 }
00219 
00220 
00221 int 
00222 InterpolatedGroundMotion::recvSelf(int commitTag, Channel &theChannel,
00223                                    FEM_ObjectBroker &theBroker)
00224 {
00225   opserr << "InterpolatedGroundMotion::recvSelf() -- not yet impelemented" << endln;
00226   return -1;
00227 }
00228 
00229 
00230 

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