forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkExtentRCBPartitioner.h
223 lines (188 loc) · 5.83 KB
/
vtkExtentRCBPartitioner.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/*=========================================================================
Program: Visualization Toolkit
Module: vtkExtentRCBPartitioner.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkExtentRCBPartitioner
* @brief This method partitions a global extent to N partitions where N is a user
* supplied parameter.
*/
#ifndef vtkExtentRCBPartitioner_h
#define vtkExtentRCBPartitioner_h
#include "vtkCommonExecutionModelModule.h" // For export macro
#include "vtkObject.h"
#include <cassert> // For assert
#include <string> // For std::string
#include <vector> // For STL vector
class VTKCOMMONEXECUTIONMODEL_EXPORT vtkExtentRCBPartitioner : public vtkObject
{
public:
static vtkExtentRCBPartitioner* New();
vtkTypeMacro(vtkExtentRCBPartitioner, vtkObject);
void PrintSelf(ostream& oss, vtkIndent indent) override;
///@{
/**
* Set/Get the number of requested partitions
*/
void SetNumberOfPartitions(const int N)
{
assert("pre: Number of partitions requested must be > 0" && (N >= 0));
this->Reset();
this->NumberOfPartitions = N;
}
///@}
///@{
/**
* Set/Get the global extent array to be partitioned.
* The global extent is packed as follows:
* [imin,imax,jmin,jmax,kmin,kmax]
*/
void SetGlobalExtent(int imin, int imax, int jmin, int jmax, int kmin, int kmax)
{
this->Reset();
this->GlobalExtent[0] = imin;
this->GlobalExtent[1] = imax;
this->GlobalExtent[2] = jmin;
this->GlobalExtent[3] = jmax;
this->GlobalExtent[4] = kmin;
this->GlobalExtent[5] = kmax;
}
void SetGlobalExtent(int ext[6])
{
this->SetGlobalExtent(ext[0], ext[1], ext[2], ext[3], ext[4], ext[5]);
}
///@}
///@{
/**
* On/Off DuplicateNodes between partitions. Default is On.
*/
vtkSetMacro(DuplicateNodes, vtkTypeBool);
vtkGetMacro(DuplicateNodes, vtkTypeBool);
vtkBooleanMacro(DuplicateNodes, vtkTypeBool);
///@}
///@{
/**
* Set/Get macro for the number of ghost layers.
*/
vtkSetMacro(NumberOfGhostLayers, int);
vtkGetMacro(NumberOfGhostLayers, int);
///@}
///@{
/**
* Returns the number of extents.
*/
vtkGetMacro(NumExtents, int);
///@}
/**
* Partitions the extent
*/
void Partition();
/**
* Returns the extent of the partition corresponding to the given ID.
*/
void GetPartitionExtent(const int idx, int ext[6]);
protected:
vtkExtentRCBPartitioner();
~vtkExtentRCBPartitioner() override;
///@{
/**
* Resets the partitioner to the initial state, all previous partition
* extents are cleared.
*/
void Reset()
{
this->PartitionExtents.clear();
this->NumExtents = 0;
this->ExtentIsPartitioned = false;
}
///@}
/**
* Given an extent, this method will create ghost layers on each side of
* the boundary in each dimension. The ghost layers however will be
* restricted to the given global extent.
*/
void ExtendGhostLayers(int ext[6]);
///@{
/**
* Givent an extent and the min/max of the dimension we are looking at, this
* method will produce a ghosted extent which is clamped within the given
* global extent
*/
void GetGhostedExtent(int ext[6], const int minIdx, const int maxIdx)
{
ext[minIdx] -= this->NumberOfGhostLayers;
ext[maxIdx] += this->NumberOfGhostLayers;
ext[minIdx] =
(ext[minIdx] < this->GlobalExtent[minIdx]) ? this->GlobalExtent[minIdx] : ext[minIdx];
ext[maxIdx] =
(ext[maxIdx] > this->GlobalExtent[maxIdx]) ? this->GlobalExtent[maxIdx] : ext[maxIdx];
}
///@}
/**
* Gets the structured data-description based on the givenn global extent
*/
void AcquireDataDescription();
/**
* Returns the extent at the position corresponding to idx.
*/
void GetExtent(const int idx, int ext[6]);
/**
* Adds the extent to the end of the list of partitioned extents
*/
void AddExtent(int ext[6]);
/**
* Replaces the extent at the position indicated by idx with the provided
* extent.
*/
void ReplaceExtent(const int idx, int ext[6]);
/**
* Splits the extent along the given dimension.
*/
void SplitExtent(int parent[6], int s1[6], int s2[6], int splitDimension);
/**
* Returns the total number of extents. It's always the 2^N where
* N is the number of subdivisions.
*/
int GetNumberOfTotalExtents();
/**
* Computes the total number of nodes for the given structured grid extent
*/
int GetNumberOfNodes(int ext[6]);
/**
* Computes the total number of cells for the given structured grid extent
*/
int GetNumberOfCells(int ext[6]);
/**
* Returns the length of the longest dimension
*/
int GetLongestDimensionLength(int ext[6]);
/**
* Returns the longest edge
*/
int GetLongestDimension(int ext[6]);
/**
* A convenience method for debugging purposes.
*/
void PrintExtent(const std::string& name, int ext[6]);
int NumberOfGhostLayers;
int DataDescription;
int GlobalExtent[6];
int NumberOfPartitions;
int NumExtents;
vtkTypeBool DuplicateNodes; // indicates whether nodes are duplicated between
// partitions, so that they are abutting. This is
// set to true by default. If disabled, the resulting
// partitions will have gaps.
bool ExtentIsPartitioned;
std::vector<int> PartitionExtents;
private:
vtkExtentRCBPartitioner(const vtkExtentRCBPartitioner&) = delete;
void operator=(const vtkExtentRCBPartitioner&) = delete;
};
#endif /* VTKEXTENTRCBPARTITIONER_H_ */