VTK  9.2.6
vtkRedistributeDataSetFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkRedistributeDataSetFilter.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 =========================================================================*/
73 #ifndef vtkRedistributeDataSetFilter_h
74 #define vtkRedistributeDataSetFilter_h
75 
76 #include "vtkDataObjectAlgorithm.h"
77 #include "vtkFiltersParallelDIY2Module.h" // for export macros
78 #include "vtkSmartPointer.h" // for vtkSmartPointer
79 
80 #include <memory> // for std::shared_ptr
81 #include <vector> // for std::vector
82 
83 // clang-format off
84 #include "vtk_diy2.h" // for DIY2 APIs
85 #include VTK_DIY2(diy/assigner.hpp)
86 // clang-format on
87 
89 class vtkBoundingBox;
93 class vtkDataObjectTree;
94 
95 class VTKFILTERSPARALLELDIY2_EXPORT vtkRedistributeDataSetFilter : public vtkDataObjectAlgorithm
96 {
97 public:
100  void PrintSelf(ostream& os, vtkIndent indent) override;
101 
103 
108  vtkGetObjectMacro(Controller, vtkMultiProcessController);
110 
112  {
113  ASSIGN_TO_ONE_REGION = 0,
114  ASSIGN_TO_ALL_INTERSECTING_REGIONS = 1,
115  SPLIT_BOUNDARY_CELLS = 2
116  };
117 
119 
131  vtkSetClampMacro(BoundaryMode, int, ASSIGN_TO_ONE_REGION, SPLIT_BOUNDARY_CELLS);
132  vtkGetMacro(BoundaryMode, int);
133  void SetBoundaryModeToAssignToOneRegion() { this->SetBoundaryMode(ASSIGN_TO_ONE_REGION); }
135  {
136  this->SetBoundaryMode(ASSIGN_TO_ALL_INTERSECTING_REGIONS);
137  }
138  void SetBoundaryModeToSplitBoundaryCells() { this->SetBoundaryMode(SPLIT_BOUNDARY_CELLS); }
140 
142 
147  vtkSetMacro(UseExplicitCuts, bool);
148  vtkGetMacro(UseExplicitCuts, bool);
149  vtkBooleanMacro(UseExplicitCuts, bool);
151 
153 
156  void SetExplicitCuts(const std::vector<vtkBoundingBox>& boxes);
157  const std::vector<vtkBoundingBox>& GetExplicitCuts() const { return this->ExplicitCuts; }
159  void AddExplicitCut(const vtkBoundingBox& bbox);
160  void AddExplicitCut(const double bbox[6]);
164 
166 
171  void SetAssigner(std::shared_ptr<diy::Assigner> assigner);
172  std::shared_ptr<diy::Assigner> GetAssigner();
173  std::shared_ptr<const diy::Assigner> GetAssigner() const;
174 
176 
186  vtkSetMacro(ExpandExplicitCuts, bool);
187  vtkGetMacro(ExpandExplicitCuts, bool);
188  vtkBooleanMacro(ExpandExplicitCuts, bool);
190 
192 
196  const std::vector<vtkBoundingBox>& GetCuts() const { return this->Cuts; }
197 
199 
217  vtkSetClampMacro(NumberOfPartitions, int, 0, VTK_INT_MAX);
218  vtkGetMacro(NumberOfPartitions, int);
220 
222 
235  vtkSetMacro(PreservePartitionsInOutput, bool);
236  vtkGetMacro(PreservePartitionsInOutput, bool);
237  vtkBooleanMacro(PreservePartitionsInOutput, bool);
239 
241 
245  vtkSetMacro(GenerateGlobalCellIds, bool);
246  vtkGetMacro(GenerateGlobalCellIds, bool);
247  vtkBooleanMacro(GenerateGlobalCellIds, bool);
249 
256  std::vector<vtkBoundingBox> ExpandCuts(
257  const std::vector<vtkBoundingBox>& cuts, const vtkBoundingBox& bounds);
258 
260 
267  vtkSetMacro(EnableDebugging, bool);
268  vtkGetMacro(EnableDebugging, bool);
269  vtkBooleanMacro(EnableDebugging, bool);
271 
273 
281  vtkSetMacro(LoadBalanceAcrossAllBlocks, bool);
282  vtkGetMacro(LoadBalanceAcrossAllBlocks, bool);
283  vtkBooleanMacro(LoadBalanceAcrossAllBlocks, bool);
285 
286 protected:
289 
293 
303  virtual std::vector<vtkBoundingBox> GenerateCuts(vtkDataObject* data);
304 
316  vtkDataSet* dataset, const std::vector<vtkBoundingBox>& cuts);
317 
318 private:
320  void operator=(const vtkRedistributeDataSetFilter&) = delete;
321 
322  bool InitializeCuts(vtkDataObjectTree* input);
323  bool Redistribute(vtkPartitionedDataSet* inputDO, vtkPartitionedDataSet* outputPDS,
324  const std::vector<vtkBoundingBox>& cuts, vtkIdType* mb_offset = nullptr);
325  bool RedistributeDataSet(
326  vtkDataSet* inputDS, vtkPartitionedDataSet* outputPDS, const std::vector<vtkBoundingBox>& cuts);
327  vtkSmartPointer<vtkDataSet> ClipDataSet(vtkDataSet* dataset, const vtkBoundingBox& bbox);
328 
329  void MarkGhostCells(vtkPartitionedDataSet* pieces);
330 
331  vtkSmartPointer<vtkPartitionedDataSet> AssignGlobalCellIds(
332  vtkPartitionedDataSet* input, vtkIdType* mb_offset = nullptr);
333  vtkSmartPointer<vtkDataSet> AssignGlobalCellIds(
334  vtkDataSet* input, vtkIdType* mb_offset = nullptr);
335 
336  void MarkValidDimensions(const vtkBoundingBox& gbounds);
337 
338  std::vector<vtkBoundingBox> ExplicitCuts;
339  std::vector<vtkBoundingBox> Cuts;
340  std::shared_ptr<diy::Assigner> Assigner;
341 
342  vtkMultiProcessController* Controller;
343  int BoundaryMode;
344  int NumberOfPartitions;
345  bool PreservePartitionsInOutput;
346  bool GenerateGlobalCellIds;
347  bool UseExplicitCuts;
348  bool ExpandExplicitCuts;
349  bool EnableDebugging;
350  bool ValidDim[3];
351  bool LoadBalanceAcrossAllBlocks;
352 };
353 
354 #endif
Fast, simple class for representing and operating on 3D bounds.
Superclass for algorithms that produce only data object as output.
provides implementation for most abstract methods in the superclass vtkCompositeDataSet
general representation of visualization data
abstract class to specify dataset behavior
Definition: vtkDataSet.h:172
a simple class to control print indentation
Definition: vtkIndent.h:119
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Composite dataset that organizes datasets into blocks.
composite dataset to encapsulates pieces of dataset.
Multiprocessing communication superclass.
composite dataset to encapsulates a dataset consisting of partitions.
redistributes input dataset into requested number of partitions
static vtkRedistributeDataSetFilter * New()
const std::vector< vtkBoundingBox > & GetExplicitCuts() const
Specify the cuts to use when UseExplicitCuts is true.
virtual vtkSmartPointer< vtkPartitionedDataSet > SplitDataSet(vtkDataSet *dataset, const std::vector< vtkBoundingBox > &cuts)
This method is called to split a vtkDataSet into multiple datasets by the vector of vtkBoundingBox pa...
virtual std::vector< vtkBoundingBox > GenerateCuts(vtkDataObject *data)
This method is called to generate the partitions for the input dataset.
const vtkBoundingBox & GetExplicitCut(int index) const
Specify the cuts to use when UseExplicitCuts is true.
void SetBoundaryModeToAssignToAllIntersectingRegions()
Specify how cells on the boundaries are handled.
int RequestDataObject(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
void AddExplicitCut(const double bbox[6])
Specify the cuts to use when UseExplicitCuts is true.
std::vector< vtkBoundingBox > ExpandCuts(const std::vector< vtkBoundingBox > &cuts, const vtkBoundingBox &bounds)
Helper function to expand a collection of bounding boxes to include the bounds specified.
int GetNumberOfExplicitCuts() const
Specify the cuts to use when UseExplicitCuts is true.
void SetController(vtkMultiProcessController *)
Get/Set the controller to use.
void SetExplicitCuts(const std::vector< vtkBoundingBox > &boxes)
Specify the cuts to use when UseExplicitCuts is true.
~vtkRedistributeDataSetFilter() override
std::shared_ptr< diy::Assigner > GetAssigner()
Specify the DIY assigner used for distributing cuts.
void RemoveAllExplicitCuts()
Specify the cuts to use when UseExplicitCuts is true.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
void SetBoundaryModeToAssignToOneRegion()
Specify how cells on the boundaries are handled.
std::shared_ptr< const diy::Assigner > GetAssigner() const
Specify the DIY assigner used for distributing cuts.
void AddExplicitCut(const vtkBoundingBox &bbox)
Specify the cuts to use when UseExplicitCuts is true.
void SetAssigner(std::shared_ptr< diy::Assigner > assigner)
Specify the DIY assigner used for distributing cuts.
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.
void SetBoundaryModeToSplitBoundaryCells()
Specify how cells on the boundaries are handled.
const std::vector< vtkBoundingBox > & GetCuts() const
Returns the cuts used by the most recent RequestData call.
Hold a reference to a vtkObjectBase instance.
@ info
Definition: vtkX3D.h:382
@ port
Definition: vtkX3D.h:453
@ index
Definition: vtkX3D.h:252
@ data
Definition: vtkX3D.h:321
int vtkIdType
Definition: vtkType.h:332
#define VTK_INT_MAX
Definition: vtkType.h:155