VTK  9.1.20211115
vtkExtentRCBPartitioner.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkExtentRCBPartitioner.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14  =========================================================================*/
21 #ifndef vtkExtentRCBPartitioner_h
22 #define vtkExtentRCBPartitioner_h
23 
24 #include "vtkCommonExecutionModelModule.h" // For export macro
25 #include "vtkObject.h"
26 #include <cassert> // For assert
27 #include <string> // For std::string
28 #include <vector> // For STL vector
29 
30 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkExtentRCBPartitioner : public vtkObject
31 {
32 public:
35  void PrintSelf(ostream& oss, vtkIndent indent) override;
36 
38 
41  void SetNumberOfPartitions(const int N)
42  {
43  assert("pre: Number of partitions requested must be > 0" && (N >= 0));
44  this->Reset();
45  this->NumberOfPartitions = N;
46  }
48 
50 
55  void SetGlobalExtent(int imin, int imax, int jmin, int jmax, int kmin, int kmax)
56  {
57  this->Reset();
58  this->GlobalExtent[0] = imin;
59  this->GlobalExtent[1] = imax;
60  this->GlobalExtent[2] = jmin;
61  this->GlobalExtent[3] = jmax;
62  this->GlobalExtent[4] = kmin;
63  this->GlobalExtent[5] = kmax;
64  }
65  void SetGlobalExtent(int ext[6])
66  {
67  this->SetGlobalExtent(ext[0], ext[1], ext[2], ext[3], ext[4], ext[5]);
68  }
70 
72 
75  vtkSetMacro(DuplicateNodes, vtkTypeBool);
76  vtkGetMacro(DuplicateNodes, vtkTypeBool);
77  vtkBooleanMacro(DuplicateNodes, vtkTypeBool);
79 
81 
84  vtkSetMacro(NumberOfGhostLayers, int);
85  vtkGetMacro(NumberOfGhostLayers, int);
87 
89 
92  vtkGetMacro(NumExtents, int);
94 
98  void Partition();
99 
103  void GetPartitionExtent(const int idx, int ext[6]);
104 
105 protected:
108 
110 
114  void Reset()
115  {
116  this->PartitionExtents.clear();
117  this->NumExtents = 0;
118  this->ExtentIsPartitioned = false;
119  }
121 
127  void ExtendGhostLayers(int ext[6]);
128 
130 
135  void GetGhostedExtent(int ext[6], const int minIdx, const int maxIdx)
136  {
137  ext[minIdx] -= this->NumberOfGhostLayers;
138  ext[maxIdx] += this->NumberOfGhostLayers;
139  ext[minIdx] =
140  (ext[minIdx] < this->GlobalExtent[minIdx]) ? this->GlobalExtent[minIdx] : ext[minIdx];
141  ext[maxIdx] =
142  (ext[maxIdx] > this->GlobalExtent[maxIdx]) ? this->GlobalExtent[maxIdx] : ext[maxIdx];
143  }
145 
150 
154  void GetExtent(const int idx, int ext[6]);
155 
159  void AddExtent(int ext[6]);
160 
165  void ReplaceExtent(const int idx, int ext[6]);
166 
170  void SplitExtent(int parent[6], int s1[6], int s2[6], int splitDimension);
171 
177 
181  int GetNumberOfNodes(int ext[6]);
182 
186  int GetNumberOfCells(int ext[6]);
187 
191  int GetLongestDimensionLength(int ext[6]);
192 
196  int GetLongestDimension(int ext[6]);
197 
201  void PrintExtent(const std::string& name, int ext[6]);
202 
205  int GlobalExtent[6];
208 
209  vtkTypeBool DuplicateNodes; // indicates whether nodes are duplicated between
210  // partitions, so that they are abutting. This is
211  // set to true by default. If disabled, the resulting
212  // partitions will have gaps.
213 
215 
216  std::vector<int> PartitionExtents;
217 
218 private:
220  void operator=(const vtkExtentRCBPartitioner&) = delete;
221 };
222 
223 #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 GetExtent(const int idx, int ext[6])
Returns the extent at the position corresponding to idx.
void ReplaceExtent(const int idx, int ext[6])
Replaces the extent at the position indicated by idx with the provided extent.
int GetNumberOfTotalExtents()
Returns the total number of extents.
void SetNumberOfPartitions(const int N)
Set/Get the number of requested partitions.
~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.
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 GetPartitionExtent(const int idx, int ext[6])
Returns the extent of the partition corresponding to the given ID.
void AcquireDataDescription()
Gets the structured data-description based on the givenn global extent.
void GetGhostedExtent(int ext[6], const int minIdx, const int maxIdx)
Givent an extent and the min/max of the dimension we are looking at, this method will produce a ghost...
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:113
abstract base class for most VTK objects
Definition: vtkObject.h:82
@ name
Definition: vtkX3D.h:225
@ string
Definition: vtkX3D.h:496
int vtkTypeBool
Definition: vtkABI.h:69