VTK
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  =========================================================================*/
26 #ifndef vtkExtentRCBPartitioner_h
27 #define vtkExtentRCBPartitioner_h
28 
29 #include "vtkCommonExecutionModelModule.h" // For export macro
30 #include "vtkObject.h"
31 #include <vector> // For STL vector
32 #include <cassert> // For assert
33 #include <string> // For std::string
34 
35 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkExtentRCBPartitioner : public vtkObject
36 {
37  public:
38  static vtkExtentRCBPartitioner *New();
40  void PrintSelf(ostream &oss, vtkIndent indent ) override;
41 
43 
46  void SetNumberOfPartitions( const int N )
47  {
48  assert( "pre: Number of partitions requested must be > 0" && (N >= 0) );
49  this->Reset();
50  this->NumberOfPartitions = N;
51  }
53 
55 
60  void SetGlobalExtent(int imin,int imax,int jmin,int jmax,int kmin,int kmax)
61  {
62  this->Reset();
63  this->GlobalExtent[0] = imin;
64  this->GlobalExtent[1] = imax;
65  this->GlobalExtent[2] = jmin;
66  this->GlobalExtent[3] = jmax;
67  this->GlobalExtent[4] = kmin;
68  this->GlobalExtent[5] = kmax;
69  }
70  void SetGlobalExtent( int ext[6] )
71  {
72  this->SetGlobalExtent( ext[0], ext[1], ext[2], ext[3], ext[4], ext[5] );
73  }
75 
77 
80  vtkSetMacro(DuplicateNodes,vtkTypeBool);
81  vtkGetMacro(DuplicateNodes,vtkTypeBool);
82  vtkBooleanMacro(DuplicateNodes,vtkTypeBool);
84 
86 
89  vtkSetMacro(NumberOfGhostLayers,int);
90  vtkGetMacro(NumberOfGhostLayers,int);
92 
94 
97  vtkGetMacro(NumExtents,int);
99 
103  void Partition();
104 
108  void GetPartitionExtent( const int idx, int ext[6] );
109 
110  protected:
112  ~vtkExtentRCBPartitioner() override;
113 
115 
119  void Reset()
120  {
121  this->PartitionExtents.clear();
122  this->NumExtents = 0;
123  this->ExtentIsPartitioned = false;
124  }
126 
132  void ExtendGhostLayers( int ext[6] );
133 
135 
141  int ext[6], const int minIdx, const int maxIdx )
142  {
143  ext[minIdx]-=this->NumberOfGhostLayers;
144  ext[maxIdx]+=this->NumberOfGhostLayers;
145  ext[minIdx] = (ext[minIdx] < this->GlobalExtent[minIdx])?
146  this->GlobalExtent[minIdx] : ext[minIdx];
147  ext[maxIdx] = (ext[maxIdx] > this->GlobalExtent[maxIdx])?
148  this->GlobalExtent[maxIdx] : ext[maxIdx];
149  }
151 
155  void AcquireDataDescription();
156 
160  void GetExtent( const int idx, int ext[6] );
161 
165  void AddExtent(int ext[6]);
166 
171  void ReplaceExtent(const int idx, int ext[6]);
172 
176  void SplitExtent(int parent[6],int s1[6],int s2[6],int splitDimension);
177 
182  int GetNumberOfTotalExtents();
183 
187  int GetNumberOfNodes( int ext[6] );
188 
192  int GetNumberOfCells( int ext[6] );
193 
197  int GetLongestDimensionLength( int ext[6] );
198 
202  int GetLongestDimension( int ext[6] );
203 
207  void PrintExtent( const std::string& name, int ext[6] );
208 
211  int GlobalExtent[6];
214 
215  vtkTypeBool DuplicateNodes; // indicates whether nodes are duplicated between
216  // partitions, so that they are abutting. This is
217  // set to true by default. If disabled, the resulting
218  // partitions will have gaps.
219 
221 
222  std::vector<int> PartitionExtents;
223 
224  private:
226  void operator=( const vtkExtentRCBPartitioner& ) = delete;
227 };
228 
229 #endif /* VTKEXTENTRCBPARTITIONER_H_ */
void SetGlobalExtent(int imin, int imax, int jmin, int jmax, int kmin, int kmax)
Set/Get the global extent array to be partitioned.
abstract base class for most VTK objects
Definition: vtkObject.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetGlobalExtent(int ext[6])
Set/Get the global extent array to be partitioned.
int vtkTypeBool
Definition: vtkABI.h:69
This method partitions a global extent to N partitions where N is a user supplied parameter...
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...
a simple class to control print indentation
Definition: vtkIndent.h:39
void SetNumberOfPartitions(const int N)
Set/Get the number of requested partitions.
std::vector< int > PartitionExtents
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void Reset()
Resets the partitioner to the initial state, all previous partition extents are cleared.