VTK
dox/Filters/ParallelMPI/vtkDistributedDataFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkDistributedDataFilter.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 /*----------------------------------------------------------------------------
00016  Copyright (c) Sandia Corporation
00017  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
00018 ----------------------------------------------------------------------------*/
00019 
00091 #ifndef __vtkDistributedDataFilter_h
00092 #define __vtkDistributedDataFilter_h
00093 
00094 #include "vtkFiltersParallelMPIModule.h" // For export macro
00095 #include "vtkDataObjectAlgorithm.h"
00096 
00097 class vtkBSPCuts;
00098 class vtkDataArray;
00099 class vtkDistributedDataFilterSTLCloak;
00100 class vtkFloatArray;
00101 class vtkIdList;
00102 class vtkIdTypeArray;
00103 class vtkIntArray;
00104 class vtkMultiProcessController;
00105 class vtkPKdTree;
00106 class vtkUnstructuredGrid;
00107 
00108 class VTKFILTERSPARALLELMPI_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 //BTX
00174   enum BoundaryModes {
00175     ASSIGN_TO_ONE_REGION=0,
00176     ASSIGN_TO_ALL_INTERSECTING_REGIONS=1,
00177     SPLIT_BOUNDARY_CELLS=2
00178   };
00179 //ETX
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 //BTX
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);
00476   vtkUnstructuredGrid *ExtractCells(vtkIdList **lists, int nlists,
00477                   int deleteCellLists, vtkDataSet *in);
00478   vtkUnstructuredGrid *ExtractZeroCellGrid(vtkDataSet *in);
00480 
00482 
00483   static int GlobalPointIdIsUsed(vtkUnstructuredGrid *grid,
00484                int ptId, vtkDistributedDataFilterSTLCloak *globalToLocal);
00485   static int LocalPointIdIsUsed(vtkUnstructuredGrid *grid, int ptId);
00486   static vtkIdType FindId(vtkIdTypeArray *ids, vtkIdType gid, vtkIdType startLoc);
00488 
00490 
00491   static vtkIdTypeArray *AddPointAndCells(vtkIdType gid,
00492                                        vtkIdType localId,
00493                                        vtkUnstructuredGrid *grid,
00494                                        vtkIdType *gidCells,
00495                                        vtkIdTypeArray *ids);
00497 
00499 
00500   static void AddConstantUnsignedCharPointArray(vtkUnstructuredGrid *grid,
00501                                  const char *arrayName, unsigned char val);
00502   static void AddConstantUnsignedCharCellArray(vtkUnstructuredGrid *grid,
00503                                  const char *arrayName, unsigned char val);
00505 
00507 
00508   static void RemoveRemoteCellsFromList(vtkIdList *cellList,
00509                                         vtkIdType *gidCells,
00510                                         vtkIdType *remoteCells,
00511                                         vtkIdType nRemoteCells);
00513 
00515 
00516   static vtkUnstructuredGrid *MergeGrids(vtkDataSet **sets, int nsets,
00517                                          int deleteDataSets,
00518                                          int useGlobalNodeIds, float pointMergeTolerance,
00519                                          int useGlobalCellIds);
00521 
00522   vtkPKdTree *Kdtree;
00523   vtkMultiProcessController *Controller;
00524 
00525   int NumProcesses;
00526   int MyId;
00527 
00528   int *Target;
00529   int *Source;
00530 
00531   int NumConvexSubRegions;
00532   double *ConvexSubRegionBounds;
00533 
00534   int GhostLevel;
00535 
00536   int RetainKdtree;
00537   int IncludeAllIntersectingCells;
00538   int ClipCells;
00539   int AssignBoundaryCellsToOneRegion;
00540   int AssignBoundaryCellsToAllIntersectingRegions;
00541   int DivideBoundaryCells;
00542 
00543   int Timing;
00544 
00545   int NextProgressStep;
00546   double ProgressIncrement;
00547 
00548   int UseMinimalMemory;
00549 
00550   vtkBSPCuts* UserCuts;
00551 
00552   vtkDistributedDataFilter(const vtkDistributedDataFilter&); // Not implemented
00553   void operator=(const vtkDistributedDataFilter&); // Not implemented
00554 
00555   class vtkInternals;
00556   vtkInternals* Internals;
00557 //ETX
00558 };
00559 #endif