| 2370 | |
| 2371 | |
| 2372 | int VTKHDF_Recorder::writeAccel(void) |
| 2373 | { |
| 2374 | // write accel |
| 2375 | std::vector<double> accelData(numNode * 3, 0.0); |
| 2376 | for (auto i : theNodeTags) { |
| 2377 | Node *theNode=theDomain->getNode(i); |
| 2378 | const Vector &accel=theNode->getAccel(); |
| 2379 | int mappedIndex = theNodeMapping[i]; |
| 2380 | int size = theNode->getCrds().Size(); |
| 2381 | |
| 2382 | accelData[3 * mappedIndex + 0] = (size > 0) ? accel(0) : 0.0; |
| 2383 | accelData[3 * mappedIndex + 1] = (size > 1) ? accel(1) : 0.0; |
| 2384 | accelData[3 * mappedIndex + 2] = (size > 2) ? accel(2) : 0.0; |
| 2385 | } |
| 2386 | |
| 2387 | { |
| 2388 | // Open dataset in point_data_group and resize it to the new number of steps |
| 2389 | hid_t dset_id = H5Dopen(point_data_group, "acceleration", H5P_DEFAULT); |
| 2390 | if (dset_id < 0) { |
| 2391 | opserr << "Error opening dataset 'acceleration'\n"; |
| 2392 | return -1; |
| 2393 | } |
| 2394 | |
| 2395 | // Get the current dataspace and dimensions |
| 2396 | hid_t space_id = H5Dget_space(dset_id); |
| 2397 | if (space_id < 0) { |
| 2398 | opserr << "Error getting dataspace for 'acceleration'\n"; |
| 2399 | H5Dclose(dset_id); |
| 2400 | return -1; |
| 2401 | } |
| 2402 | |
| 2403 | // Get the current dimensions |
| 2404 | hsize_t current_dims[2]; |
| 2405 | if (H5Sget_simple_extent_dims(space_id, current_dims, NULL) < 0) { |
| 2406 | opserr << "Error getting current dimensions\n"; |
| 2407 | H5Sclose(space_id); |
| 2408 | H5Dclose(dset_id); |
| 2409 | return -1; |
| 2410 | } |
| 2411 | |
| 2412 | // Calculate new dimensions (current rows + new rows, same columns) |
| 2413 | hsize_t new_dims[2] = {current_dims[0] + static_cast<hsize_t>(numNode), 3}; |
| 2414 | |
| 2415 | // Extend the dataset |
| 2416 | if (H5Dset_extent(dset_id, new_dims) < 0) { |
| 2417 | opserr << "Error setting new extent for 'acceleration'\n"; |
| 2418 | H5Sclose(space_id); |
| 2419 | H5Dclose(dset_id); |
| 2420 | return -1; |
| 2421 | } |
| 2422 | |
| 2423 | // Get the new dataspace |
| 2424 | hid_t new_space_id = H5Dget_space(dset_id); |
| 2425 | if (new_space_id < 0) { |
| 2426 | opserr << "Error getting new dataspace for 'acceleration'\n"; |
| 2427 | H5Sclose(space_id); |
| 2428 | H5Dclose(dset_id); |
| 2429 | return -1; |