VTK  9.5.20251103
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
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
67VTK_ABI_NAMESPACE_BEGIN
69class vtkBoundingBox;
74class VTKFILTERSPARALLELDIY2_EXPORT vtkRedistributeDataSetFilter : public vtkDataObjectAlgorithm
75{
76public:
79 void PrintSelf(ostream& os, vtkIndent indent) override;
80
85
87
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
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;
147 void AddExplicitCut(const double bbox[6]);
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
175 vtkBooleanMacro(ExpandExplicitCuts, bool);
177
179
183 const std::vector<vtkBoundingBox>& GetCuts() const;
185
187
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
258 vtkBooleanMacro(LoadBalanceAcrossAllBlocks, bool);
260
262
268
269protected:
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
288private:
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
337VTK_ABI_NAMESPACE_END
338#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
abstract class to specify dataset behavior
Definition vtkDataSet.h:166
a simple class to control print indentation
Definition vtkIndent.h:108
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 that groups datasets as a collection.
composite dataset to encapsulates a dataset consisting of partitions.
A strategy interface for partitioning meshes.
redistributes input dataset into requested number of partitions
static vtkRedistributeDataSetFilter * New()
void SetBoundaryModeToAssignToAllIntersectingRegions()
Specify how cells on the boundaries are handled.
const vtkBoundingBox & GetExplicitCut(int index) const
Specify the cuts to use when UseExplicitCuts is true.
int RequestDataObject(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
void SetUseExplicitCuts(bool)
Specify whether to compute the load balancing automatically or use explicitly provided cuts.
void AddExplicitCut(const double bbox[6])
Specify the cuts to use when UseExplicitCuts is true.
const std::vector< vtkBoundingBox > & GetExplicitCuts() const
Specify the cuts to use when UseExplicitCuts is true.
vtkIdType GetNumberOfPartitions() const
Specify the number of partitions to split the input dataset into.
bool GetExpandExplicitCuts() const
Specify the DIY assigner used for distributing cuts.
void SetNumberOfPartitions(vtkIdType)
Specify the number of partitions to split the input dataset into.
int GetNumberOfExplicitCuts() const
Specify the cuts to use when UseExplicitCuts is true.
virtual int GetBoundaryModeMaxValue()
Specify how cells on the boundaries are handled.
void SetController(vtkMultiProcessController *)
Get/Set the controller to use.
bool GetLoadBalanceAcrossAllBlocks()
When UseExplicitCuts is false, and input is a vtkPartitionedDataSetCollection, set this to true to ge...
void SetExplicitCuts(const std::vector< vtkBoundingBox > &boxes)
Specify the cuts to use when UseExplicitCuts is true.
~vtkRedistributeDataSetFilter() override
virtual int GetBoundaryModeMinValue()
Specify how cells on the boundaries are handled.
void SetExpandExplicitCuts(bool)
When using explicit cuts, it possible that the bounding box defined by all the cuts is smaller than t...
void RemoveAllExplicitCuts()
Specify the cuts to use when UseExplicitCuts is true.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
const std::vector< vtkBoundingBox > & GetCuts() const
Returns the cuts used by the most recent RequestData call.
vtkPartitioningStrategy * GetStrategy()
Setter/Getter for Strategy.
vtkMTimeType GetMTime() override
Necessary to override this in order to take into account modifications to strategy.
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.
bool GetUseExplicitCuts() const
Specify whether to compute the load balancing automatically or use explicitly provided cuts.
void AddExplicitCut(const vtkBoundingBox &bbox)
Specify the cuts to use when UseExplicitCuts is true.
void SetLoadBalanceAcrossAllBlocks(bool)
When UseExplicitCuts is false, and input is a vtkPartitionedDataSetCollection, set this to true to ge...
void SetAssigner(std::shared_ptr< diy::Assigner > assigner)
Specify the DIY assigner used for distributing cuts.
virtual void SetBoundaryMode(int mode)
Specify how cells on the boundaries are handled.
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.
std::shared_ptr< diy::Assigner > GetAssigner()
Specify the DIY assigner used for distributing cuts.
void SetStrategy(vtkPartitioningStrategy *)
Setter/Getter for Strategy.
Hold a reference to a vtkObjectBase instance.
Encapsulation structure for describing the result of a partitioning calculation.
int vtkIdType
Definition vtkType.h:367
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:322