| 191 | } |
| 192 | |
| 193 | int OPS_nodeDisp() |
| 194 | { |
| 195 | if (OPS_GetNumRemainingInputArgs() < 1) { |
| 196 | opserr << "WARNING insufficient args: nodeDisp nodeTag <dof ...>\n"; |
| 197 | return -1; |
| 198 | } |
| 199 | |
| 200 | // tag and dof |
| 201 | int data[2] = {0, -1}; |
| 202 | int numdata = OPS_GetNumRemainingInputArgs(); |
| 203 | if (numdata > 2) { |
| 204 | numdata = 2; |
| 205 | } |
| 206 | |
| 207 | if (OPS_GetIntInput(&numdata, data) < 0) { |
| 208 | opserr<<"WARNING nodeDisp - failed to read int inputs\n"; |
| 209 | return -1; |
| 210 | } |
| 211 | data[1]--; |
| 212 | |
| 213 | // get response |
| 214 | Domain* theDomain = OPS_GetDomain(); |
| 215 | if (theDomain == 0) return -1; |
| 216 | const Vector *nodalResponse = theDomain->getNodeResponse(data[0], Disp); |
| 217 | |
| 218 | if (nodalResponse == 0) { |
| 219 | opserr << "WARNING no response is found\n"; |
| 220 | return -1; |
| 221 | } |
| 222 | |
| 223 | // set outputs |
| 224 | int size = nodalResponse->Size(); |
| 225 | if (data[1] >= 0) { |
| 226 | if (data[1] >= size) { |
| 227 | opserr << "WARNING nodeDisp nodeTag? dof? - dofTag? too large\n"; |
| 228 | return -1; |
| 229 | } |
| 230 | |
| 231 | double value = (*nodalResponse)(data[1]); |
| 232 | numdata = 1; |
| 233 | |
| 234 | if (OPS_SetDoubleOutput(&numdata, &value, true) < 0) { |
| 235 | opserr<<"WARNING nodeDisp - failed to read double inputs\n"; |
| 236 | return -1; |
| 237 | } |
| 238 | |
| 239 | |
| 240 | } else { |
| 241 | |
| 242 | std::vector<double> values(size); |
| 243 | for (int i=0; i<size; i++) { |
| 244 | values[i] = (*nodalResponse)(i); |
| 245 | } |
| 246 | if (OPS_SetDoubleOutput(&size, &values[0], false) < 0) { |
| 247 | opserr<<"WARNING nodeDisp - failed to read double inputs\n"; |
| 248 | return -1; |
| 249 | } |
| 250 | } |
no test coverage detected