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 #include <ElementalLoad.h>
00032 #include <Element.h>
00033 #include <Domain.h>
00034
00035 ElementalLoad::ElementalLoad(int tag, int cTag, const ID &theEleTags)
00036 :Load(tag, cTag), theElementTags(0), theElements(0), numElements(0)
00037 {
00038 theElementTags = new ID(theEleTags);
00039 if (theElementTags != 0)
00040 numElements = theElementTags->Size();
00041 }
00042
00043 ElementalLoad::ElementalLoad(int tag, int cTag)
00044 :Load(tag, cTag), theElementTags(0), theElements(0), numElements(0)
00045 {
00046
00047 }
00048
00049
00050
00051 ElementalLoad::ElementalLoad(int cTag)
00052 :Load(0, cTag), theElementTags(0), theElements(0), numElements(0)
00053 {
00054
00055 }
00056
00057 ElementalLoad::~ElementalLoad()
00058 {
00059 if (theElementTags != 0)
00060 delete theElementTags;
00061
00062 if (theElements != 0)
00063 delete [] theElements;
00064 }
00065
00066
00067 void
00068 ElementalLoad::setDomain(Domain *theDomain)
00069 {
00070 this->DomainComponent::setDomain(theDomain);
00071
00072 int size = 0;
00073 if (theElementTags != 0) {
00074 size = theElementTags->Size();
00075 if (theElements == 0)
00076 delete [] theElements;
00077 theElements = new Element *[size];
00078
00079 for (int i=0; i<size; i++) {
00080 theElements[i] = theDomain->getElement((*theElementTags)(i));
00081 if (theElements[i] == 0) {
00082 opserr << "WARNING - ElementalLoad::setDomain - ele with tag ";
00083 opserr << (*theElementTags)(i) << " does not exist in the domain\n";
00084 }
00085 }
00086 }
00087 }
00088
00089 void
00090 ElementalLoad::applyLoad(double loadFactor)
00091 {
00092 for (int i=0; i<numElements; i++)
00093 if (theElements[i] != 0)
00094 theElements[i]->addLoad(this, loadFactor);
00095 }
00096
00097 const Vector&
00098 ElementalLoad::getSensitivityData(int gradNumber)
00099 {
00100 static Vector trash(10);
00101
00102 return trash;
00103 }
00104
00105 const ID &
00106 ElementalLoad::getElementTags(void)
00107 {
00108 return *theElementTags;
00109 }
00110
00111
00112 int
00113 ElementalLoad::removeElement(int tag)
00114 {
00115 int loc = theElementTags->getLocation(tag);
00116 if (loc >= 0) {
00117 (*theElementTags)(loc) = -1;
00118 for (int i=loc; i<numElements-1; i++)
00119 theElements[i] = theElements[i+1];
00120 numElements--;
00121 }
00122
00123 return numElements;
00124 }
00125
00126 int
00127 ElementalLoad::setElementTags(const ID &theEleTags)
00128 {
00129 if (theElementTags != 0) {
00130 delete theElementTags;
00131 numElements = 0;
00132 }
00133
00134 theElementTags = new ID(theEleTags);
00135 if (theElementTags != 0)
00136 numElements = theElementTags->Size();
00137
00138 return 0;
00139 }
00140
00141