| 2194 | } |
| 2195 | |
| 2196 | int VTKHDF_Recorder::writeVel(void) |
| 2197 | { |
| 2198 | // write vel |
| 2199 | std::vector<double> velData(numNode * 3, 0.0); |
| 2200 | for (auto i : theNodeTags) { |
| 2201 | Node *theNode=theDomain->getNode(i); |
| 2202 | const Vector &vel=theNode->getVel(); |
| 2203 | int mappedIndex = theNodeMapping[i]; |
| 2204 | int size = theNode->getCrds().Size(); |
| 2205 | |
| 2206 | velData[3 * mappedIndex + 0] = (size > 0) ? vel(0) : 0.0; |
| 2207 | velData[3 * mappedIndex + 1] = (size > 1) ? vel(1) : 0.0; |
| 2208 | velData[3 * mappedIndex + 2] = (size > 2) ? vel(2) : 0.0; |
| 2209 | } |
| 2210 | |
| 2211 | { |
| 2212 | // Open dataset in point_data_group and resize it to the new number of steps |
| 2213 | hid_t dset_id = H5Dopen(point_data_group, "velocity", H5P_DEFAULT); |
| 2214 | if (dset_id < 0) { |
| 2215 | opserr << "Error opening dataset 'velocity'\n"; |
| 2216 | return -1; |
| 2217 | } |
| 2218 | |
| 2219 | // Get the current dataspace and dimensions |
| 2220 | hid_t space_id = H5Dget_space(dset_id); |
| 2221 | if (space_id < 0) { |
| 2222 | opserr << "Error getting dataspace for 'velocity'\n"; |
| 2223 | H5Dclose(dset_id); |
| 2224 | return -1; |
| 2225 | } |
| 2226 | |
| 2227 | // Get the current dimensions |
| 2228 | hsize_t current_dims[2]; |
| 2229 | if (H5Sget_simple_extent_dims(space_id, current_dims, NULL) < 0) { |
| 2230 | opserr << "Error getting current dimensions\n"; |
| 2231 | H5Sclose(space_id); |
| 2232 | H5Dclose(dset_id); |
| 2233 | return -1; |
| 2234 | } |
| 2235 | |
| 2236 | // Calculate new dimensions (current rows + new rows, same columns) |
| 2237 | hsize_t new_dims[2] = {current_dims[0] + static_cast<hsize_t>(numNode), 3}; |
| 2238 | |
| 2239 | // Extend the dataset |
| 2240 | if (H5Dset_extent(dset_id, new_dims) < 0) { |
| 2241 | opserr << "Error setting new extent for 'velocity'\n"; |
| 2242 | H5Sclose(space_id); |
| 2243 | H5Dclose(dset_id); |
| 2244 | return -1; |
| 2245 | } |
| 2246 | |
| 2247 | // Get the new dataspace |
| 2248 | hid_t new_space_id = H5Dget_space(dset_id); |
| 2249 | if (new_space_id < 0) { |
| 2250 | opserr << "Error getting new dataspace for 'velocity'\n"; |
| 2251 | H5Sclose(space_id); |
| 2252 | H5Dclose(dset_id); |
| 2253 | return -1; |