00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00091 #ifndef __vtkDistributedDataFilter_h
00092 #define __vtkDistributedDataFilter_h
00093
00094 #include "vtkDataObjectAlgorithm.h"
00095
00096 class vtkBSPCuts;
00097 class vtkDataArray;
00098 class vtkDistributedDataFilterSTLCloak;
00099 class vtkFloatArray;
00100 class vtkIdList;
00101 class vtkIdTypeArray;
00102 class vtkIntArray;
00103 class vtkModelMetadata;
00104 class vtkMultiProcessController;
00105 class vtkPKdTree;
00106 class vtkUnstructuredGrid;
00107
00108 class VTK_PARALLEL_EXPORT vtkDistributedDataFilter: public vtkDataObjectAlgorithm
00109 {
00110 vtkTypeMacro(vtkDistributedDataFilter,
00111 vtkDataObjectAlgorithm);
00112
00113 public:
00114 void PrintSelf(ostream& os, vtkIndent indent);
00115
00116 static vtkDistributedDataFilter *New();
00117
00119
00120 void SetController(vtkMultiProcessController *c);
00121 vtkGetObjectMacro(Controller, vtkMultiProcessController);
00123
00132 vtkPKdTree *GetKdtree();
00133
00148 vtkBooleanMacro(RetainKdtree, int);
00149 vtkGetMacro(RetainKdtree, int);
00150 vtkSetMacro(RetainKdtree, int);
00151
00161 vtkBooleanMacro(IncludeAllIntersectingCells, int);
00162 vtkGetMacro(IncludeAllIntersectingCells, int);
00163 vtkSetMacro(IncludeAllIntersectingCells, int);
00164
00169 vtkBooleanMacro(ClipCells, int);
00170 vtkGetMacro(ClipCells, int);
00171 vtkSetMacro(ClipCells, int);
00172
00173
00174 enum BoundaryModes {
00175 ASSIGN_TO_ONE_REGION=0,
00176 ASSIGN_TO_ALL_INTERSECTING_REGIONS=1,
00177 SPLIT_BOUNDARY_CELLS=2
00178 };
00179
00180
00182
00183 void SetBoundaryMode(int mode);
00184 void SetBoundaryModeToAssignToOneRegion()
00185 { this->SetBoundaryMode(vtkDistributedDataFilter::ASSIGN_TO_ONE_REGION); }
00186 void SetBoundaryModeToAssignToAllIntersectingRegions()
00187 { this->SetBoundaryMode(
00188 vtkDistributedDataFilter::ASSIGN_TO_ALL_INTERSECTING_REGIONS);
00189 }
00190 void SetBoundaryModeToSplitBoundaryCells()
00191 { this->SetBoundaryMode(vtkDistributedDataFilter::SPLIT_BOUNDARY_CELLS); }
00192 int GetBoundaryMode();
00194
00196 virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00197
00205 vtkBooleanMacro(UseMinimalMemory, int);
00206 vtkGetMacro(UseMinimalMemory, int);
00207 vtkSetMacro(UseMinimalMemory, int);
00208
00209
00212 vtkBooleanMacro(Timing, int);
00213 vtkSetMacro(Timing, int);
00214 vtkGetMacro(Timing, int);
00215
00217
00222 vtkBSPCuts* GetCuts() {return this->UserCuts;}
00223 void SetCuts(vtkBSPCuts* cuts);
00225
00234 void SetUserRegionAssignments(const int *map, int numRegions);
00235
00236 protected:
00237 vtkDistributedDataFilter();
00238 ~vtkDistributedDataFilter();
00239
00245 void AssignBoundaryCellsToOneRegionOn();
00246 void AssignBoundaryCellsToOneRegionOff();
00247 void SetAssignBoundaryCellsToOneRegion(int val);
00248
00256 void AssignBoundaryCellsToAllIntersectingRegionsOn();
00257 void AssignBoundaryCellsToAllIntersectingRegionsOff();
00258 void SetAssignBoundaryCellsToAllIntersectingRegions(int val);
00259
00266 void DivideBoundaryCellsOn();
00267 void DivideBoundaryCellsOff();
00268 void SetDivideBoundaryCells(int val);
00269
00274 virtual int RequestData(vtkInformation *, vtkInformationVector **,
00275 vtkInformationVector *);
00276 void SingleProcessExecute(vtkDataSet *input, vtkUnstructuredGrid *output);
00277 virtual int RequestInformation(vtkInformation *, vtkInformationVector **,
00278 vtkInformationVector *);
00279 virtual int FillInputPortInformation(int port, vtkInformation *info);
00280
00282
00285 virtual int RequestDataObject(vtkInformation*,
00286 vtkInformationVector**,
00287 vtkInformationVector*);
00289
00291
00292 int RequestDataInternal(vtkDataSet* input, vtkUnstructuredGrid* output);
00293
00294 private:
00296
00297 enum{
00298 DeleteNo = 0,
00299 DeleteYes = 1
00300 };
00301
00302 enum{
00303 DuplicateCellsNo = 0,
00304 DuplicateCellsYes = 1
00305 };
00306
00307 enum{
00308 GhostCellsNo = 0,
00309 GhostCellsYes = 1
00310 };
00311
00312 enum{
00313 UnsetGhostLevel = 99
00314 };
00315
00317 int PartitionDataAndAssignToProcesses(vtkDataSet *set);
00318
00320 vtkUnstructuredGrid *RedistributeDataSet(vtkDataSet *set, vtkDataSet *input);
00321
00323 int ClipGridCells(vtkUnstructuredGrid *grid);
00324
00326 vtkUnstructuredGrid * AcquireGhostCells(vtkUnstructuredGrid *grid);
00327
00329 void ComputeMyRegionBounds();
00330
00332 int CheckFieldArrayTypes(vtkDataSet *set);
00333
00336 vtkDataSet *TestFixTooFewInputFiles(vtkDataSet *input);
00337
00339 vtkUnstructuredGrid *MPIRedistribute(vtkDataSet *in, vtkDataSet *input);
00340
00342 vtkIdList **GetCellIdsForProcess(int proc, int *nlists);
00343
00346 void SetUpPairWiseExchange();
00347
00349
00350 void FreeIntArrays(vtkIdTypeArray **ar);
00351 static void FreeIdLists(vtkIdList**lists, int nlists);
00352 static vtkIdType GetIdListSize(vtkIdList**lists, int nlists);
00354
00356
00357 vtkIdTypeArray *ExchangeCounts(vtkIdType myCount, int tag);
00358 vtkIdTypeArray *ExchangeCountsLean(vtkIdType myCount, int tag);
00359 vtkIdTypeArray *ExchangeCountsFast(vtkIdType myCount, int tag);
00361
00363
00364 vtkIdTypeArray **ExchangeIdArrays(vtkIdTypeArray **arIn,
00365 int deleteSendArrays, int tag);
00366 vtkIdTypeArray **ExchangeIdArraysLean(vtkIdTypeArray **arIn,
00367 int deleteSendArrays, int tag);
00368 vtkIdTypeArray **ExchangeIdArraysFast(vtkIdTypeArray **arIn,
00369 int deleteSendArrays, int tag);
00371
00373
00374 vtkFloatArray **ExchangeFloatArrays(vtkFloatArray **myArray,
00375 int deleteSendArrays, int tag);
00376 vtkFloatArray **ExchangeFloatArraysLean(vtkFloatArray **myArray,
00377 int deleteSendArrays, int tag);
00378 vtkFloatArray **ExchangeFloatArraysFast(vtkFloatArray **myArray,
00379 int deleteSendArrays, int tag);
00381
00383
00384 vtkUnstructuredGrid *ExchangeMergeSubGrids(vtkIdList **cellIds, int deleteCellIds,
00385 vtkDataSet *myGrid, int deleteMyGrid,
00386 int filterOutDuplicateCells, int ghostCellFlag, int tag);
00387 vtkUnstructuredGrid *ExchangeMergeSubGrids(vtkIdList ***cellIds, int *numLists,
00388 int deleteCellIds,
00389 vtkDataSet *myGrid, int deleteMyGrid,
00390 int filterOutDuplicateCells, int ghostCellFlag, int tag);
00391 vtkUnstructuredGrid *ExchangeMergeSubGridsLean(
00392 vtkIdList ***cellIds, int *numLists,
00393 int deleteCellIds,
00394 vtkDataSet *myGrid, int deleteMyGrid,
00395 int filterOutDuplicateCells, int ghostCellFlag, int tag);
00396 vtkUnstructuredGrid *ExchangeMergeSubGridsFast(
00397 vtkIdList ***cellIds, int *numLists,
00398 int deleteCellIds,
00399 vtkDataSet *myGrid, int deleteMyGrid,
00400 int filterOutDuplicateCells, int ghostCellFlag, int tag);
00402
00403
00405
00406 char *MarshallDataSet(vtkUnstructuredGrid *extractedGrid, int &size);
00407 vtkUnstructuredGrid *UnMarshallDataSet(char *buf, int size);
00409
00411
00412 void ClipCellsToSpatialRegion(vtkUnstructuredGrid *grid);
00413 void ClipWithVtkClipDataSet(vtkUnstructuredGrid *grid, double *bounds,
00414 vtkUnstructuredGrid **outside, vtkUnstructuredGrid **inside);
00416
00417 void ClipWithBoxClipDataSet(vtkUnstructuredGrid *grid, double *bounds,
00418 vtkUnstructuredGrid **outside, vtkUnstructuredGrid **inside);
00419
00421
00425 vtkIdTypeArray *GetGlobalNodeIdArray(vtkDataSet *set);
00426 vtkIdType *GetGlobalNodeIds(vtkDataSet *set);
00427 vtkIdTypeArray *GetGlobalElementIdArray(vtkDataSet *set);
00428 vtkIdType *GetGlobalElementIds(vtkDataSet *set);
00429 int AssignGlobalNodeIds(vtkUnstructuredGrid *grid);
00430 int AssignGlobalElementIds(vtkDataSet *in);
00431 vtkIdTypeArray **FindGlobalPointIds(vtkFloatArray **ptarray,
00432 vtkIdTypeArray *ids, vtkUnstructuredGrid *grid, vtkIdType &numUniqueMissingPoints);
00434
00436
00437 vtkIdTypeArray **MakeProcessLists(vtkIdTypeArray **pointIds,
00438 vtkDistributedDataFilterSTLCloak *procs);
00440
00442
00443 vtkIdList **BuildRequestedGrids( vtkIdTypeArray **globalPtIds,
00444 vtkUnstructuredGrid *grid,
00445 vtkDistributedDataFilterSTLCloak *ptIdMap);
00447
00449
00450 int InMySpatialRegion(float x, float y, float z);
00451 int InMySpatialRegion(double x, double y, double z);
00452 int StrictlyInsideMyBounds(float x, float y, float z);
00453 int StrictlyInsideMyBounds(double x, double y, double z);
00455
00457
00458 vtkIdTypeArray **GetGhostPointIds(int ghostLevel, vtkUnstructuredGrid *grid,
00459 int AddCellsIAlreadyHave);
00460 vtkUnstructuredGrid *AddGhostCellsUniqueCellAssignment(
00461 vtkUnstructuredGrid *myGrid,
00462 vtkDistributedDataFilterSTLCloak *globalToLocalMap);
00463 vtkUnstructuredGrid *AddGhostCellsDuplicateCellAssignment(
00464 vtkUnstructuredGrid *myGrid,
00465 vtkDistributedDataFilterSTLCloak *globalToLocalMap);
00466 vtkUnstructuredGrid *SetMergeGhostGrid(
00467 vtkUnstructuredGrid *ghostCellGrid,
00468 vtkUnstructuredGrid *incomingGhostCells,
00469 int ghostLevel, vtkDistributedDataFilterSTLCloak *idMap);
00471
00473
00474 vtkUnstructuredGrid *ExtractCells(vtkIdList *list,
00475 int deleteCellLists, vtkDataSet *in, vtkModelMetadata *mmd);
00476 vtkUnstructuredGrid *ExtractCells(vtkIdList **lists, int nlists,
00477 int deleteCellLists, vtkDataSet *in, vtkModelMetadata *mmd);
00478 vtkUnstructuredGrid *ExtractZeroCellGrid(vtkDataSet *in,
00479 vtkModelMetadata *mmd);
00481
00483
00484 static int GlobalPointIdIsUsed(vtkUnstructuredGrid *grid,
00485 int ptId, vtkDistributedDataFilterSTLCloak *globalToLocal);
00486 static int LocalPointIdIsUsed(vtkUnstructuredGrid *grid, int ptId);
00487 static vtkIdType FindId(vtkIdTypeArray *ids, vtkIdType gid, vtkIdType startLoc);
00489
00491
00492 static vtkIdTypeArray *AddPointAndCells(vtkIdType gid,
00493 vtkIdType localId,
00494 vtkUnstructuredGrid *grid,
00495 vtkIdType *gidCells,
00496 vtkIdTypeArray *ids);
00498
00500
00501 static void AddConstantUnsignedCharPointArray(vtkUnstructuredGrid *grid,
00502 const char *arrayName, unsigned char val);
00503 static void AddConstantUnsignedCharCellArray(vtkUnstructuredGrid *grid,
00504 const char *arrayName, unsigned char val);
00506
00508
00509 static void RemoveRemoteCellsFromList(vtkIdList *cellList,
00510 vtkIdType *gidCells,
00511 vtkIdType *remoteCells,
00512 vtkIdType nRemoteCells);
00514
00516
00517 static vtkUnstructuredGrid *MergeGrids(vtkDataSet **sets, int nsets,
00518 int deleteDataSets,
00519 int useGlobalNodeIds, float pointMergeTolerance,
00520 int useGlobalCellIds);
00522
00524
00525 void AddMetadata(vtkUnstructuredGrid *grid, vtkModelMetadata *mmd);
00526 static int HasMetadata(vtkDataSet *s);
00528
00529 vtkPKdTree *Kdtree;
00530 vtkMultiProcessController *Controller;
00531
00532 int NumProcesses;
00533 int MyId;
00534
00535 int *Target;
00536 int *Source;
00537
00538 int NumConvexSubRegions;
00539 double *ConvexSubRegionBounds;
00540
00541 int GhostLevel;
00542
00543 int RetainKdtree;
00544 int IncludeAllIntersectingCells;
00545 int ClipCells;
00546 int AssignBoundaryCellsToOneRegion;
00547 int AssignBoundaryCellsToAllIntersectingRegions;
00548 int DivideBoundaryCells;
00549
00550 int Timing;
00551
00552 int NextProgressStep;
00553 double ProgressIncrement;
00554
00555 int UseMinimalMemory;
00556
00557 vtkBSPCuts* UserCuts;
00558
00559 vtkDistributedDataFilter(const vtkDistributedDataFilter&);
00560 void operator=(const vtkDistributedDataFilter&);
00561
00562 class vtkInternals;
00563 vtkInternals* Internals;
00564
00565 };
00566 #endif