------------------------------------------------------------------------------
| 240 | |
| 241 | //------------------------------------------------------------------------------ |
| 242 | void vtkHDFWriter::WriteData() |
| 243 | { |
| 244 | this->Impl->SetSubFilesReady(false); |
| 245 | |
| 246 | // Root file group only needs to be opened for the first timestep |
| 247 | if (this->CurrentTimeIndex == 0) |
| 248 | { |
| 249 | // Write all pieces concurrently |
| 250 | if (this->NbPieces > 1) |
| 251 | { |
| 252 | const std::string partitionSuffix = "part" + vtk::to_string(this->CurrentPiece); |
| 253 | const std::string filePath = |
| 254 | ::GetExternalBlockFileName(std::string(this->FileName), partitionSuffix); |
| 255 | this->Impl->CreateFile(this->Overwrite, filePath); |
| 256 | } |
| 257 | else |
| 258 | { |
| 259 | if (!this->Impl->CreateFile(this->Overwrite, this->FileName)) |
| 260 | { |
| 261 | vtkErrorMacro(<< "Could not create file : " << this->FileName); |
| 262 | return; |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | // Wait for the file to be created |
| 268 | this->Controller->Barrier(); |
| 269 | |
| 270 | vtkDataObject* input = vtkDataObject::SafeDownCast(this->GetInput()); |
| 271 | |
| 272 | // Write the time step data in an external file |
| 273 | if (this->NbPieces == 1 && this->IsTemporal && this->UseExternalTimeSteps) |
| 274 | { |
| 275 | const std::string timestepSuffix = vtk::to_string(this->CurrentTimeIndex); |
| 276 | const std::string subFilePath = |
| 277 | ::GetExternalBlockFileName(std::string(this->FileName), timestepSuffix); |
| 278 | vtkNew<vtkHDFWriter> writer; |
| 279 | writer->SetInputData(input); |
| 280 | writer->SetFileName(subFilePath.c_str()); |
| 281 | writer->SetCompressionLevel(this->CompressionLevel); |
| 282 | writer->SetChunkSize(this->ChunkSize); |
| 283 | writer->SetUseExternalComposite(this->UseExternalComposite); |
| 284 | writer->SetUseExternalPartitions(this->UseExternalPartitions); |
| 285 | if (!writer->Write()) |
| 286 | { |
| 287 | vtkErrorMacro(<< "Could not write timestep file " << subFilePath); |
| 288 | return; |
| 289 | } |
| 290 | if (!this->Impl->OpenSubfile(subFilePath)) |
| 291 | { |
| 292 | vtkErrorMacro(<< "Could not open subfile" << subFilePath); |
| 293 | } |
| 294 | if (this->CurrentTimeIndex == this->NumberOfTimeSteps - 1) |
| 295 | { |
| 296 | // On the last timestep, the implementation creates virtual datasets referencing all |
| 297 | // Subfiles. This can only be done once we know the size of all sub-datasets. |
| 298 | this->Impl->SetSubFilesReady(true); |
| 299 | } |
no test coverage detected