VTK  9.3.20240221
vtkExtentRCBPartitioner.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
12 #ifndef vtkExtentRCBPartitioner_h
13 #define vtkExtentRCBPartitioner_h
14 
15 #include "vtkCommonExecutionModelModule.h" // For export macro
16 #include "vtkObject.h"
17 #include <cassert> // For assert
18 #include <string> // For std::string
19 #include <vector> // For STL vector
20 
21 VTK_ABI_NAMESPACE_BEGIN
22 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkExtentRCBPartitioner : public vtkObject
23 {
24 public:
27  void PrintSelf(ostream& oss, vtkIndent indent) override;
28 
30 
34  {
35  assert("pre: Number of partitions requested must be > 0" && (N >= 0));
36  this->Reset();
37  this->NumberOfPartitions = N;
38  }
40 
42 
47  void SetGlobalExtent(int imin, int imax, int jmin, int jmax, int kmin, int kmax)
48  {
49  this->Reset();
50  this->GlobalExtent[0] = imin;
51  this->GlobalExtent[1] = imax;
52  this->GlobalExtent[2] = jmin;
53  this->GlobalExtent[3] = jmax;
54  this->GlobalExtent[4] = kmin;
55  this->GlobalExtent[5] = kmax;
56  }
57  void SetGlobalExtent(int ext[6])
58  {
59  this->SetGlobalExtent(ext[0], ext[1], ext[2], ext[3], ext[4], ext[5]);
60  }
62 
64 
67  vtkSetMacro(DuplicateNodes, vtkTypeBool);
68  vtkGetMacro(DuplicateNodes, vtkTypeBool);
69  vtkBooleanMacro(DuplicateNodes, vtkTypeBool);
71 
73 
76  vtkSetMacro(NumberOfGhostLayers, int);
77  vtkGetMacro(NumberOfGhostLayers, int);
79 
81 
84  vtkGetMacro(NumExtents, int);
86 
90  void Partition();
91 
95  void GetPartitionExtent(int idx, int ext[6]);
96 
97 protected:
100 
102 
106  void Reset()
107  {
108  this->PartitionExtents.clear();
109  this->NumExtents = 0;
110  this->ExtentIsPartitioned = false;
111  }
113 
119  void ExtendGhostLayers(int ext[6]);
120 
122 
127  void GetGhostedExtent(int ext[6], int minIdx, int maxIdx)
128  {
129  ext[minIdx] -= this->NumberOfGhostLayers;
130  ext[maxIdx] += this->NumberOfGhostLayers;
131  ext[minIdx] =
132  (ext[minIdx] < this->GlobalExtent[minIdx]) ? this->GlobalExtent[minIdx] : ext[minIdx];
133  ext[maxIdx] =
134  (ext[maxIdx] > this->GlobalExtent[maxIdx]) ? this->GlobalExtent[maxIdx] : ext[maxIdx];
135  }
137 
142 
146  void GetExtent(int idx, int ext[6]);
147 
151  void AddExtent(int ext[6]);
152 
157  void ReplaceExtent(int idx, int ext[6]);
158 
162  void SplitExtent(int parent[6], int s1[6], int s2[6], int splitDimension);
163 
169 
173  int GetNumberOfNodes(int ext[6]);
174 
178  int GetNumberOfCells(int ext[6]);
179 
183  int GetLongestDimensionLength(int ext[6]);
184 
188  int GetLongestDimension(int ext[6]);
189 
193  void PrintExtent(const std::string& name, int ext[6]);
194 
197  int GlobalExtent[6];
200 
201  vtkTypeBool DuplicateNodes; // indicates whether nodes are duplicated between
202  // partitions, so that they are abutting. This is
203  // set to true by default. If disabled, the resulting
204  // partitions will have gaps.
205 
207 
208  std::vector<int> PartitionExtents;
209 
210 private:
212  void operator=(const vtkExtentRCBPartitioner&) = delete;
213 };
214 
215 VTK_ABI_NAMESPACE_END
216 #endif /* VTKEXTENTRCBPARTITIONER_H_ */
This method partitions a global extent to N partitions where N is a user supplied parameter.
int GetNumberOfCells(int ext[6])
Computes the total number of cells for the given structured grid extent.
void PrintSelf(ostream &oss, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void GetGhostedExtent(int ext[6], int minIdx, int maxIdx)
Givent an extent and the min/max of the dimension we are looking at, this method will produce a ghost...
void GetPartitionExtent(int idx, int ext[6])
Returns the extent of the partition corresponding to the given ID.
int GetNumberOfTotalExtents()
Returns the total number of extents.
~vtkExtentRCBPartitioner() override
void PrintExtent(const std::string &name, int ext[6])
A convenience method for debugging purposes.
void SetGlobalExtent(int imin, int imax, int jmin, int jmax, int kmin, int kmax)
Set/Get the global extent array to be partitioned.
static vtkExtentRCBPartitioner * New()
void SplitExtent(int parent[6], int s1[6], int s2[6], int splitDimension)
Splits the extent along the given dimension.
int GetNumberOfNodes(int ext[6])
Computes the total number of nodes for the given structured grid extent.
void Partition()
Partitions the extent.
std::vector< int > PartitionExtents
void Reset()
Resets the partitioner to the initial state, all previous partition extents are cleared.
void SetNumberOfPartitions(int N)
Set/Get the number of requested partitions.
int GetLongestDimensionLength(int ext[6])
Returns the length of the longest dimension.
void AddExtent(int ext[6])
Adds the extent to the end of the list of partitioned extents.
void SetGlobalExtent(int ext[6])
Set/Get the global extent array to be partitioned.
void AcquireDataDescription()
Gets the structured data-description based on the givenn global extent.
void ReplaceExtent(int idx, int ext[6])
Replaces the extent at the position indicated by idx with the provided extent.
void GetExtent(int idx, int ext[6])
Returns the extent at the position corresponding to idx.
int GetLongestDimension(int ext[6])
Returns the longest edge.
void ExtendGhostLayers(int ext[6])
Given an extent, this method will create ghost layers on each side of the boundary in each dimension.
a simple class to control print indentation
Definition: vtkIndent.h:108
abstract base class for most VTK objects
Definition: vtkObject.h:161
@ name
Definition: vtkX3D.h:219
@ string
Definition: vtkX3D.h:490
int vtkTypeBool
Definition: vtkABI.h:64