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 
92 #ifndef vtkDistributedDataFilter_h
93 #define vtkDistributedDataFilter_h
94 
95 #include "vtkFiltersParallelMPIModule.h" // For export macro
96 #include "vtkDataObjectAlgorithm.h"
97 
98 class vtkBSPCuts;
99 class vtkDataArray;
100 class vtkDistributedDataFilterSTLCloak;
101 class vtkFloatArray;
102 class vtkIdList;
103 class vtkIdTypeArray;
104 class vtkIntArray;
106 class vtkPKdTree;
107 class vtkUnstructuredGrid;
108 
109 class VTKFILTERSPARALLELMPI_EXPORT vtkDistributedDataFilter: public vtkDataObjectAlgorithm
110 {
111  vtkTypeMacro(vtkDistributedDataFilter,
113 
114 public:
115  void PrintSelf(ostream& os, vtkIndent indent) override;
116 
117  static vtkDistributedDataFilter *New();
118 
120 
123  void SetController(vtkMultiProcessController *c);
124  vtkGetObjectMacro(Controller, vtkMultiProcessController);
126 
137  vtkPKdTree *GetKdtree();
138 
156  vtkBooleanMacro(RetainKdtree, int);
157  vtkGetMacro(RetainKdtree, int);
158  vtkSetMacro(RetainKdtree, int);
159 
171  vtkBooleanMacro(IncludeAllIntersectingCells, int);
172  vtkGetMacro(IncludeAllIntersectingCells, int);
173  vtkSetMacro(IncludeAllIntersectingCells, int);
174 
181  vtkBooleanMacro(ClipCells, int);
182  vtkGetMacro(ClipCells, int);
183  vtkSetMacro(ClipCells, int);
184 
186  ASSIGN_TO_ONE_REGION=0,
187  ASSIGN_TO_ALL_INTERSECTING_REGIONS=1,
188  SPLIT_BOUNDARY_CELLS=2
189  };
190 
192 
195  void SetBoundaryMode(int mode);
197  { this->SetBoundaryMode(vtkDistributedDataFilter::ASSIGN_TO_ONE_REGION); }
199  { this->SetBoundaryMode(
201  }
203  { this->SetBoundaryMode(vtkDistributedDataFilter::SPLIT_BOUNDARY_CELLS); }
204  int GetBoundaryMode();
206 
211 
222  vtkBooleanMacro(UseMinimalMemory, int);
223  vtkGetMacro(UseMinimalMemory, int);
224  vtkSetMacro(UseMinimalMemory, int);
225 
230  vtkGetMacro(MinimumGhostLevel, int)
231  vtkSetMacro(MinimumGhostLevel, int)
232 
233 
237  vtkBooleanMacro(Timing, int);
238  vtkSetMacro(Timing, int);
239  vtkGetMacro(Timing, int);
240 
253  vtkBSPCuts* GetCuts() {return this->UserCuts;}
254  void SetCuts(vtkBSPCuts* cuts);
255 
265  void SetUserRegionAssignments(const int *map, int numRegions);
266 
267 protected:
270 
278  void AssignBoundaryCellsToOneRegionOn();
279  void AssignBoundaryCellsToOneRegionOff();
280  void SetAssignBoundaryCellsToOneRegion(int val);
281 
291  void AssignBoundaryCellsToAllIntersectingRegionsOn();
292  void AssignBoundaryCellsToAllIntersectingRegionsOff();
293  void SetAssignBoundaryCellsToAllIntersectingRegions(int val);
294 
303  void DivideBoundaryCellsOn();
304  void DivideBoundaryCellsOff();
305  void SetDivideBoundaryCells(int val);
306 
314  vtkInformationVector *) override;
315  void SingleProcessExecute(vtkDataSet *input, vtkUnstructuredGrid *output);
317  vtkInformationVector *) override;
318  virtual int FillInputPortInformation(int port, vtkInformation *info) override;
319 
325  virtual int RequestDataObject(vtkInformation*,
327  vtkInformationVector*) override;
328 
332  int RequestDataInternal(vtkDataSet* input, vtkUnstructuredGrid* output);
333 
334 private:
335 
336  enum{
337  DeleteNo = 0,
338  DeleteYes = 1
339  };
340 
341  enum{
342  DuplicateCellsNo = 0,
343  DuplicateCellsYes = 1
344  };
345 
346  enum{
347  GhostCellsNo = 0,
348  GhostCellsYes = 1
349  };
350 
351  enum{
352  UnsetGhostLevel = 99
353  };
354 
358  int PartitionDataAndAssignToProcesses(vtkDataSet *set);
359 
363  vtkUnstructuredGrid *RedistributeDataSet(vtkDataSet *set, vtkDataSet *input);
364 
368  int ClipGridCells(vtkUnstructuredGrid *grid);
369 
373  vtkUnstructuredGrid * AcquireGhostCells(vtkUnstructuredGrid *grid);
374 
378  void ComputeMyRegionBounds();
379 
383  int CheckFieldArrayTypes(vtkDataSet *set);
384 
390  vtkDataSet *TestFixTooFewInputFiles(vtkDataSet *input);
391 
395  vtkUnstructuredGrid *MPIRedistribute(vtkDataSet *in, vtkDataSet *input);
396 
400  vtkIdList **GetCellIdsForProcess(int proc, int *nlists);
401 
406  void SetUpPairWiseExchange();
407 
409 
412  void FreeIntArrays(vtkIdTypeArray **ar);
413  static void FreeIdLists(vtkIdList**lists, int nlists);
414  static vtkIdType GetIdListSize(vtkIdList**lists, int nlists);
416 
418 
421  vtkIdTypeArray *ExchangeCounts(vtkIdType myCount, int tag);
422  vtkIdTypeArray *ExchangeCountsLean(vtkIdType myCount, int tag);
423  vtkIdTypeArray *ExchangeCountsFast(vtkIdType myCount, int tag);
425 
427 
430  vtkIdTypeArray **ExchangeIdArrays(vtkIdTypeArray **arIn,
431  int deleteSendArrays, int tag);
432  vtkIdTypeArray **ExchangeIdArraysLean(vtkIdTypeArray **arIn,
433  int deleteSendArrays, int tag);
434  vtkIdTypeArray **ExchangeIdArraysFast(vtkIdTypeArray **arIn,
435  int deleteSendArrays, int tag);
437 
439 
442  vtkFloatArray **ExchangeFloatArrays(vtkFloatArray **myArray,
443  int deleteSendArrays, int tag);
444  vtkFloatArray **ExchangeFloatArraysLean(vtkFloatArray **myArray,
445  int deleteSendArrays, int tag);
446  vtkFloatArray **ExchangeFloatArraysFast(vtkFloatArray **myArray,
447  int deleteSendArrays, int tag);
449 
451 
454  vtkUnstructuredGrid *ExchangeMergeSubGrids(vtkIdList **cellIds, int deleteCellIds,
455  vtkDataSet *myGrid, int deleteMyGrid,
456  int filterOutDuplicateCells, int ghostCellFlag, int tag);
457  vtkUnstructuredGrid *ExchangeMergeSubGrids(vtkIdList ***cellIds, int *numLists,
458  int deleteCellIds,
459  vtkDataSet *myGrid, int deleteMyGrid,
460  int filterOutDuplicateCells, int ghostCellFlag, int tag);
461  vtkUnstructuredGrid *ExchangeMergeSubGridsLean(
462  vtkIdList ***cellIds, int *numLists,
463  int deleteCellIds,
464  vtkDataSet *myGrid, int deleteMyGrid,
465  int filterOutDuplicateCells, int ghostCellFlag, int tag);
466  vtkUnstructuredGrid *ExchangeMergeSubGridsFast(
467  vtkIdList ***cellIds, int *numLists,
468  int deleteCellIds,
469  vtkDataSet *myGrid, int deleteMyGrid,
470  int filterOutDuplicateCells, int ghostCellFlag, int tag);
472 
473 
475 
478  char* MarshallDataSet(vtkUnstructuredGrid* extractedGrid, vtkIdType& size);
479  vtkUnstructuredGrid* UnMarshallDataSet(char* buf, vtkIdType size);
481 
483 
486  void ClipCellsToSpatialRegion(vtkUnstructuredGrid *grid);
487 #if 0
488  void ClipWithVtkClipDataSet(vtkUnstructuredGrid *grid, double *bounds,
489  vtkUnstructuredGrid **outside, vtkUnstructuredGrid **inside);
490 #endif
491 
492 
493  void ClipWithBoxClipDataSet(vtkUnstructuredGrid *grid, double *bounds,
494  vtkUnstructuredGrid **outside, vtkUnstructuredGrid **inside);
495 
497 
503  vtkIdTypeArray *GetGlobalNodeIdArray(vtkDataSet *set);
504  vtkIdType *GetGlobalNodeIds(vtkDataSet *set);
505  vtkIdTypeArray *GetGlobalElementIdArray(vtkDataSet *set);
506  vtkIdType *GetGlobalElementIds(vtkDataSet *set);
507  int AssignGlobalNodeIds(vtkUnstructuredGrid *grid);
508  int AssignGlobalElementIds(vtkDataSet *in);
509  vtkIdTypeArray **FindGlobalPointIds(vtkFloatArray **ptarray,
510  vtkIdTypeArray *ids, vtkUnstructuredGrid *grid, vtkIdType &numUniqueMissingPoints);
512 
516  vtkIdTypeArray **MakeProcessLists(vtkIdTypeArray **pointIds,
517  vtkDistributedDataFilterSTLCloak *procs);
518 
522  vtkIdList **BuildRequestedGrids( vtkIdTypeArray **globalPtIds,
523  vtkUnstructuredGrid *grid,
524  vtkDistributedDataFilterSTLCloak *ptIdMap);
525 
527 
530  int InMySpatialRegion(float x, float y, float z);
531  int InMySpatialRegion(double x, double y, double z);
532  int StrictlyInsideMyBounds(float x, float y, float z);
533  int StrictlyInsideMyBounds(double x, double y, double z);
535 
537 
540  vtkIdTypeArray **GetGhostPointIds(int ghostLevel, vtkUnstructuredGrid *grid,
541  int AddCellsIAlreadyHave);
542  vtkUnstructuredGrid *AddGhostCellsUniqueCellAssignment(
543  vtkUnstructuredGrid *myGrid,
544  vtkDistributedDataFilterSTLCloak *globalToLocalMap);
545  vtkUnstructuredGrid *AddGhostCellsDuplicateCellAssignment(
546  vtkUnstructuredGrid *myGrid,
547  vtkDistributedDataFilterSTLCloak *globalToLocalMap);
548  vtkUnstructuredGrid *SetMergeGhostGrid(
549  vtkUnstructuredGrid *ghostCellGrid,
550  vtkUnstructuredGrid *incomingGhostCells,
551  int ghostLevel, vtkDistributedDataFilterSTLCloak *idMap);
553 
555 
558  vtkUnstructuredGrid *ExtractCells(vtkIdList *list,
559  int deleteCellLists, vtkDataSet *in);
560  vtkUnstructuredGrid *ExtractCells(vtkIdList **lists, int nlists,
561  int deleteCellLists, vtkDataSet *in);
562  vtkUnstructuredGrid *ExtractZeroCellGrid(vtkDataSet *in);
564 
566 
569  static int GlobalPointIdIsUsed(vtkUnstructuredGrid *grid,
570  int ptId, vtkDistributedDataFilterSTLCloak *globalToLocal);
571  static int LocalPointIdIsUsed(vtkUnstructuredGrid *grid, int ptId);
572  static vtkIdType FindId(vtkIdTypeArray *ids, vtkIdType gid, vtkIdType startLoc);
574 
578  static vtkIdTypeArray *AddPointAndCells(vtkIdType gid,
579  vtkIdType localId,
580  vtkUnstructuredGrid *grid,
581  vtkIdType *gidCells,
582  vtkIdTypeArray *ids);
583 
585 
588  static void AddConstantUnsignedCharPointArray(vtkUnstructuredGrid *grid,
589  const char *arrayName, unsigned char val);
590  static void AddConstantUnsignedCharCellArray(vtkUnstructuredGrid *grid,
591  const char *arrayName, unsigned char val);
593 
597  static void RemoveRemoteCellsFromList(vtkIdList *cellList,
598  vtkIdType *gidCells,
599  vtkIdType *remoteCells,
600  vtkIdType nRemoteCells);
601 
605  static vtkUnstructuredGrid *MergeGrids(vtkDataSet **sets, int nsets,
606  int deleteDataSets,
607  int useGlobalNodeIds, float pointMergeTolerance,
608  int useGlobalCellIds);
609 
610  vtkPKdTree *Kdtree;
611  vtkMultiProcessController *Controller;
612 
613  int NumProcesses;
614  int MyId;
615 
616  int *Target;
617  int *Source;
618 
619  int NumConvexSubRegions;
620  double *ConvexSubRegionBounds;
621 
622  // User-adjustable minimum number of ghost levels.
623  int MinimumGhostLevel;
624 
625  // Actual number of ghost levels used during execution.
626  int GhostLevel;
627 
628  int RetainKdtree;
629  int IncludeAllIntersectingCells;
630  int ClipCells;
631  int AssignBoundaryCellsToOneRegion;
632  int AssignBoundaryCellsToAllIntersectingRegions;
633  int DivideBoundaryCells;
634 
635  int Timing;
636 
637  int NextProgressStep;
638  double ProgressIncrement;
639 
640  int UseMinimalMemory;
641 
642  vtkBSPCuts* UserCuts;
643 
645  void operator=(const vtkDistributedDataFilter&) = delete;
646 
647  class vtkInternals;
648  vtkInternals* Internals;
649 
650 };
651 #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:62
static vtkDataObjectAlgorithm * New()
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
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:45
a simple class to control print indentation
Definition: vtkIndent.h:39
list of point or cell ids
Definition: vtkIdList.h:36
dataset represents arbitrary combinations of all possible cell types
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
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.