| 146 | |
| 147 | |
| 148 | int |
| 149 | SumElementForcesRecorder::setDomain(Domain &theDom) |
| 150 | { |
| 151 | theDomain = &theDom; |
| 152 | |
| 153 | // delete old data |
| 154 | if (theElements != 0) |
| 155 | delete [] theElements; |
| 156 | if (data != 0) |
| 157 | delete data; |
| 158 | |
| 159 | // set numEle |
| 160 | numEle = eleID.Size(); |
| 161 | if (numEle == 0) { |
| 162 | opserr << "WARNING SumElementForcesRecorder::initialize() - no elements tags passed in input!\n"; |
| 163 | return 0; |
| 164 | } |
| 165 | |
| 166 | // create theElements, an array of pointers to elements |
| 167 | theElements = new Element *[numEle]; |
| 168 | if (theElements == 0) { |
| 169 | opserr << "WARNING SumElementForcesRecorder::initialize() - out of memory\n"; |
| 170 | numEle = 0; // set numEle = 0, in case record() still called |
| 171 | return -1; |
| 172 | } |
| 173 | |
| 174 | // zero theElements array |
| 175 | for (int k=0; k<numEle; k++) |
| 176 | theElements[k] = 0; |
| 177 | |
| 178 | // |
| 179 | // loop over the list of elements, |
| 180 | // if element exists add it's pointer o the array |
| 181 | // get its resisting force, check size to determine compatible with others |
| 182 | // |
| 183 | |
| 184 | int sizeArray = -1; |
| 185 | |
| 186 | for (int i=0; i<numEle; i++) { |
| 187 | int eleTag = eleID(i); |
| 188 | |
| 189 | Element *theEle = theDomain->getElement(eleTag); |
| 190 | |
| 191 | if (theEle != 0) { |
| 192 | |
| 193 | const Vector &force = theEle->getResistingForce(); |
| 194 | int forceSize = force.Size(); |
| 195 | if (sizeArray == -1) { |
| 196 | sizeArray = forceSize; |
| 197 | theElements[i] = theEle; |
| 198 | } else if (sizeArray != forceSize) { |
| 199 | opserr << "WARNING: forces mismatch - element: " << eleTag << " will not be included\n"; |
| 200 | } else { |
| 201 | theElements[i] = theEle; |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 |
no test coverage detected