------------------------------------------------------------------------------
| 86 | |
| 87 | //------------------------------------------------------------------------------ |
| 88 | bool vtkPHyperTreeGridProbeFilter::Reduce( |
| 89 | vtkHyperTreeGrid* source, vtkDataSet* output, vtkIdList* localPointIds) |
| 90 | { |
| 91 | int procId = 0; |
| 92 | int numProcs = 1; |
| 93 | if (this->Controller) |
| 94 | { |
| 95 | procId = this->Controller->GetLocalProcessId(); |
| 96 | numProcs = this->Controller->GetNumberOfProcesses(); |
| 97 | } |
| 98 | |
| 99 | vtkIdType numPointsFound = localPointIds->GetNumberOfIds(); |
| 100 | if (procId != 0) |
| 101 | { |
| 102 | this->Controller->Send(&numPointsFound, 1, 0, HYPERTREEGRID_PROBE_COMMUNICATION_TAG); |
| 103 | if (numPointsFound > 0) |
| 104 | { |
| 105 | this->Controller->Send(output, 0, HYPERTREEGRID_PROBE_COMMUNICATION_TAG); |
| 106 | this->Controller->Send( |
| 107 | localPointIds->GetPointer(0), numPointsFound, 0, HYPERTREEGRID_PROBE_COMMUNICATION_TAG); |
| 108 | } |
| 109 | output->ReleaseData(); |
| 110 | localPointIds->Initialize(); |
| 111 | } |
| 112 | else |
| 113 | { |
| 114 | vtkIdType numRemotePoints = 0; |
| 115 | vtkSmartPointer<vtkDataSet> remoteOutput = vtk::TakeSmartPointer(output->NewInstance()); |
| 116 | vtkNew<vtkIdList> remotePointIds; |
| 117 | // deal with master process |
| 118 | remoteOutput->CopyStructure(output); |
| 119 | unsigned int numArrays = source->GetCellData()->GetNumberOfArrays(); |
| 120 | for (unsigned int iA = 0; iA < numArrays; iA++) |
| 121 | { |
| 122 | vtkDataArray* da = |
| 123 | output->GetPointData()->GetArray(source->GetCellData()->GetArray(iA)->GetName()); |
| 124 | auto localInstance = vtk::TakeSmartPointer(da->NewInstance()); |
| 125 | localInstance->DeepCopy(da); |
| 126 | remoteOutput->GetPointData()->AddArray(localInstance); |
| 127 | da->SetNumberOfTuples(output->GetNumberOfPoints()); |
| 128 | vtkHyperTreeGridProbeFilterUtilities::FillDefaultArray(da); |
| 129 | } |
| 130 | this->DealWithRemote(localPointIds, remoteOutput, source, output); |
| 131 | remoteOutput->Initialize(); |
| 132 | |
| 133 | // deal with other processes |
| 134 | if (numProcs > 1) |
| 135 | { |
| 136 | for (int iProc = 1; iProc < numProcs; iProc++) |
| 137 | { |
| 138 | this->Controller->Receive( |
| 139 | &numRemotePoints, 1, iProc, HYPERTREEGRID_PROBE_COMMUNICATION_TAG); |
| 140 | remotePointIds->SetNumberOfIds(numRemotePoints); |
| 141 | if (numRemotePoints > 0) |
| 142 | { |
| 143 | this->Controller->Receive(remoteOutput, iProc, HYPERTREEGRID_PROBE_COMMUNICATION_TAG); |
| 144 | remotePointIds->Initialize(); |
| 145 | remotePointIds->SetNumberOfIds(numRemotePoints); |