VTK  9.2.5
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  =========================================================================*/
24 #ifndef vtkExtentRCBPartitioner_h
25 #define vtkExtentRCBPartitioner_h
26 
27 #include "vtkCommonExecutionModelModule.h" // For export macro
28 #include "vtkObject.h"
29 #include <cassert> // For assert
30 #include <string> // For std::string
31 #include <vector> // For STL vector
32 
33 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkExtentRCBPartitioner : public vtkObject
34 {
35 public:
38  void PrintSelf(ostream& oss, vtkIndent indent) override;
39 
41 
44  void SetNumberOfPartitions(const int N)
45  {
46  assert("pre: Number of partitions requested must be > 0" && (N >= 0));
47  this->Reset();
48  this->NumberOfPartitions = N;
49  }
51 
53 
58  void SetGlobalExtent(int imin, int imax, int jmin, int jmax, int kmin, int kmax)
59  {
60  this->Reset();
61  this->GlobalExtent[0] = imin;
62  this->GlobalExtent[1] = imax;
63  this->GlobalExtent[2] = jmin;
64  this->GlobalExtent[3] = jmax;
65  this->GlobalExtent[4] = kmin;
66  this->GlobalExtent[5] = kmax;
67  }
68  void SetGlobalExtent(int ext[6])
69  {
70  this->SetGlobalExtent(ext[0], ext[1], ext[2], ext[3], ext[4], ext[5]);
71  }
73 
75 
78  vtkSetMacro(DuplicateNodes, vtkTypeBool);
79  vtkGetMacro(DuplicateNodes, vtkTypeBool);
80  vtkBooleanMacro(DuplicateNodes, vtkTypeBool);
82 
84 
87  vtkSetMacro(NumberOfGhostLayers, int);
88  vtkGetMacro(NumberOfGhostLayers, int);
90 
92 
95  vtkGetMacro(NumExtents, int);
97 
101  void Partition();
102 
106  void GetPartitionExtent(const int idx, int ext[6]);
107 
108 protected:
111 
113 
117  void Reset()
118  {
119  this->PartitionExtents.clear();
120  this->NumExtents = 0;
121  this->ExtentIsPartitioned = false;
122  }
124 
130  void ExtendGhostLayers(int ext[6]);
131 
133 
138  void GetGhostedExtent(int ext[6], const int minIdx, const int maxIdx)
139  {
140  ext[minIdx] -= this->NumberOfGhostLayers;
141  ext[maxIdx] += this->NumberOfGhostLayers;
142  ext[minIdx] =
143  (ext[minIdx] < this->GlobalExtent[minIdx]) ? this->GlobalExtent[minIdx] : ext[minIdx];
144  ext[maxIdx] =
145  (ext[maxIdx] > this->GlobalExtent[maxIdx]) ? this->GlobalExtent[maxIdx] : ext[maxIdx];
146  }
148 
153 
157  void GetExtent(const int idx, int ext[6]);
158 
162  void AddExtent(int ext[6]);
163 
168  void ReplaceExtent(const int idx, int ext[6]);
169 
173  void SplitExtent(int parent[6], int s1[6], int s2[6], int splitDimension);
174 
180 
184  int GetNumberOfNodes(int ext[6]);
185 
189  int GetNumberOfCells(int ext[6]);
190 
194  int GetLongestDimensionLength(int ext[6]);
195 
199  int GetLongestDimension(int ext[6]);
200 
204  void PrintExtent(const std::string& name, int ext[6]);
205 
208  int GlobalExtent[6];
211 
212  vtkTypeBool DuplicateNodes; // indicates whether nodes are duplicated between
213  // partitions, so that they are abutting. This is
214  // set to true by default. If disabled, the resulting
215  // partitions will have gaps.
216 
218 
219  std::vector<int> PartitionExtents;
220 
221 private:
223  void operator=(const vtkExtentRCBPartitioner&) = delete;
224 };
225 
226 #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:119
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