------------------------------------------------------------------------------ Load variable data using files associated with cycle and point selection ------------------------------------------------------------------------------
| 625 | // Load variable data using files associated with cycle and point selection |
| 626 | //------------------------------------------------------------------------------ |
| 627 | void H5RageAdaptor::LoadVariableData( |
| 628 | vtkImageData* output, int timeStep, vtkDataArraySelection* pointDataArraySelection) |
| 629 | { |
| 630 | // Add FieldData array for cycle number |
| 631 | vtkNew<vtkDoubleArray> cycleArray; |
| 632 | cycleArray->SetName("CycleIndex"); |
| 633 | cycleArray->SetNumberOfComponents(1); |
| 634 | cycleArray->SetNumberOfTuples(1); |
| 635 | cycleArray->SetTuple1(0, this->TimeSteps[timeStep]); |
| 636 | output->GetFieldData()->AddArray(cycleArray); |
| 637 | |
| 638 | bool firstScalar = true; |
| 639 | for (int var = 0; var < this->NumberOfVariables; var++) |
| 640 | { |
| 641 | if (pointDataArraySelection->ArrayIsEnabled(this->VariableName[var].c_str())) |
| 642 | { |
| 643 | float* fData = nullptr; |
| 644 | double* dData = nullptr; |
| 645 | |
| 646 | // Proc 0 reads the HDF file verifying and getting data |
| 647 | // HDF data was written as column major and must be reversed |
| 648 | if (this->Rank == 0) |
| 649 | { |
| 650 | int offset = var * this->NumberOfTimeSteps + timeStep; |
| 651 | hid_t file_id = H5Fopen(this->HdfFileName[offset].c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); |
| 652 | hid_t dataset_id = H5Dopen(file_id, "data", hid_t(0)); |
| 653 | hid_t dataspace_id = H5Dget_space(dataset_id); |
| 654 | hid_t datatype_id = H5Dget_type(dataset_id); |
| 655 | hid_t ndims = H5Sget_simple_extent_ndims(dataspace_id); |
| 656 | hsize_t* dims_out = new hsize_t[ndims]; |
| 657 | H5Sget_simple_extent_dims(dataspace_id, dims_out, nullptr); |
| 658 | int* dimensions = new int[ndims]; |
| 659 | for (int dim = 0; dim < ndims; dim++) |
| 660 | { |
| 661 | dimensions[dim] = dims_out[dim]; |
| 662 | } |
| 663 | |
| 664 | hid_t memspace_id; |
| 665 | if (this->UseFloat64) |
| 666 | { |
| 667 | dData = new double[this->TotalTuples]; |
| 668 | memspace_id = H5Screate_simple(ndims, dims_out, nullptr); |
| 669 | H5Dread(dataset_id, H5T_NATIVE_DOUBLE, memspace_id, dataspace_id, H5P_DEFAULT, dData); |
| 670 | ConvertHDFData(ndims, dimensions, dData); |
| 671 | } |
| 672 | else |
| 673 | { |
| 674 | fData = new float[this->TotalTuples]; |
| 675 | memspace_id = H5Screate_simple(ndims, dims_out, nullptr); |
| 676 | H5Dread(dataset_id, H5T_NATIVE_FLOAT, memspace_id, dataspace_id, H5P_DEFAULT, fData); |
| 677 | ConvertHDFData(ndims, dimensions, fData); |
| 678 | } |
| 679 | |
| 680 | H5Tclose(datatype_id); |
| 681 | H5Dclose(dataset_id); |
| 682 | H5Sclose(memspace_id); |
| 683 | H5Sclose(dataspace_id); |
| 684 | H5Fclose(file_id); |
no test coverage detected