VTK  9.7.1
vtkRedistributeDataSetFilter.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
51 #ifndef vtkRedistributeDataSetFilter_h
52 #define vtkRedistributeDataSetFilter_h
53 
54 #include "vtkDataObjectAlgorithm.h"
55 #include "vtkFiltersParallelDIY2Module.h" // for export macros
56 #include "vtkPartitioningStrategy.h" // for PartitionInformation
57 #include "vtkSmartPointer.h" // for vtkSmartPointer
58 
59 #include <memory> // for std::shared_ptr
60 #include <vector> // for std::vector
61 
62 // clang-format off
63 #include "vtk_diy2.h" // for DIY2 APIs
64 #include VTK_DIY2(diy/assigner.hpp)
65 // clang-format on
66 
67 VTK_ABI_NAMESPACE_BEGIN
69 class vtkBoundingBox;
73 class vtkDataObjectTree;
74 class VTKFILTERSPARALLELDIY2_EXPORT vtkRedistributeDataSetFilter : public vtkDataObjectAlgorithm
75 {
76 public:
79  void PrintSelf(ostream& os, vtkIndent indent) override;
80 
84  vtkMTimeType GetMTime() override;
85 
87 
91  void SetController(vtkMultiProcessController*);
92  vtkGetObjectMacro(Controller, vtkMultiProcessController);
94 
96  {
97  ASSIGN_TO_ONE_REGION = 0,
98  ASSIGN_TO_ALL_INTERSECTING_REGIONS = 1,
99  SPLIT_BOUNDARY_CELLS = 2
100  };
101 
103 
115  virtual void SetBoundaryMode(int mode);
116  virtual int GetBoundaryModeMinValue() { return ASSIGN_TO_ONE_REGION; }
117  virtual int GetBoundaryModeMaxValue() { return SPLIT_BOUNDARY_CELLS; }
118 
119  vtkGetMacro(BoundaryMode, int);
120  void SetBoundaryModeToAssignToOneRegion() { this->SetBoundaryMode(ASSIGN_TO_ONE_REGION); }
122  {
123  this->SetBoundaryMode(ASSIGN_TO_ALL_INTERSECTING_REGIONS);
124  }
125  void SetBoundaryModeToSplitBoundaryCells() { this->SetBoundaryMode(SPLIT_BOUNDARY_CELLS); }
127 
129 
134  void SetUseExplicitCuts(bool);
135  bool GetUseExplicitCuts() const;
136  vtkBooleanMacro(UseExplicitCuts, bool);
138 
140 
143  void SetExplicitCuts(const std::vector<vtkBoundingBox>& boxes);
144  const std::vector<vtkBoundingBox>& GetExplicitCuts() const;
145  void RemoveAllExplicitCuts();
146  void AddExplicitCut(const vtkBoundingBox& bbox);
147  void AddExplicitCut(const double bbox[6]);
148  int GetNumberOfExplicitCuts() const;
149  const vtkBoundingBox& GetExplicitCut(int index) const;
151 
153 
158  void SetAssigner(std::shared_ptr<diy::Assigner> assigner);
159  std::shared_ptr<diy::Assigner> GetAssigner();
160  std::shared_ptr<const diy::Assigner> GetAssigner() const;
161 
163 
173  void SetExpandExplicitCuts(bool);
174  bool GetExpandExplicitCuts() const;
175  vtkBooleanMacro(ExpandExplicitCuts, bool);
177 
179 
183  const std::vector<vtkBoundingBox>& GetCuts() const;
185 
187 
201  void SetNumberOfPartitions(vtkIdType);
202  vtkIdType GetNumberOfPartitions() const;
204 
206 
219  vtkSetMacro(PreservePartitionsInOutput, bool);
220  vtkGetMacro(PreservePartitionsInOutput, bool);
221  vtkBooleanMacro(PreservePartitionsInOutput, bool);
223 
225 
229  vtkSetMacro(GenerateGlobalCellIds, bool);
230  vtkGetMacro(GenerateGlobalCellIds, bool);
231  vtkBooleanMacro(GenerateGlobalCellIds, bool);
233 
235 
242  vtkSetMacro(EnableDebugging, bool);
243  vtkGetMacro(EnableDebugging, bool);
244  vtkBooleanMacro(EnableDebugging, bool);
246 
248 
256  void SetLoadBalanceAcrossAllBlocks(bool);
257  bool GetLoadBalanceAcrossAllBlocks();
258  vtkBooleanMacro(LoadBalanceAcrossAllBlocks, bool);
260 
262 
265  vtkPartitioningStrategy* GetStrategy();
266  void SetStrategy(vtkPartitioningStrategy*);
268 
269 protected:
271  ~vtkRedistributeDataSetFilter() override;
272 
273  int FillInputPortInformation(int port, vtkInformation* info) override;
276 
277  /*
278  * A method with this signature used to exist. With the refactoring of this filter to accept
279  * different partitioning strategies, this method no longer had any meaning in the generic
280  * sense.
281  *
282  * If you inherited this filter and overrid this method, please implement a new partitioning
283  * strategy instead.
284  */
285  // virtual vtkSmartPointer<vtkPartitionedDataSet> SplitDataSet(
286  // vtkDataSet* dataset, const std::vector<vtkBoundingBox>& cuts);
287 
288 private:
290  void operator=(const vtkRedistributeDataSetFilter&) = delete;
291 
301  virtual vtkSmartPointer<vtkPartitionedDataSet> SplitDataSet(
303 
304  bool Redistribute(vtkPartitionedDataSetCollection* inputCollection,
305  vtkPartitionedDataSetCollection* outputCollection,
306  const std::vector<vtkPartitioningStrategy::PartitionInformation>& info,
307  bool preserve_input_hierarchy);
308 
309  bool RedistributePTD(vtkPartitionedDataSet*, vtkPartitionedDataSet*,
310  const std::vector<vtkPartitioningStrategy::PartitionInformation>&, unsigned int*, vtkIdType*);
311 
312  bool RedistributeDataSet(vtkDataSet* inputDS, vtkPartitionedDataSet* outputPDS,
314  vtkSmartPointer<vtkDataSet> ClipDataSet(vtkDataSet* dataset, const vtkBoundingBox& bbox);
315 
316  void MarkGhostCells(vtkPartitionedDataSet* pieces);
317 
318  vtkSmartPointer<vtkPartitionedDataSet> AssignGlobalCellIds(
319  vtkPartitionedDataSet* input, vtkIdType* mb_offset = nullptr);
320  vtkSmartPointer<vtkDataSet> AssignGlobalCellIds(
321  vtkDataSet* input, vtkIdType* mb_offset = nullptr);
322 
323  void MarkValidDimensions(const vtkBoundingBox& gbounds);
324 
325  std::shared_ptr<diy::Assigner> Assigner;
326 
327  vtkMultiProcessController* Controller;
328  int BoundaryMode;
329  bool PreservePartitionsInOutput;
330  bool GenerateGlobalCellIds;
331  bool EnableDebugging;
332  bool ValidDim[3];
333 
335 };
336 
337 VTK_ABI_NAMESPACE_END
338 #endif
virtual int RequestDataObject(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
composite dataset to encapsulates a dataset consisting of partitions.
provides implementation for most abstract methods in the superclass vtkCompositeDataSet ...
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
static vtkDataObjectAlgorithm * New()
void SetBoundaryModeToSplitBoundaryCells()
Specify how cells on the boundaries are handled.
int vtkIdType
Definition: vtkType.h:363
virtual int GetBoundaryModeMaxValue()
Specify how cells on the boundaries are handled.
a simple class to control print indentation
Definition: vtkIndent.h:28
void SetBoundaryModeToAssignToOneRegion()
Specify how cells on the boundaries are handled.
composite dataset to encapsulates pieces of dataset.
virtual vtkMTimeType GetMTime()
Return this object's modified time.
A strategy interface for partitioning meshes.
Encapsulation structure for describing the result of a partitioning calculation.
virtual int GetBoundaryModeMinValue()
Specify how cells on the boundaries are handled.
Superclass for algorithms that produce only data object as output.
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Composite dataset that organizes datasets into blocks.
Store zero or more vtkInformation instances.
void SetBoundaryModeToAssignToAllIntersectingRegions()
Specify how cells on the boundaries are handled.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
redistributes input dataset into requested number of partitions
Fast, simple class for representing and operating on 3D bounds.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Composite dataset that groups datasets as a collection.
Multiprocessing communication superclass.