VTK  9.0.1
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  =========================================================================*/
23 #ifndef vtkExtentRCBPartitioner_h
24 #define vtkExtentRCBPartitioner_h
25 
26 #include "vtkCommonExecutionModelModule.h" // For export macro
27 #include "vtkObject.h"
28 #include <cassert> // For assert
29 #include <string> // For std::string
30 #include <vector> // For STL vector
31 
32 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkExtentRCBPartitioner : public vtkObject
33 {
34 public:
35  static vtkExtentRCBPartitioner* New();
37  void PrintSelf(ostream& oss, vtkIndent indent) override;
38 
40 
43  void SetNumberOfPartitions(const int N)
44  {
45  assert("pre: Number of partitions requested must be > 0" && (N >= 0));
46  this->Reset();
47  this->NumberOfPartitions = N;
48  }
50 
52 
57  void SetGlobalExtent(int imin, int imax, int jmin, int jmax, int kmin, int kmax)
58  {
59  this->Reset();
60  this->GlobalExtent[0] = imin;
61  this->GlobalExtent[1] = imax;
62  this->GlobalExtent[2] = jmin;
63  this->GlobalExtent[3] = jmax;
64  this->GlobalExtent[4] = kmin;
65  this->GlobalExtent[5] = kmax;
66  }
67  void SetGlobalExtent(int ext[6])
68  {
69  this->SetGlobalExtent(ext[0], ext[1], ext[2], ext[3], ext[4], ext[5]);
70  }
72 
74 
77  vtkSetMacro(DuplicateNodes, vtkTypeBool);
78  vtkGetMacro(DuplicateNodes, vtkTypeBool);
79  vtkBooleanMacro(DuplicateNodes, vtkTypeBool);
81 
83 
86  vtkSetMacro(NumberOfGhostLayers, int);
87  vtkGetMacro(NumberOfGhostLayers, int);
89 
91 
94  vtkGetMacro(NumExtents, int);
96 
100  void Partition();
101 
105  void GetPartitionExtent(const int idx, int ext[6]);
106 
107 protected:
109  ~vtkExtentRCBPartitioner() override;
110 
112 
116  void Reset()
117  {
118  this->PartitionExtents.clear();
119  this->NumExtents = 0;
120  this->ExtentIsPartitioned = false;
121  }
123 
129  void ExtendGhostLayers(int ext[6]);
130 
132 
137  void GetGhostedExtent(int ext[6], const int minIdx, const int maxIdx)
138  {
139  ext[minIdx] -= this->NumberOfGhostLayers;
140  ext[maxIdx] += this->NumberOfGhostLayers;
141  ext[minIdx] =
142  (ext[minIdx] < this->GlobalExtent[minIdx]) ? this->GlobalExtent[minIdx] : ext[minIdx];
143  ext[maxIdx] =
144  (ext[maxIdx] > this->GlobalExtent[maxIdx]) ? this->GlobalExtent[maxIdx] : ext[maxIdx];
145  }
147 
151  void AcquireDataDescription();
152 
156  void GetExtent(const int idx, int ext[6]);
157 
161  void AddExtent(int ext[6]);
162 
167  void ReplaceExtent(const int idx, int ext[6]);
168 
172  void SplitExtent(int parent[6], int s1[6], int s2[6], int splitDimension);
173 
178  int GetNumberOfTotalExtents();
179 
183  int GetNumberOfNodes(int ext[6]);
184 
188  int GetNumberOfCells(int ext[6]);
189 
193  int GetLongestDimensionLength(int ext[6]);
194 
198  int GetLongestDimension(int ext[6]);
199 
203  void PrintExtent(const std::string& name, int ext[6]);
204 
207  int GlobalExtent[6];
210 
211  vtkTypeBool DuplicateNodes; // indicates whether nodes are duplicated between
212  // partitions, so that they are abutting. This is
213  // set to true by default. If disabled, the resulting
214  // partitions will have gaps.
215 
217 
218  std::vector<int> PartitionExtents;
219 
220 private:
222  void operator=(const vtkExtentRCBPartitioner&) = delete;
223 };
224 
225 #endif /* VTKEXTENTRCBPARTITIONER_H_ */
vtkExtentRCBPartitioner::SetGlobalExtent
void SetGlobalExtent(int imin, int imax, int jmin, int jmax, int kmin, int kmax)
Set/Get the global extent array to be partitioned.
Definition: vtkExtentRCBPartitioner.h:57
vtkExtentRCBPartitioner::NumberOfPartitions
int NumberOfPartitions
Definition: vtkExtentRCBPartitioner.h:208
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkExtentRCBPartitioner::NumExtents
int NumExtents
Definition: vtkExtentRCBPartitioner.h:209
vtkExtentRCBPartitioner::GetGhostedExtent
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...
Definition: vtkExtentRCBPartitioner.h:137
vtkExtentRCBPartitioner::DuplicateNodes
vtkTypeBool DuplicateNodes
Definition: vtkExtentRCBPartitioner.h:211
vtkExtentRCBPartitioner::ExtentIsPartitioned
bool ExtentIsPartitioned
Definition: vtkExtentRCBPartitioner.h:216
vtkExtentRCBPartitioner
Definition: vtkExtentRCBPartitioner.h:32
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkExtentRCBPartitioner::SetNumberOfPartitions
void SetNumberOfPartitions(const int N)
Set/Get the number of requested partitions.
Definition: vtkExtentRCBPartitioner.h:43
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkX3D::name
@ name
Definition: vtkX3D.h:225
vtkObject.h
vtkExtentRCBPartitioner::NumberOfGhostLayers
int NumberOfGhostLayers
Definition: vtkExtentRCBPartitioner.h:205
vtkExtentRCBPartitioner::PartitionExtents
std::vector< int > PartitionExtents
Definition: vtkExtentRCBPartitioner.h:218
vtkX3D::string
@ string
Definition: vtkX3D.h:496
vtkExtentRCBPartitioner::Reset
void Reset()
Resets the partitioner to the initial state, all previous partition extents are cleared.
Definition: vtkExtentRCBPartitioner.h:116
vtkExtentRCBPartitioner::DataDescription
int DataDescription
Definition: vtkExtentRCBPartitioner.h:206
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkExtentRCBPartitioner::SetGlobalExtent
void SetGlobalExtent(int ext[6])
Definition: vtkExtentRCBPartitioner.h:67