Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkDistributedDataFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkDistributedDataFilter.h,v $
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 
00059 #ifndef __vtkDistributedDataFilter_h
00060 #define __vtkDistributedDataFilter_h
00061 
00062 #include "vtkDataSetToUnstructuredGridFilter.h"
00063 
00064 class vtkUnstructuredGrid;
00065 class vtkPKdTree;
00066 class vtkMultiProcessController;
00067 class vtkTimerLog;
00068 class vtkDataArray;
00069 class vtkIntArray;
00070 class vtkFloatArray;
00071 class vtkIdList;
00072 class vtkUnstructuredGrid;
00073 class vtkModelMetadata;
00074 class vtkDistributedDataFilterSTLCloak;
00075 
00076 class VTK_PARALLEL_EXPORT vtkDistributedDataFilter: public vtkDataSetToUnstructuredGridFilter
00077 {
00078   vtkTypeRevisionMacro(vtkDistributedDataFilter, 
00079     vtkDataSetToUnstructuredGridFilter);
00080 
00081 public:
00082   void PrintSelf(ostream& os, vtkIndent indent);
00083   void PrintTiming(ostream& os, vtkIndent indent);
00084 
00085   static vtkDistributedDataFilter *New();
00086 
00088 
00089   void SetController(vtkMultiProcessController *c);
00090   vtkGetObjectMacro(Controller, vtkMultiProcessController);
00092 
00109   vtkSetStringMacro(GlobalNodeIdArrayName);
00110 
00117   vtkSetStringMacro(GlobalElementIdArrayName);
00118   
00133   vtkBooleanMacro(RetainKdtree, int);
00134   vtkGetMacro(RetainKdtree, int);
00135   vtkSetMacro(RetainKdtree, int);
00136 
00142   vtkPKdTree *GetKdtree();
00143 
00153   vtkBooleanMacro(IncludeAllIntersectingCells, int);
00154   vtkGetMacro(IncludeAllIntersectingCells, int);
00155   vtkSetMacro(IncludeAllIntersectingCells, int);
00156 
00161   vtkBooleanMacro(ClipCells, int);
00162   vtkGetMacro(ClipCells, int);
00163   vtkSetMacro(ClipCells, int);
00164 
00165 //BTX
00166   enum BoundaryModes {
00167     ASSIGN_TO_ONE_REGION=0,
00168     ASSIGN_TO_ALL_INTERSECTING_REGIONS=1,
00169     SPLIT_BOUNDARY_CELLS=2
00170   };
00171 //ETX
00172 
00174 
00175   void SetBoundaryMode(int mode);
00176   void SetBoundaryModeToAssignToOneRegion()
00177     { this->SetBoundaryMode(vtkDistributedDataFilter::ASSIGN_TO_ONE_REGION); }
00178   void SetBoundaryModeToAssignToAllIntersectingRegions()
00179     { this->SetBoundaryMode(
00180       vtkDistributedDataFilter::ASSIGN_TO_ALL_INTERSECTING_REGIONS);
00181     }
00182   void SetBoundaryModeToSplitBoundaryCells()
00183     { this->SetBoundaryMode(vtkDistributedDataFilter::SPLIT_BOUNDARY_CELLS); }
00184   int GetBoundaryMode();
00186   
00188   virtual void ComputeInputUpdateExtents( vtkDataObject *output );
00189 
00197   vtkBooleanMacro(UseMinimalMemory, int);
00198   vtkGetMacro(UseMinimalMemory, int);
00199   vtkSetMacro(UseMinimalMemory, int);
00200 
00201 
00204   vtkBooleanMacro(Timing, int);
00205   vtkSetMacro(Timing, int);
00206   vtkGetMacro(Timing, int);
00207 
00209   unsigned long GetMTime();
00210 
00211 protected:
00212   vtkDistributedDataFilter();
00213   ~vtkDistributedDataFilter();
00214 
00220   void AssignBoundaryCellsToOneRegionOn();
00221   void AssignBoundaryCellsToOneRegionOff();
00222   void SetAssignBoundaryCellsToOneRegion(int val);
00223 
00231   void AssignBoundaryCellsToAllIntersectingRegionsOn();
00232   void AssignBoundaryCellsToAllIntersectingRegionsOff();
00233   void SetAssignBoundaryCellsToAllIntersectingRegions(int val);
00234 
00241   void DivideBoundaryCellsOn();
00242   void DivideBoundaryCellsOff();
00243   void SetDivideBoundaryCells(int val);
00244 
00249   void Execute();
00250   void SingleProcessExecute();
00251   void ExecuteInformation();
00252 
00253 private:
00254 
00255 //BTX
00256   enum{
00257       DeleteNo = 0,
00258       DeleteYes = 1
00259       };
00260 
00261   enum{
00262       DuplicateCellsNo = 0,
00263       DuplicateCellsYes = 1
00264       };
00265 
00266   enum{
00267       GhostCellsNo = 0,
00268       GhostCellsYes = 1
00269       };
00270 
00271   enum{
00272       UnsetGhostLevel = 99
00273       };
00274 //ETX
00275   int PartitionDataAndAssignToProcesses(vtkDataSet *set);
00276   vtkUnstructuredGrid *RedistributeDataSet(vtkDataSet *set);
00277   int ClipGridCells(vtkUnstructuredGrid *grid);
00278   vtkUnstructuredGrid * AcquireGhostCells(vtkUnstructuredGrid *grid);
00279 
00280   void ComputeMyRegionBounds();
00281 
00282   int CheckFieldArrayTypes(vtkDataSet *set);
00283 
00284   vtkDataSet *TestFixTooFewInputFiles();
00285 
00286   vtkUnstructuredGrid *MPIRedistribute(vtkDataSet *in);
00287 
00288   vtkIdList **GetCellIdsForProcess(int proc, int *nlists);
00289 
00290   void SetUpPairWiseExchange();
00291   void FreeIntArrays(vtkIntArray **ar);
00292   vtkIntArray *ExchangeCounts(int myCount, int tag);
00293   vtkIntArray **ExchangeIntArrays(vtkIntArray **arIn, 
00294                                   int deleteSendArrays, int tag);
00295   vtkFloatArray **ExchangeFloatArrays(vtkFloatArray **myArray, 
00296                                       int deleteSendArrays, int tag);
00297   vtkUnstructuredGrid *ExchangeMergeSubGrids(vtkIdList **cellIds, int deleteCellIds,
00298                          vtkDataSet *myGrid, int deleteMyGrid,
00299                          int filterOutDuplicateCells, int ghostCellFlag, int tag);
00300   vtkUnstructuredGrid *ExchangeMergeSubGrids(vtkIdList ***cellIds, int *numLists, 
00301                    int deleteCellIds,
00302                    vtkDataSet *myGrid, int deleteMyGrid,
00303                    int filterOutDuplicateCells, int ghostCellFlag, int tag);
00304   vtkIntArray *ExchangeCountsLean(int myCount, int tag);
00305   vtkIntArray **ExchangeIntArraysLean(vtkIntArray **arIn, 
00306                                   int deleteSendArrays, int tag);
00307   vtkFloatArray **ExchangeFloatArraysLean(vtkFloatArray **myArray, 
00308                                       int deleteSendArrays, int tag);
00309   vtkUnstructuredGrid *ExchangeMergeSubGridsLean(
00310                    vtkIdList ***cellIds, int *numLists, 
00311                    int deleteCellIds,
00312                    vtkDataSet *myGrid, int deleteMyGrid,
00313                    int filterOutDuplicateCells, int ghostCellFlag, int tag);
00314   vtkIntArray *ExchangeCountsFast(int myCount, int tag);
00315   vtkIntArray **ExchangeIntArraysFast(vtkIntArray **arIn, 
00316                                   int deleteSendArrays, int tag);
00317   vtkFloatArray **ExchangeFloatArraysFast(vtkFloatArray **myArray, 
00318                                       int deleteSendArrays, int tag);
00319   vtkUnstructuredGrid *ExchangeMergeSubGridsFast(
00320                    vtkIdList ***cellIds, int *numLists, 
00321                    int deleteCellIds,
00322                    vtkDataSet *myGrid, int deleteMyGrid,
00323                    int filterOutDuplicateCells, int ghostCellFlag, int tag);
00324 
00325 
00326   char *MarshallDataSet(vtkUnstructuredGrid *extractedGrid, int &size);
00327   vtkUnstructuredGrid *UnMarshallDataSet(char *buf, int size);
00328 
00329   void ClipCellsToSpatialRegion(vtkUnstructuredGrid *grid);
00330 
00331   void ClipWithVtkClipDataSet(vtkUnstructuredGrid *grid, double *bounds,
00332            vtkUnstructuredGrid **outside, vtkUnstructuredGrid **inside);
00333   void ClipWithBoxClipDataSet(vtkUnstructuredGrid *grid, double *bounds,
00334            vtkUnstructuredGrid **outside, vtkUnstructuredGrid **inside);
00335 
00336   const char *GetGlobalNodeIdArrayName(vtkDataSet *set);
00337   int *GetGlobalNodeIds(vtkDataSet *set);
00338 
00339   const char *GetGlobalElementIdArrayName(vtkDataSet *set);
00340   int *GetGlobalElementIds(vtkDataSet *set);
00341 
00342   int AssignGlobalNodeIds(vtkUnstructuredGrid *grid);
00343   int AssignGlobalElementIds(vtkDataSet *in);
00344 
00345   vtkIntArray **FindGlobalPointIds(vtkFloatArray **ptarray,
00346     vtkIntArray *ids, vtkUnstructuredGrid *grid, int &numUniqueMissingPoints);
00347 
00348   int InMySpatialRegion(float x, float y, float z);
00349   int InMySpatialRegion(double x, double y, double z);
00350   int StrictlyInsideMyBounds(float x, float y, float z);
00351   int StrictlyInsideMyBounds(double x, double y, double z);
00352 
00353   vtkIntArray **GetGhostPointIds(int ghostLevel, vtkUnstructuredGrid *grid,
00354                                  int AddCellsIAlreadyHave);
00355   vtkIntArray **MakeProcessLists(vtkIntArray **pointIds,
00356                                  vtkDistributedDataFilterSTLCloak *procs);
00357   vtkUnstructuredGrid *AddGhostCellsUniqueCellAssignment(
00358                            vtkUnstructuredGrid *myGrid,
00359                            vtkDistributedDataFilterSTLCloak *globalToLocalMap);
00360   vtkUnstructuredGrid *AddGhostCellsDuplicateCellAssignment(
00361                            vtkUnstructuredGrid *myGrid,
00362                            vtkDistributedDataFilterSTLCloak *globalToLocalMap);
00363   vtkIdList **BuildRequestedGrids( vtkIntArray **globalPtIds,
00364                         vtkUnstructuredGrid *grid,
00365                         vtkDistributedDataFilterSTLCloak *ptIdMap);
00366   vtkUnstructuredGrid *SetMergeGhostGrid(
00367                        vtkUnstructuredGrid *ghostCellGrid,
00368                        vtkUnstructuredGrid *incomingGhostCells,
00369                        int ghostLevel, vtkDistributedDataFilterSTLCloak *idMap);
00370 
00371   vtkUnstructuredGrid *ExtractCells(vtkIdList *list, 
00372                   int deleteCellLists, vtkDataSet *in, vtkModelMetadata *mmd);
00373   vtkUnstructuredGrid *ExtractCells(vtkIdList **lists, int nlists, 
00374                   int deleteCellLists, vtkDataSet *in, vtkModelMetadata *mmd);
00375 
00376   void AddMetadata(vtkUnstructuredGrid *grid, vtkModelMetadata *mmd);
00377 
00378   static int GlobalPointIdIsUsed(vtkUnstructuredGrid *grid,
00379                int ptId, vtkDistributedDataFilterSTLCloak *globalToLocal);
00380 
00381   static int LocalPointIdIsUsed(vtkUnstructuredGrid *grid, int ptId);
00382   static int FindId(vtkIntArray *ids, int gid, int startLoc);
00383   static vtkIntArray *AddPointAndCells(int gid, int localId, 
00384                         vtkUnstructuredGrid *grid, int *gidCells, vtkIntArray *ids);
00385 
00386   static void AddConstantUnsignedCharPointArray(vtkUnstructuredGrid *grid, 
00387                                  const char *arrayName, unsigned char val);
00388   static void AddConstantUnsignedCharCellArray(vtkUnstructuredGrid *grid, 
00389                                  const char *arrayName, unsigned char val);
00390   static void RemoveRemoteCellsFromList(vtkIdList *cellList, int *gidCells, 
00391                                  int *remoteCells, int nRemoteCells);
00392   static vtkUnstructuredGrid *MergeGrids(vtkDataSet **sets, int nsets,
00393          int deleteDataSets,
00394          const char *globalNodeIdArrayName, float pointMergeTolerance,
00395          const char *globalCellIdArrayName);
00396 
00397   static void FreeIdLists(vtkIdList**lists, int nlists);
00398   static vtkIdType GetIdListSize(vtkIdList**lists, int nlists);
00399   static int HasMetadata(vtkDataSet *s);
00400 
00401   vtkPKdTree *Kdtree;
00402   vtkMultiProcessController *Controller;
00403 
00404   int NumProcesses;
00405   int MyId;
00406 
00407   int *Target;
00408   int *Source;
00409 
00410   int NumConvexSubRegions;
00411   double *ConvexSubRegionBounds;
00412 
00413   int GhostLevel;
00414 
00415   char *GlobalElementIdArrayName;
00416   char *GlobalNodeIdArrayName; 
00417 
00418   int RetainKdtree;
00419   int IncludeAllIntersectingCells;
00420   int ClipCells;
00421   int AssignBoundaryCellsToOneRegion;
00422   int AssignBoundaryCellsToAllIntersectingRegions;
00423   int DivideBoundaryCells;
00424 
00425   int Timing;
00426 
00427   vtkTimerLog *TimerLog;
00428 
00429   int UseMinimalMemory;
00430 
00431   vtkDistributedDataFilter(const vtkDistributedDataFilter&); // Not implemented
00432   void operator=(const vtkDistributedDataFilter&); // Not implemented
00433 };
00434 #endif