VTK
vtkDistributedDataFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkDistributedDataFilter.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*----------------------------------------------------------------------------
16  Copyright (c) Sandia Corporation
17  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
18 ----------------------------------------------------------------------------*/
19 
89 #ifndef vtkDistributedDataFilter_h
90 #define vtkDistributedDataFilter_h
91 
92 #include "vtkFiltersParallelMPIModule.h" // For export macro
93 #include "vtkDataObjectAlgorithm.h"
94 
95 class vtkBSPCuts;
96 class vtkDataArray;
97 class vtkDistributedDataFilterSTLCloak;
98 class vtkFloatArray;
99 class vtkIdList;
100 class vtkIdTypeArray;
101 class vtkIntArray;
103 class vtkPKdTree;
104 class vtkUnstructuredGrid;
105 
106 class VTKFILTERSPARALLELMPI_EXPORT vtkDistributedDataFilter: public vtkDataObjectAlgorithm
107 {
108  vtkTypeMacro(vtkDistributedDataFilter,
110 
111 public:
112  void PrintSelf(ostream& os, vtkIndent indent) override;
113 
114  static vtkDistributedDataFilter *New();
115 
117 
120  void SetController(vtkMultiProcessController *c);
121  vtkGetObjectMacro(Controller, vtkMultiProcessController);
123 
134  vtkPKdTree *GetKdtree();
135 
153  vtkBooleanMacro(RetainKdtree, int);
154  vtkGetMacro(RetainKdtree, int);
155  vtkSetMacro(RetainKdtree, int);
156 
168  vtkBooleanMacro(IncludeAllIntersectingCells, int);
169  vtkGetMacro(IncludeAllIntersectingCells, int);
170  vtkSetMacro(IncludeAllIntersectingCells, int);
171 
178  vtkBooleanMacro(ClipCells, int);
179  vtkGetMacro(ClipCells, int);
180  vtkSetMacro(ClipCells, int);
181 
183  ASSIGN_TO_ONE_REGION=0,
184  ASSIGN_TO_ALL_INTERSECTING_REGIONS=1,
185  SPLIT_BOUNDARY_CELLS=2
186  };
187 
189 
192  void SetBoundaryMode(int mode);
194  { this->SetBoundaryMode(vtkDistributedDataFilter::ASSIGN_TO_ONE_REGION); }
196  { this->SetBoundaryMode(
198  }
200  { this->SetBoundaryMode(vtkDistributedDataFilter::SPLIT_BOUNDARY_CELLS); }
201  int GetBoundaryMode();
203 
208 
219  vtkBooleanMacro(UseMinimalMemory, int);
220  vtkGetMacro(UseMinimalMemory, int);
221  vtkSetMacro(UseMinimalMemory, int);
222 
227  vtkGetMacro(MinimumGhostLevel, int)
228  vtkSetMacro(MinimumGhostLevel, int)
229 
230 
234  vtkBooleanMacro(Timing, int);
235  vtkSetMacro(Timing, int);
236  vtkGetMacro(Timing, int);
237 
250  vtkBSPCuts* GetCuts() {return this->UserCuts;}
251  void SetCuts(vtkBSPCuts* cuts);
252 
262  void SetUserRegionAssignments(const int *map, int numRegions);
263 
264 protected:
267 
275  void AssignBoundaryCellsToOneRegionOn();
276  void AssignBoundaryCellsToOneRegionOff();
277  void SetAssignBoundaryCellsToOneRegion(int val);
278 
288  void AssignBoundaryCellsToAllIntersectingRegionsOn();
289  void AssignBoundaryCellsToAllIntersectingRegionsOff();
290  void SetAssignBoundaryCellsToAllIntersectingRegions(int val);
291 
300  void DivideBoundaryCellsOn();
301  void DivideBoundaryCellsOff();
302  void SetDivideBoundaryCells(int val);
303 
311  vtkInformationVector *) override;
312  void SingleProcessExecute(vtkDataSet *input, vtkUnstructuredGrid *output);
314  vtkInformationVector *) override;
315  virtual int FillInputPortInformation(int port, vtkInformation *info) override;
316 
322  virtual int RequestDataObject(vtkInformation*,
324  vtkInformationVector*) override;
325 
329  int RequestDataInternal(vtkDataSet* input, vtkUnstructuredGrid* output);
330 
331 private:
332 
333  enum{
334  DeleteNo = 0,
335  DeleteYes = 1
336  };
337 
338  enum{
339  DuplicateCellsNo = 0,
340  DuplicateCellsYes = 1
341  };
342 
343  enum{
344  GhostCellsNo = 0,
345  GhostCellsYes = 1
346  };
347 
348  enum{
349  UnsetGhostLevel = 99
350  };
351 
355  int PartitionDataAndAssignToProcesses(vtkDataSet *set);
356 
360  vtkUnstructuredGrid *RedistributeDataSet(vtkDataSet *set, vtkDataSet *input);
361 
365  int ClipGridCells(vtkUnstructuredGrid *grid);
366 
370  vtkUnstructuredGrid * AcquireGhostCells(vtkUnstructuredGrid *grid);
371 
375  void ComputeMyRegionBounds();
376 
380  int CheckFieldArrayTypes(vtkDataSet *set);
381 
387  vtkDataSet *TestFixTooFewInputFiles(vtkDataSet *input);
388 
392  vtkUnstructuredGrid *MPIRedistribute(vtkDataSet *in, vtkDataSet *input);
393 
397  vtkIdList **GetCellIdsForProcess(int proc, int *nlists);
398 
403  void SetUpPairWiseExchange();
404 
406 
409  void FreeIntArrays(vtkIdTypeArray **ar);
410  static void FreeIdLists(vtkIdList**lists, int nlists);
411  static vtkIdType GetIdListSize(vtkIdList**lists, int nlists);
413 
415 
418  vtkIdTypeArray *ExchangeCounts(vtkIdType myCount, int tag);
419  vtkIdTypeArray *ExchangeCountsLean(vtkIdType myCount, int tag);
420  vtkIdTypeArray *ExchangeCountsFast(vtkIdType myCount, int tag);
422 
424 
427  vtkIdTypeArray **ExchangeIdArrays(vtkIdTypeArray **arIn,
428  int deleteSendArrays, int tag);
429  vtkIdTypeArray **ExchangeIdArraysLean(vtkIdTypeArray **arIn,
430  int deleteSendArrays, int tag);
431  vtkIdTypeArray **ExchangeIdArraysFast(vtkIdTypeArray **arIn,
432  int deleteSendArrays, int tag);
434 
436 
439  vtkFloatArray **ExchangeFloatArrays(vtkFloatArray **myArray,
440  int deleteSendArrays, int tag);
441  vtkFloatArray **ExchangeFloatArraysLean(vtkFloatArray **myArray,
442  int deleteSendArrays, int tag);
443  vtkFloatArray **ExchangeFloatArraysFast(vtkFloatArray **myArray,
444  int deleteSendArrays, int tag);
446 
448 
451  vtkUnstructuredGrid *ExchangeMergeSubGrids(vtkIdList **cellIds, int deleteCellIds,
452  vtkDataSet *myGrid, int deleteMyGrid,
453  int filterOutDuplicateCells, int ghostCellFlag, int tag);
454  vtkUnstructuredGrid *ExchangeMergeSubGrids(vtkIdList ***cellIds, int *numLists,
455  int deleteCellIds,
456  vtkDataSet *myGrid, int deleteMyGrid,
457  int filterOutDuplicateCells, int ghostCellFlag, int tag);
458  vtkUnstructuredGrid *ExchangeMergeSubGridsLean(
459  vtkIdList ***cellIds, int *numLists,
460  int deleteCellIds,
461  vtkDataSet *myGrid, int deleteMyGrid,
462  int filterOutDuplicateCells, int ghostCellFlag, int tag);
463  vtkUnstructuredGrid *ExchangeMergeSubGridsFast(
464  vtkIdList ***cellIds, int *numLists,
465  int deleteCellIds,
466  vtkDataSet *myGrid, int deleteMyGrid,
467  int filterOutDuplicateCells, int ghostCellFlag, int tag);
469 
470 
472 
475  char* MarshallDataSet(vtkUnstructuredGrid* extractedGrid, vtkIdType& size);
476  vtkUnstructuredGrid* UnMarshallDataSet(char* buf, vtkIdType size);
478 
480 
483  void ClipCellsToSpatialRegion(vtkUnstructuredGrid *grid);
484 #if 0
485  void ClipWithVtkClipDataSet(vtkUnstructuredGrid *grid, double *bounds,
486  vtkUnstructuredGrid **outside, vtkUnstructuredGrid **inside);
487 #endif
488 
489 
490  void ClipWithBoxClipDataSet(vtkUnstructuredGrid *grid, double *bounds,
491  vtkUnstructuredGrid **outside, vtkUnstructuredGrid **inside);
492 
494 
500  vtkIdTypeArray *GetGlobalNodeIdArray(vtkDataSet *set);
501  vtkIdType *GetGlobalNodeIds(vtkDataSet *set);
502  vtkIdTypeArray *GetGlobalElementIdArray(vtkDataSet *set);
503  vtkIdType *GetGlobalElementIds(vtkDataSet *set);
504  int AssignGlobalNodeIds(vtkUnstructuredGrid *grid);
505  int AssignGlobalElementIds(vtkDataSet *in);
506  vtkIdTypeArray **FindGlobalPointIds(vtkFloatArray **ptarray,
507  vtkIdTypeArray *ids, vtkUnstructuredGrid *grid, vtkIdType &numUniqueMissingPoints);
509 
513  vtkIdTypeArray **MakeProcessLists(vtkIdTypeArray **pointIds,
514  vtkDistributedDataFilterSTLCloak *procs);
515 
519  vtkIdList **BuildRequestedGrids( vtkIdTypeArray **globalPtIds,
520  vtkUnstructuredGrid *grid,
521  vtkDistributedDataFilterSTLCloak *ptIdMap);
522 
524 
527  int InMySpatialRegion(float x, float y, float z);
528  int InMySpatialRegion(double x, double y, double z);
529  int StrictlyInsideMyBounds(float x, float y, float z);
530  int StrictlyInsideMyBounds(double x, double y, double z);
532 
534 
537  vtkIdTypeArray **GetGhostPointIds(int ghostLevel, vtkUnstructuredGrid *grid,
538  int AddCellsIAlreadyHave);
539  vtkUnstructuredGrid *AddGhostCellsUniqueCellAssignment(
540  vtkUnstructuredGrid *myGrid,
541  vtkDistributedDataFilterSTLCloak *globalToLocalMap);
542  vtkUnstructuredGrid *AddGhostCellsDuplicateCellAssignment(
543  vtkUnstructuredGrid *myGrid,
544  vtkDistributedDataFilterSTLCloak *globalToLocalMap);
545  vtkUnstructuredGrid *SetMergeGhostGrid(
546  vtkUnstructuredGrid *ghostCellGrid,
547  vtkUnstructuredGrid *incomingGhostCells,
548  int ghostLevel, vtkDistributedDataFilterSTLCloak *idMap);
550 
552 
555  vtkUnstructuredGrid *ExtractCells(vtkIdList *list,
556  int deleteCellLists, vtkDataSet *in);
557  vtkUnstructuredGrid *ExtractCells(vtkIdList **lists, int nlists,
558  int deleteCellLists, vtkDataSet *in);
559  vtkUnstructuredGrid *ExtractZeroCellGrid(vtkDataSet *in);
561 
563 
566  static int GlobalPointIdIsUsed(vtkUnstructuredGrid *grid,
567  int ptId, vtkDistributedDataFilterSTLCloak *globalToLocal);
568  static int LocalPointIdIsUsed(vtkUnstructuredGrid *grid, int ptId);
569  static vtkIdType FindId(vtkIdTypeArray *ids, vtkIdType gid, vtkIdType startLoc);
571 
575  static vtkIdTypeArray *AddPointAndCells(vtkIdType gid,
576  vtkIdType localId,
577  vtkUnstructuredGrid *grid,
578  vtkIdType *gidCells,
579  vtkIdTypeArray *ids);
580 
582 
585  static void AddConstantUnsignedCharPointArray(vtkUnstructuredGrid *grid,
586  const char *arrayName, unsigned char val);
587  static void AddConstantUnsignedCharCellArray(vtkUnstructuredGrid *grid,
588  const char *arrayName, unsigned char val);
590 
594  static void RemoveRemoteCellsFromList(vtkIdList *cellList,
595  vtkIdType *gidCells,
596  vtkIdType *remoteCells,
597  vtkIdType nRemoteCells);
598 
602  static vtkUnstructuredGrid *MergeGrids(vtkDataSet **sets, int nsets,
603  int deleteDataSets,
604  int useGlobalNodeIds, float pointMergeTolerance,
605  int useGlobalCellIds);
606 
607  vtkPKdTree *Kdtree;
608  vtkMultiProcessController *Controller;
609 
610  int NumProcesses;
611  int MyId;
612 
613  int *Target;
614  int *Source;
615 
616  int NumConvexSubRegions;
617  double *ConvexSubRegionBounds;
618 
619  // User-adjustable minimum number of ghost levels.
620  int MinimumGhostLevel;
621 
622  // Actual number of ghost levels used during execution.
623  int GhostLevel;
624 
625  int RetainKdtree;
626  int IncludeAllIntersectingCells;
627  int ClipCells;
628  int AssignBoundaryCellsToOneRegion;
629  int AssignBoundaryCellsToAllIntersectingRegions;
630  int DivideBoundaryCells;
631 
632  int Timing;
633 
634  int NextProgressStep;
635  double ProgressIncrement;
636 
637  int UseMinimalMemory;
638 
639  vtkBSPCuts* UserCuts;
640 
642  void operator=(const vtkDistributedDataFilter&) = delete;
643 
644  class vtkInternals;
645  vtkInternals* Internals;
646 
647 };
648 #endif
virtual int RequestDataObject(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
Build a k-d tree decomposition of a list of points.
Definition: vtkPKdTree.h:57
Store vtkAlgorithm input/output information.
This class represents an axis-aligned Binary Spatial Partitioning of a 3D space.
Definition: vtkBSPCuts.h:44
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
static vtkDataObjectAlgorithm * New()
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:35
void SetBoundaryModeToSplitBoundaryCells()
Handling of ClipCells and IncludeAllIntersectingCells.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:347
void SetBoundaryModeToAssignToAllIntersectingRegions()
Handling of ClipCells and IncludeAllIntersectingCells.
vtkBSPCuts * GetCuts()
You can set the k-d tree decomposition, rather than have D3 compute it.
void SetBoundaryModeToAssignToOneRegion()
Handling of ClipCells and IncludeAllIntersectingCells.
Distribute data among processors.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
a simple class to control print indentation
Definition: vtkIndent.h:33
list of point or cell ids
Definition: vtkIdList.h:30
dataset represents arbitrary combinations of all possible cell types
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
Superclass for algorithms that produce only data object as output.
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Store zero or more vtkInformation instances.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Multiprocessing communication superclass.