VTK  9.3.20240424
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 vtkSetClampMacro(BoundaryMode, int, ASSIGN_TO_ONE_REGION, SPLIT_BOUNDARY_CELLS);
116 vtkGetMacro(BoundaryMode, int);
117 void SetBoundaryModeToAssignToOneRegion() { this->SetBoundaryMode(ASSIGN_TO_ONE_REGION); }
119 {
120 this->SetBoundaryMode(ASSIGN_TO_ALL_INTERSECTING_REGIONS);
121 }
122 void SetBoundaryModeToSplitBoundaryCells() { this->SetBoundaryMode(SPLIT_BOUNDARY_CELLS); }
124
126
132 bool GetUseExplicitCuts() const;
133 vtkBooleanMacro(UseExplicitCuts, bool);
135
137
140 void SetExplicitCuts(const std::vector<vtkBoundingBox>& boxes);
141 const std::vector<vtkBoundingBox>& GetExplicitCuts() const;
144 void AddExplicitCut(const double bbox[6]);
146 const vtkBoundingBox& GetExplicitCut(int index) const;
148
150
155 void SetAssigner(std::shared_ptr<diy::Assigner> assigner);
156 std::shared_ptr<diy::Assigner> GetAssigner();
157 std::shared_ptr<const diy::Assigner> GetAssigner() const;
158
160
172 vtkBooleanMacro(ExpandExplicitCuts, bool);
174
176
180 const std::vector<vtkBoundingBox>& GetCuts() const;
182
184
201
203
216 vtkSetMacro(PreservePartitionsInOutput, bool);
217 vtkGetMacro(PreservePartitionsInOutput, bool);
218 vtkBooleanMacro(PreservePartitionsInOutput, bool);
220
222
226 vtkSetMacro(GenerateGlobalCellIds, bool);
227 vtkGetMacro(GenerateGlobalCellIds, bool);
228 vtkBooleanMacro(GenerateGlobalCellIds, bool);
230
232
239 vtkSetMacro(EnableDebugging, bool);
240 vtkGetMacro(EnableDebugging, bool);
241 vtkBooleanMacro(EnableDebugging, bool);
243
245
255 vtkBooleanMacro(LoadBalanceAcrossAllBlocks, bool);
257
259
265
266protected:
269
270 int FillInputPortInformation(int port, vtkInformation* info) override;
273
274 /*
275 * A method with this signature used to exist. With the refactoring of this filter to accept
276 * different partitioning strategies, this method no longer had any meaning in the generic
277 * sense.
278 *
279 * If you inherited this filter and overrid this method, please implement a new partitioning
280 * strategy instead.
281 */
282 // virtual vtkSmartPointer<vtkPartitionedDataSet> SplitDataSet(
283 // vtkDataSet* dataset, const std::vector<vtkBoundingBox>& cuts);
284
285private:
287 void operator=(const vtkRedistributeDataSetFilter&) = delete;
288
298 virtual vtkSmartPointer<vtkPartitionedDataSet> SplitDataSet(
300
301 bool Redistribute(vtkPartitionedDataSetCollection* inputCollection,
302 vtkPartitionedDataSetCollection* outputCollection,
303 const std::vector<vtkPartitioningStrategy::PartitionInformation>& info,
304 bool preserve_input_hierarchy);
305
306 bool RedistributePTD(vtkPartitionedDataSet*, vtkPartitionedDataSet*,
307 const std::vector<vtkPartitioningStrategy::PartitionInformation>&, unsigned int*, vtkIdType*);
308
309 bool RedistributeDataSet(vtkDataSet* inputDS, vtkPartitionedDataSet* outputPDS,
311 vtkSmartPointer<vtkDataSet> ClipDataSet(vtkDataSet* dataset, const vtkBoundingBox& bbox);
312
313 void MarkGhostCells(vtkPartitionedDataSet* pieces);
314
315 vtkSmartPointer<vtkPartitionedDataSet> AssignGlobalCellIds(
316 vtkPartitionedDataSet* input, vtkIdType* mb_offset = nullptr);
317 vtkSmartPointer<vtkDataSet> AssignGlobalCellIds(
318 vtkDataSet* input, vtkIdType* mb_offset = nullptr);
319
320 void MarkValidDimensions(const vtkBoundingBox& gbounds);
321
322 std::shared_ptr<diy::Assigner> Assigner;
323
324 vtkMultiProcessController* Controller;
325 int BoundaryMode;
326 bool PreservePartitionsInOutput;
327 bool GenerateGlobalCellIds;
328 bool EnableDebugging;
329 bool ValidDim[3];
330
332};
333
334VTK_ABI_NAMESPACE_END
335#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.
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
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.
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:315
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270