------------------------------------------------------------------------------
| 2817 | |
| 2818 | //------------------------------------------------------------------------------ |
| 2819 | int vtkPDistributedDataFilter::AssignGlobalNodeIds(vtkUnstructuredGrid* grid) |
| 2820 | { |
| 2821 | TimeLog timer("AssignGlobalNodeIds", this->Timing); |
| 2822 | (void)timer; |
| 2823 | |
| 2824 | int nprocs = this->NumProcesses; |
| 2825 | int pid; |
| 2826 | vtkIdType ptId; |
| 2827 | vtkIdType nGridPoints = grid->GetNumberOfPoints(); |
| 2828 | |
| 2829 | vtkIdType* numPointsOutside = new vtkIdType[nprocs]; |
| 2830 | memset(numPointsOutside, 0, sizeof(vtkIdType) * nprocs); |
| 2831 | |
| 2832 | vtkIdTypeArray* globalIds = vtkIdTypeArray::New(); |
| 2833 | globalIds->SetNumberOfValues(nGridPoints); |
| 2834 | globalIds->SetName(TEMP_NODE_ID_NAME); |
| 2835 | |
| 2836 | // 1. Count the points in grid which lie within my assigned spatial region |
| 2837 | |
| 2838 | vtkIdType myNumPointsInside = 0; |
| 2839 | |
| 2840 | for (ptId = 0; ptId < nGridPoints; ptId++) |
| 2841 | { |
| 2842 | double* pt = grid->GetPoints()->GetPoint(ptId); |
| 2843 | |
| 2844 | if (this->InMySpatialRegion(pt[0], pt[1], pt[2])) |
| 2845 | { |
| 2846 | globalIds->SetValue(ptId, 0); // flag it as mine |
| 2847 | myNumPointsInside++; |
| 2848 | } |
| 2849 | else |
| 2850 | { |
| 2851 | // Well, whose region is this point in? |
| 2852 | |
| 2853 | int regionId = this->Kdtree->GetRegionContainingPoint(pt[0], pt[1], pt[2]); |
| 2854 | |
| 2855 | pid = this->Kdtree->GetProcessAssignedToRegion(regionId); |
| 2856 | |
| 2857 | numPointsOutside[pid]++; |
| 2858 | |
| 2859 | pid += 1; |
| 2860 | pid *= -1; |
| 2861 | |
| 2862 | globalIds->SetValue(ptId, pid); // a flag |
| 2863 | } |
| 2864 | } |
| 2865 | |
| 2866 | // 2. Gather and Broadcast this number of "Inside" points for each process. |
| 2867 | |
| 2868 | vtkIdTypeArray* numPointsInside = this->ExchangeCounts(myNumPointsInside, 0x0013); |
| 2869 | |
| 2870 | // 3. Assign global Ids to the points inside my spatial region |
| 2871 | |
| 2872 | vtkIdType firstId = 0; |
| 2873 | vtkIdType numGlobalIdsSoFar = 0; |
| 2874 | |
| 2875 | for (pid = 0; pid < nprocs; pid++) |
| 2876 | { |
no test coverage detected