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

Method SerializeFieldData

Filters/ParallelGeometry/vtkPStructuredGridConnectivity.cxx:827–883  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

825
826//------------------------------------------------------------------------------
827void vtkPStructuredGridConnectivity::SerializeFieldData(
828 int GridExtent[6], int ext[6], vtkFieldData* fieldData, vtkMultiProcessStream& bytestream)
829{
830 assert("pre: FieldData is nullptr" && (fieldData != nullptr));
831
832 // STEP 0: Write the number of arrays
833 bytestream << fieldData->GetNumberOfArrays();
834
835 // For each array:
836 for (int array = 0; array < fieldData->GetNumberOfArrays(); ++array)
837 {
838 vtkDataArray* myArray = fieldData->GetArray(array);
839 assert("pre: attempting to serialize a nullptr array!" && (myArray != nullptr));
840
841 // STEP 1: Extract the ghost data within the given ext
842 // Allocate the ghost array where the data will be extracted
843 vtkDataArray* ghostArray = vtkDataArray::CreateDataArray(myArray->GetDataType());
844
845 ghostArray->SetName(myArray->GetName());
846 ghostArray->SetNumberOfComponents(myArray->GetNumberOfComponents());
847 ghostArray->SetNumberOfTuples(vtkStructuredData::GetNumberOfPoints(ext));
848
849 int ijk[3];
850 for (int i = ext[0]; i <= ext[1]; ++i)
851 {
852 for (int j = ext[2]; j <= ext[3]; ++j)
853 {
854 for (int k = ext[4]; k <= ext[5]; ++k)
855 {
856 ijk[0] = i;
857 ijk[1] = j;
858 ijk[2] = k;
859 assert("pre: IJK is outside the grid extent!" &&
860 this->IsNodeWithinExtent(i, j, k, GridExtent));
861
862 // Compute the source index from the grid extent. Note, this could
863 // be a cell index if the incoming GridExtent and ext are cell extents.
864 vtkIdType sourceIdx = vtkStructuredData::ComputePointIdForExtent(GridExtent, ijk);
865 assert("pre: source index is out-of-bounds!" && (sourceIdx >= 0) &&
866 (sourceIdx < myArray->GetNumberOfTuples()));
867
868 // Compute the target index from the grid extent. Note, this could
869 // be a cell index if the incoming GridExtent and ext are cell extents.
870 vtkIdType targetIdx = vtkStructuredData::ComputePointIdForExtent(ext, ijk);
871 assert("pre: target index is out-of-bounds!" && (targetIdx >= 0) &&
872 (targetIdx < ghostArray->GetNumberOfTuples()));
873
874 ghostArray->SetTuple(targetIdx, sourceIdx, myArray);
875 } // END for k
876 } // END for j
877 } // END for i
878
879 // STEP 3: Serialize the ghost array
880 bytestream.Push(ghostArray);
881 ghostArray->Delete();
882 } // END for all arrays
883}
884

Callers 2

Calls 15

IsNodeWithinExtentMethod · 0.80
DeleteMethod · 0.65
assertFunction · 0.50
CreateDataArrayFunction · 0.50
GetNumberOfPointsFunction · 0.50
GetNumberOfArraysMethod · 0.45
GetArrayMethod · 0.45
GetDataTypeMethod · 0.45
SetNameMethod · 0.45
GetNameMethod · 0.45
SetNumberOfComponentsMethod · 0.45
GetNumberOfComponentsMethod · 0.45

Tested by

no test coverage detected