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

Method ParallelWriteNonCompositeData

IO/ParallelXML/vtkXMLPMultiBlockDataWriter.cxx:246–307  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

244
245//------------------------------------------------------------------------------
246int vtkXMLPMultiBlockDataWriter::ParallelWriteNonCompositeData(
247 vtkDataObject* dObj, vtkXMLDataElement* parentXML, int currentFileIndex)
248{
249 int myProcId = this->Controller->GetLocalProcessId();
250 if (myProcId == 0)
251 {
252 // pieceProcessList is a list where index is the process number and value is
253 // the data-type for the current leaf on that process.
254 int numberOfProcesses = this->Controller->GetNumberOfProcesses();
255 std::vector<int> pieceProcessList(numberOfProcesses);
256 this->XMLPMultiBlockDataWriterInternal->GetPieceProcessList(
257 currentFileIndex, pieceProcessList.data());
258
259 int numPieces = 0;
260 for (int procId = 0; procId < numberOfProcesses; procId++)
261 {
262 if (pieceProcessList[procId] >= 0)
263 {
264 numPieces++;
265 }
266 }
267 if (numPieces > 1)
268 {
269 // intentionally overwrite parentXML::Name from "DataSet" to
270 //"Piece" as the calling function did not know this had multiple
271 // pieces. It will still have the index that was set before.
272 parentXML->SetName("Piece");
273 }
274
275 int indexCounter = 0;
276 for (int procId = 0; procId < numberOfProcesses; procId++)
277 {
278 if (pieceProcessList[procId] >= 0)
279 {
280 vtkXMLDataElement* datasetXML = parentXML;
281 if (numPieces > 1)
282 {
283 // a hacky way to make sure that the pieces are nested into
284 // parentXML
285 datasetXML = vtkXMLDataElement::New();
286 datasetXML->SetName("DataSet");
287 datasetXML->SetIntAttribute("index", indexCounter);
288 parentXML->AddNestedElement(datasetXML);
289 datasetXML->Delete();
290 indexCounter++;
291 }
292 std::string fName =
293 this->CreatePieceFileName(currentFileIndex, procId, pieceProcessList[procId]);
294 datasetXML->SetAttribute("file", fName.c_str());
295 }
296 }
297 }
298
299 const int* datatypes_ptr = this->GetDataTypesPointer();
300 if (dObj && datatypes_ptr[currentFileIndex] != -1)
301 {
302 std::string fName =
303 this->CreatePieceFileName(currentFileIndex, myProcId, datatypes_ptr[currentFileIndex]);

Callers 1

WriteCompositeMethod · 0.95

Calls 13

CreatePieceFileNameMethod · 0.95
GetNumberOfProcessesMethod · 0.80
GetPieceProcessListMethod · 0.80
SetIntAttributeMethod · 0.80
AddNestedElementMethod · 0.80
GetDataTypesPointerMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
GetLocalProcessIdMethod · 0.45
dataMethod · 0.45
SetNameMethod · 0.45
SetAttributeMethod · 0.45

Tested by

no test coverage detected