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

Method SplitFiles

IO/CGNS/vtkFileSeriesHelper.cxx:493–528  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

491
492//----------------------------------------------------------------------------
493std::vector<std::string> vtkFileSeriesHelper::SplitFiles(
494 const std::vector<std::string>& activeFiles, int piece, int numPieces) const
495{
496 if (!this->PartitionedFiles || numPieces <= 1)
497 {
498 return activeFiles;
499 }
500
501 int numFiles = static_cast<int>(activeFiles.size());
502 if (numFiles > numPieces)
503 {
504 int filesPerRank = numFiles / numPieces;
505 int leftover = numFiles % numPieces;
506
507 int index = piece * filesPerRank + ((piece < leftover) ? piece : leftover);
508 int count = filesPerRank + ((piece < leftover) ? 1 : 0);
509
510 assert(index + count <= numFiles);
511
512 std::vector<std::string> myfiles(count);
513 for (int cc = 0; cc < count; ++cc)
514 {
515 myfiles[cc] = activeFiles[index + cc];
516 }
517 return myfiles;
518 }
519 else
520 {
521 std::vector<std::string> retval;
522 if (piece < numFiles)
523 {
524 retval.push_back(activeFiles[piece]);
525 }
526 return retval;
527 }
528}
529
530//----------------------------------------------------------------------------
531void vtkFileSeriesHelper::PrintSelf(ostream& os, vtkIndent indent)

Callers 1

GetActiveFilesMethod · 0.95

Calls 3

assertFunction · 0.50
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected