| 1012 | //------------------------------------------------------------------------------ |
| 1013 | template <typename T> |
| 1014 | void vtkADIOS2CoreImageReader::GatherTimeStepsFromADIOSTimeArray() |
| 1015 | { |
| 1016 | try |
| 1017 | { |
| 1018 | auto varADIOS2 = this->Impl->AdiosIO.InquireVariable<T>(this->TimeStepArray); |
| 1019 | |
| 1020 | size_t nSteps = varADIOS2.Steps(); |
| 1021 | size_t stepsStart = varADIOS2.StepsStart(); |
| 1022 | std::vector<int> dims = parseDimensions(this->Impl->AvailVars[this->TimeStepArray]["Shape"]); |
| 1023 | int multiplication{ 1 }; |
| 1024 | std::for_each(dims.begin(), dims.end(), [&multiplication](int v) { multiplication *= v; }); |
| 1025 | |
| 1026 | this->Impl->TimeSteps.clear(); |
| 1027 | // A temporary vector to hold time steps since ADIOS requires the variable and array should have |
| 1028 | // same type |
| 1029 | std::vector<T> tempTimeSteps(nSteps, 0); |
| 1030 | if (multiplication == 1 || multiplication == static_cast<int>(nSteps)) |
| 1031 | { |
| 1032 | // From Chuck: We should be able to read all steps at once but because of an ADIOS2 bug |
| 1033 | // we can only read one at a time |
| 1034 | for (size_t s = 0; s < nSteps; ++s) |
| 1035 | { |
| 1036 | varADIOS2.SetStepSelection({ stepsStart + s, 1 }); |
| 1037 | this->Impl->BpReader.Get(varADIOS2, tempTimeSteps.data() + s); |
| 1038 | } |
| 1039 | this->Impl->BpReader.PerformGets(); |
| 1040 | |
| 1041 | for (const auto v : tempTimeSteps) |
| 1042 | { |
| 1043 | this->Impl->TimeSteps.push_back(static_cast<double>(v)); |
| 1044 | } |
| 1045 | } |
| 1046 | else |
| 1047 | { |
| 1048 | for (int i = 0; i < static_cast<int>(nSteps); i++) |
| 1049 | { |
| 1050 | this->Impl->TimeSteps.push_back(static_cast<double>(stepsStart + i)); |
| 1051 | } |
| 1052 | } |
| 1053 | |
| 1054 | this->Impl->TimeStepsReverseMap.clear(); |
| 1055 | for (size_t i = 0; i < this->Impl->TimeSteps.size(); ++i) |
| 1056 | { |
| 1057 | this->Impl->TimeStepsReverseMap[this->Impl->TimeSteps[i]] = i; |
| 1058 | } |
| 1059 | } |
| 1060 | catch (const std::exception& ex) |
| 1061 | { |
| 1062 | vtkErrorMacro("Fail to gather time steps from time array " << this->TimeStepArray << ex.what()); |
| 1063 | } |
| 1064 | } |
| 1065 | VTK_ABI_NAMESPACE_END |