VTK: Filters/ParallelDIY2/vtkRedistributeDataSetFilter.h Source File

| VTK 9.3.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
61 #ifndef vtkRedistributeDataSetFilter_h
62 #define vtkRedistributeDataSetFilter_h
63
64 #include "vtkDataObjectAlgorithm.h"
65 #include "vtkFiltersParallelDIY2Module.h" // for export macros
66 #include "vtkSmartPointer.h" // for vtkSmartPointer
67
68 #include <memory> // for std::shared_ptr
69 #include <vector> // for std::vector
70
71 // clang-format off
72 #include "vtk_diy2.h" // for DIY2 APIs
73 #include VTK_DIY2(diy/assigner.hpp)
74 // clang-format on
75
76 VTK_ABI_NAMESPACE_BEGIN
77 class vtkMultiProcessController;
78 class vtkBoundingBox;
79 class vtkPartitionedDataSet;
80 class vtkMultiBlockDataSet;
81 class vtkMultiPieceDataSet;
82 class vtkDataObjectTree;
83
84 class VTKFILTERSPARALLELDIY2_EXPORT vtkRedistributeDataSetFilter : public vtkDataObjectAlgorithm
85 {
86 public:
87 static vtkRedistributeDataSetFilter* New();
88 vtkTypeMacro(vtkRedistributeDataSetFilter, vtkDataObjectAlgorithm);
89 void PrintSelf(ostream& os, vtkIndent indent) override;
90
92
96 void SetController(vtkMultiProcessController*);
97 vtkGetObjectMacro(Controller, vtkMultiProcessController);
99
100 enum BoundaryModes
101 {
102 ASSIGN_TO_ONE_REGION = 0,
103 ASSIGN_TO_ALL_INTERSECTING_REGIONS = 1,
104 SPLIT_BOUNDARY_CELLS = 2
105 };
106
108
120 vtkSetClampMacro(BoundaryMode, int, ASSIGN_TO_ONE_REGION, SPLIT_BOUNDARY_CELLS);
121 vtkGetMacro(BoundaryMode, int);
122 void SetBoundaryModeToAssignToOneRegion() { this->SetBoundaryMode(ASSIGN_TO_ONE_REGION); }
123 void SetBoundaryModeToAssignToAllIntersectingRegions()
124 {
125 this->SetBoundaryMode(ASSIGN_TO_ALL_INTERSECTING_REGIONS);
126 }
127 void SetBoundaryModeToSplitBoundaryCells() { this->SetBoundaryMode(SPLIT_BOUNDARY_CELLS); }
129
131
136 vtkSetMacro(UseExplicitCuts, bool);
137 vtkGetMacro(UseExplicitCuts, bool);
138 vtkBooleanMacro(UseExplicitCuts, bool);
140
142
145 void SetExplicitCuts(const std::vector<vtkBoundingBox>& boxes);
146 const std::vector<vtkBoundingBox>& GetExplicitCuts() const { return this->ExplicitCuts; }
147 void RemoveAllExplicitCuts();
148 void AddExplicitCut(const vtkBoundingBox& bbox);
149 void AddExplicitCut(const double bbox[6]);
150 int GetNumberOfExplicitCuts() const;
151 const vtkBoundingBox& GetExplicitCut(int index) const;
153
155
160 void SetAssigner(std::shared_ptr<diy::Assigner> assigner);
161 std::shared_ptr<diy::Assigner> GetAssigner();
162 std::shared_ptr<const diy::Assigner> GetAssigner() const;
163
165
175 vtkSetMacro(ExpandExplicitCuts, bool);
176 vtkGetMacro(ExpandExplicitCuts, bool);
177 vtkBooleanMacro(ExpandExplicitCuts, bool);
179
181
185 const std::vector<vtkBoundingBox>& GetCuts() const { return this->Cuts; }
186
188
206 vtkSetClampMacro(NumberOfPartitions, int, 0, VTK_INT_MAX);
207 vtkGetMacro(NumberOfPartitions, int);
209
211
224 vtkSetMacro(PreservePartitionsInOutput, bool);
225 vtkGetMacro(PreservePartitionsInOutput, bool);
226 vtkBooleanMacro(PreservePartitionsInOutput, bool);
228
230
234 vtkSetMacro(GenerateGlobalCellIds, bool);
235 vtkGetMacro(GenerateGlobalCellIds, bool);
236 vtkBooleanMacro(GenerateGlobalCellIds, bool);
238
245 std::vector<vtkBoundingBox> ExpandCuts(
246 const std::vector<vtkBoundingBox>& cuts, const vtkBoundingBox& bounds);
247
249
256 vtkSetMacro(EnableDebugging, bool);
257 vtkGetMacro(EnableDebugging, bool);
258 vtkBooleanMacro(EnableDebugging, bool);
260
262
270 vtkSetMacro(LoadBalanceAcrossAllBlocks, bool);
271 vtkGetMacro(LoadBalanceAcrossAllBlocks, bool);
272 vtkBooleanMacro(LoadBalanceAcrossAllBlocks, bool);
274
275 protected:
276 vtkRedistributeDataSetFilter();
277 ~vtkRedistributeDataSetFilter() override;
278
279 int FillInputPortInformation(int port, vtkInformation* info) override;
280 int RequestDataObject(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
281 int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
282
292 virtual std::vector<vtkBoundingBox> GenerateCuts(vtkDataObject* data);
293
304 virtual vtkSmartPointer<vtkPartitionedDataSet> SplitDataSet(
305 vtkDataSet* dataset, const std::vector<vtkBoundingBox>& cuts);
306
307 private:
308 vtkRedistributeDataSetFilter(const vtkRedistributeDataSetFilter&) = delete;
309 void operator=(const vtkRedistributeDataSetFilter&) = delete;
310
311 bool InitializeCuts(vtkDataObjectTree* input);
312 bool Redistribute(vtkPartitionedDataSet* inputDO, vtkPartitionedDataSet* outputPDS,
313 const std::vector<vtkBoundingBox>& cuts, vtkIdType* mb_offset = nullptr);
314 bool RedistributeDataSet(
315 vtkDataSet* inputDS, vtkPartitionedDataSet* outputPDS, const std::vector<vtkBoundingBox>& cuts);
316 vtkSmartPointer<vtkDataSet> ClipDataSet(vtkDataSet* dataset, const vtkBoundingBox& bbox);
317
318 void MarkGhostCells(vtkPartitionedDataSet* pieces);
319
320 vtkSmartPointer<vtkPartitionedDataSet> AssignGlobalCellIds(
321 vtkPartitionedDataSet* input, vtkIdType* mb_offset = nullptr);
322 vtkSmartPointer<vtkDataSet> AssignGlobalCellIds(
323 vtkDataSet* input, vtkIdType* mb_offset = nullptr);
324
325 void MarkValidDimensions(const vtkBoundingBox& gbounds);
326
327 std::vector<vtkBoundingBox> ExplicitCuts;
328 std::vector<vtkBoundingBox> Cuts;
329 std::shared_ptr<diy::Assigner> Assigner;
330
331 vtkMultiProcessController* Controller;
332 int BoundaryMode;
333 int NumberOfPartitions;
334 bool PreservePartitionsInOutput;
335 bool GenerateGlobalCellIds;
336 bool UseExplicitCuts;
337 bool ExpandExplicitCuts;
338 bool EnableDebugging;
339 bool ValidDim[3];
340 bool LoadBalanceAcrossAllBlocks;
341 };
342
343 VTK_ABI_NAMESPACE_END
344 #endif
vtkBoundingBox
Fast, simple class for representing and operating on 3D bounds.
Definition: vtkBoundingBox.h:38
vtkDataObjectAlgorithm
Superclass for algorithms that produce only data object as output.
Definition: vtkDataObjectAlgorithm.h:33
vtkDataObjectTree
provides implementation for most abstract methods in the superclass vtkCompositeDataSet
Definition: vtkDataObjectTree.h:49
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:64
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:40
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:72
vtkMultiBlockDataSet
Composite dataset that organizes datasets into blocks.
Definition: vtkMultiBlockDataSet.h:50
vtkMultiPieceDataSet
composite dataset to encapsulates pieces of dataset.
Definition: vtkMultiPieceDataSet.h:33
vtkMultiProcessController
Multiprocessing communication superclass.
Definition: vtkMultiProcessController.h:72
vtkPartitionedDataSet
composite dataset to encapsulates a dataset consisting of partitions.
Definition: vtkPartitionedDataSet.h:39
vtkRedistributeDataSetFilter
redistributes input dataset into requested number of partitions
Definition: vtkRedistributeDataSetFilter.h:85
vtkRedistributeDataSetFilter::New
static vtkRedistributeDataSetFilter * New()
vtkRedistributeDataSetFilter::GetExplicitCuts
const std::vector< vtkBoundingBox > & GetExplicitCuts() const
Specify the cuts to use when UseExplicitCuts is true.
Definition: vtkRedistributeDataSetFilter.h:146
vtkRedistributeDataSetFilter::SplitDataSet
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...
vtkRedistributeDataSetFilter::GenerateCuts
virtual std::vector< vtkBoundingBox > GenerateCuts(vtkDataObject *data)
This method is called to generate the partitions for the input dataset.
vtkRedistributeDataSetFilter::GetExplicitCut
const vtkBoundingBox & GetExplicitCut(int index) const
Specify the cuts to use when UseExplicitCuts is true.
vtkRedistributeDataSetFilter::SetBoundaryModeToAssignToAllIntersectingRegions
void SetBoundaryModeToAssignToAllIntersectingRegions()
Specify how cells on the boundaries are handled.
Definition: vtkRedistributeDataSetFilter.h:123
vtkRedistributeDataSetFilter::RequestDataObject
int RequestDataObject(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkRedistributeDataSetFilter::AddExplicitCut
void AddExplicitCut(const double bbox[6])
Specify the cuts to use when UseExplicitCuts is true.
vtkRedistributeDataSetFilter::ExpandCuts
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.
vtkRedistributeDataSetFilter::GetNumberOfExplicitCuts
int GetNumberOfExplicitCuts() const
Specify the cuts to use when UseExplicitCuts is true.
vtkRedistributeDataSetFilter::SetController
void SetController(vtkMultiProcessController *)
Get/Set the controller to use.
vtkRedistributeDataSetFilter::SetExplicitCuts
void SetExplicitCuts(const std::vector< vtkBoundingBox > &boxes)
Specify the cuts to use when UseExplicitCuts is true.
vtkRedistributeDataSetFilter::~vtkRedistributeDataSetFilter
~vtkRedistributeDataSetFilter() override
vtkRedistributeDataSetFilter::GetAssigner
std::shared_ptr< diy::Assigner > GetAssigner()
Specify the DIY assigner used for distributing cuts.
vtkRedistributeDataSetFilter::RemoveAllExplicitCuts
void RemoveAllExplicitCuts()
Specify the cuts to use when UseExplicitCuts is true.
vtkRedistributeDataSetFilter::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
vtkRedistributeDataSetFilter::BoundaryModes
BoundaryModes
Definition: vtkRedistributeDataSetFilter.h:101
vtkRedistributeDataSetFilter::SetBoundaryModeToAssignToOneRegion
void SetBoundaryModeToAssignToOneRegion()
Specify how cells on the boundaries are handled.
Definition: vtkRedistributeDataSetFilter.h:122
vtkRedistributeDataSetFilter::GetAssigner
std::shared_ptr< const diy::Assigner > GetAssigner() const
Specify the DIY assigner used for distributing cuts.
vtkRedistributeDataSetFilter::AddExplicitCut
void AddExplicitCut(const vtkBoundingBox &bbox)
Specify the cuts to use when UseExplicitCuts is true.
vtkRedistributeDataSetFilter::SetAssigner
void SetAssigner(std::shared_ptr< diy::Assigner > assigner)
Specify the DIY assigner used for distributing cuts.
vtkRedistributeDataSetFilter::vtkRedistributeDataSetFilter
vtkRedistributeDataSetFilter()
vtkRedistributeDataSetFilter::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkRedistributeDataSetFilter::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkRedistributeDataSetFilter::SetBoundaryModeToSplitBoundaryCells
void SetBoundaryModeToSplitBoundaryCells()
Specify how cells on the boundaries are handled.
Definition: vtkRedistributeDataSetFilter.h:127
vtkRedistributeDataSetFilter::GetCuts
const std::vector< vtkBoundingBox > & GetCuts() const
Returns the cuts used by the most recent RequestData call.
Definition: vtkRedistributeDataSetFilter.h:185
vtkSmartPointer
Hold a reference to a vtkObjectBase instance.
Definition: vtkSmartPointer.h:41
vtkX3D::info
@ info
Definition: vtkX3D.h:376
vtkX3D::port
@ port
Definition: vtkX3D.h:447
vtkX3D::index
@ index
Definition: vtkX3D.h:246
vtkX3D::data
@ data
Definition: vtkX3D.h:315
vtkDataObjectAlgorithm.h
vtkSmartPointer.h
vtkIdType
int vtkIdType
Definition: vtkType.h:315
VTK_INT_MAX
#define VTK_INT_MAX
Definition: vtkType.h:144