| 2547 | |
| 2548 | |
| 2549 | int VTKHDF_Recorder::writeDisp(void) |
| 2550 | { |
| 2551 | // write disp |
| 2552 | std::vector<double> dispData(numNode * 3, 0.0); |
| 2553 | for (auto i : theNodeTags) { |
| 2554 | Node *theNode=theDomain->getNode(i); |
| 2555 | const Vector &disp=theNode->getDisp(); |
| 2556 | int mappedIndex = theNodeMapping[i]; |
| 2557 | int size = theNode->getCrds().Size(); |
| 2558 | |
| 2559 | dispData[3 * mappedIndex + 0] = (size > 0) ? disp(0) : 0.0; |
| 2560 | dispData[3 * mappedIndex + 1] = (size > 1) ? disp(1) : 0.0; |
| 2561 | dispData[3 * mappedIndex + 2] = (size > 2) ? disp(2) : 0.0; |
| 2562 | |
| 2563 | } |
| 2564 | |
| 2565 | { |
| 2566 | // Open dataset in point_data_group and resize it to the new number of steps |
| 2567 | hid_t dset_id = H5Dopen(point_data_group, "displacement", H5P_DEFAULT); |
| 2568 | if (dset_id < 0) { |
| 2569 | opserr << "Error opening dataset 'displacement'\n"; |
| 2570 | return -1; |
| 2571 | } |
| 2572 | |
| 2573 | // Get the current dataspace and dimensions |
| 2574 | hid_t space_id = H5Dget_space(dset_id); |
| 2575 | if (space_id < 0) { |
| 2576 | opserr << "Error getting dataspace for 'displacement'\n"; |
| 2577 | H5Dclose(dset_id); |
| 2578 | return -1; |
| 2579 | } |
| 2580 | |
| 2581 | // Get the current dimensions |
| 2582 | hsize_t current_dims[2]; |
| 2583 | if (H5Sget_simple_extent_dims(space_id, current_dims, NULL) < 0) { |
| 2584 | opserr << "Error getting current dimensions\n"; |
| 2585 | H5Sclose(space_id); |
| 2586 | H5Dclose(dset_id); |
| 2587 | return -1; |
| 2588 | } |
| 2589 | |
| 2590 | // Calculate new dimensions (current rows + new rows, same columns) |
| 2591 | hsize_t new_dims[2] = {current_dims[0] + static_cast<hsize_t>(numNode), 3}; |
| 2592 | |
| 2593 | // Extend the dataset |
| 2594 | if (H5Dset_extent(dset_id, new_dims) < 0) { |
| 2595 | opserr << "Error setting new extent for 'displacement'\n"; |
| 2596 | H5Sclose(space_id); |
| 2597 | H5Dclose(dset_id); |
| 2598 | return -1; |
| 2599 | } |
| 2600 | |
| 2601 | // Get the new dataspace |
| 2602 | hid_t new_space_id = H5Dget_space(dset_id); |
| 2603 | if (new_space_id < 0) { |
| 2604 | opserr << "Error getting new dataspace for 'displacement'\n"; |
| 2605 | H5Sclose(space_id); |
| 2606 | H5Dclose(dset_id); |