MCPcopy Create free account
hub / github.com/Kitware/VTK / WriteData

Method WriteData

IO/HDF/vtkHDFWriter.cxx:242–311  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

240
241//------------------------------------------------------------------------------
242void 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 }

Callers 1

RequestDataMethod · 0.95

Calls 15

DispatchDataObjectMethod · 0.95
GetExternalBlockFileNameFunction · 0.85
OpenSubfileMethod · 0.80
to_stringFunction · 0.50
stringClass · 0.50
CreateFileMethod · 0.45
BarrierMethod · 0.45
GetInputMethod · 0.45
SetInputDataMethod · 0.45
SetFileNameMethod · 0.45

Tested by

no test coverage detected