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

MultiSupportPattern.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: 2000/12/12 07:44:19 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/domain/pattern/MultiSupportPattern.cpp,v $
00024                                                                         
00025 // Written: fmk 11/00
00026 // Revised:
00027 //
00028 // Purpose: This file contains the class definition for MultiSupportPattern.
00029 // MultiSupportPattern is an abstract class.
00030 
00031 #include <MultiSupportPattern.h>
00032 #include <GroundMotion.h>
00033 
00034 #include <Domain.h>
00035 #include <SP_Constraint.h>
00036 #include <SP_ConstraintIter.h>
00037 #include <stdlib.h>
00038 #include <Channel.h>
00039 #include <ErrorHandler.h>
00040 
00041 MultiSupportPattern::MultiSupportPattern(int tag, int _classTag)
00042   :LoadPattern(tag, _classTag), 
00043   theMotions(0), theMotionTags(0,16), numMotions(0)
00044 {
00045 
00046 }
00047 
00048 
00049 MultiSupportPattern::MultiSupportPattern(int tag)
00050   :LoadPattern(tag, PATTERN_TAG_MultiSupportPattern), 
00051   theMotions(0), theMotionTags(0,16), numMotions(0)
00052 {
00053 
00054 }
00055 
00056 
00057 MultiSupportPattern::~MultiSupportPattern()
00058 {
00059   // invoke the destructor on all ground motions supplied
00060   for (int i=0; i<numMotions; i++)
00061       delete theMotions[i];
00062   
00063   if (theMotions != 0)
00064     //    free ((void *)theMotions);
00065     delete [] theMotions;
00066 }
00067 
00068 
00069 
00070 void 
00071 MultiSupportPattern::applyLoad(double time)
00072 {
00073   SP_Constraint *sp;
00074   SP_ConstraintIter &theIter = this->getSPs();
00075   while ((sp = theIter()) != 0)
00076     sp->applyConstraint(time);
00077 }
00078     
00079 
00080 int
00081 MultiSupportPattern::addMotion(GroundMotion &theMotion, int tag)
00082 {
00083   // ensure no motion with given tag already added
00084   if (theMotionTags.getLocation(tag) >= 0) {
00085     cerr << "MultiSupportPattern::addMotion - could not add new, motion wih same tag exists\n";
00086     return -1;
00087   }    
00088 
00089   // make space for new
00090   GroundMotion **newMotions = new GroundMotion *[numMotions+1];
00091   //  GroundMotion **newMotions = (GroundMotion **)malloc(sizeof(GroundMotion *)*(numMotions+1));
00092   if (newMotions == 0) {
00093     cerr << "MultiSupportPattern::addMotion - could not add new, out of mem\n";
00094     return -1;
00095   }
00096   
00097   // copy old
00098   for (int i=0; i<numMotions; i++)
00099     newMotions[i] = theMotions[i];
00100 
00101   // add the new motion to new
00102   newMotions[numMotions] = &theMotion;
00103 
00104   // delete the old
00105   if (theMotions != 0)
00106     delete [] theMotions;
00107 
00108   // reset
00109   theMotions = newMotions;
00110   theMotionTags[numMotions] = tag;
00111   numMotions++;
00112 
00113   return 0;
00114 }
00115 
00116 
00117 
00118 GroundMotion *
00119 MultiSupportPattern::getMotion(int tag)
00120 {
00121   int loc = theMotionTags.getLocation(tag);
00122   if (loc < 0)
00123     return 0;
00124   else
00125     return theMotions[loc];
00126 
00127 }
00128 
00129 
00130 bool
00131 MultiSupportPattern::addNodalLoad(NodalLoad *)
00132 {
00133   cerr << "MultiSupportPattern::addNodalLoad() - cannot add NodalLoad to EQ pattern\n";  
00134   return false;
00135 }
00136 
00137 bool
00138 MultiSupportPattern::addElementalLoad(ElementalLoad *)
00139 {
00140   cerr << "MultiSupportPattern::addElementalLoad() - cannot add ElementalLoad to EQ pattern\n";    
00141   return false;
00142 }
00143 
00144 
00145 
00146 int 
00147 MultiSupportPattern::sendSelf(int commitTag, Channel &theChannel)
00148 {
00149   return -1;
00150 }
00151 
00152 int 
00153 MultiSupportPattern::recvSelf(int commitTag, Channel &theChannel, 
00154     FEM_ObjectBroker &theBroker)
00155 {
00156   return -1;
00157 }
00158 
00159 void 
00160 MultiSupportPattern::Print(ostream &s, int flag)
00161 {
00162   s << "MultiSupportPattern  tag: " << this->getTag() << endl;
00163   SP_Constraint *sp;
00164   SP_ConstraintIter &theIter = this->getSPs();
00165   while ((sp = theIter()) != 0)
00166     sp->Print(s, flag);
00167 }
00168 
00169 LoadPattern *
00170 MultiSupportPattern::getCopy(void)
00171 {
00172   LoadPattern *theCopy = new MultiSupportPattern(this->getTag());
00173   return theCopy;
00174 }
Copyright Contact Us