| 2729 | |
| 2730 | |
| 2731 | int VTKHDF_Recorder::writeStep(double timeStamp) |
| 2732 | { |
| 2733 | // Update numSteps and attribute |
| 2734 | numSteps++; |
| 2735 | const char* attr_name = "NSteps"; |
| 2736 | |
| 2737 | // Open and update NSteps attribute |
| 2738 | hid_t attr_id = H5Aopen(steps_group, attr_name, H5P_DEFAULT); |
| 2739 | if (attr_id < 0) { |
| 2740 | opserr << "Error: Failed to open 'NSteps' attribute\n"; |
| 2741 | return -1; |
| 2742 | } |
| 2743 | |
| 2744 | H5Awrite(attr_id, H5T_NATIVE_INT, &numSteps); |
| 2745 | H5Aclose(attr_id); |
| 2746 | |
| 2747 | // Values for each dataset |
| 2748 | const int newNumberOfParts = 1; // Always one rank per recorder |
| 2749 | const int newPointOffsets = current_PointOffset; |
| 2750 | const int newCellOffsets = current_CellOffset; |
| 2751 | const int newPartOffsets = current_PartOffset; |
| 2752 | const int newConnectivityIdOffsets = current_ConnectivityIdOffset; |
| 2753 | const double value = timeStamp; |
| 2754 | const int newNumPoints = numNode; |
| 2755 | const int newNumCells = numElement; |
| 2756 | const int newNumberOfConnectivityIds = numConnectivityIds; |
| 2757 | |
| 2758 | |
| 2759 | // Debug output (can be removed for production) |
| 2760 | // opserr << " Number of parts: " << newNumberOfParts << endln; |
| 2761 | // opserr << " Point offsets: " << newPointOffsets << endln; |
| 2762 | // opserr << " Cell offsets: " << newCellOffsets << endln; |
| 2763 | // opserr << " Part offsets: " << newPartOffsets << endln; |
| 2764 | // opserr << " Value: " << value << endln; |
| 2765 | // opserr << " Number of points: " << newNumPoints << endln; |
| 2766 | // opserr << " Number of cells: " << newNumCells << endln; |
| 2767 | // opserr << " Number of connectivity ids: " << newNumberOfConnectivityIds << endln; |
| 2768 | |
| 2769 | // Set up dimensions for dataset operations |
| 2770 | hsize_t newSize[1] = {static_cast<hsize_t>(numSteps)}; |
| 2771 | hsize_t start[1] = {static_cast<hsize_t>(numSteps - 1)}; |
| 2772 | hsize_t count[1] = {1}; |
| 2773 | |
| 2774 | // NumberOfParts |
| 2775 | { |
| 2776 | hid_t dset_id = H5Dopen(steps_group, "NumberOfParts", H5P_DEFAULT); |
| 2777 | if (dset_id < 0) { |
| 2778 | opserr << "Error: Failed to open 'NumberOfParts' dataset\n"; |
| 2779 | return -1; |
| 2780 | } |
| 2781 | |
| 2782 | H5Dset_extent(dset_id, newSize); |
| 2783 | hid_t file_space = H5Dget_space(dset_id); |
| 2784 | H5Sselect_hyperslab(file_space, H5S_SELECT_SET, start, NULL, count, NULL); |
| 2785 | |
| 2786 | // Create memory space and write data |
| 2787 | hid_t mem_space = H5Screate_simple(1, count, NULL); |
| 2788 | H5Dwrite(dset_id, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, &newNumberOfParts); |