VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkExtentRCBPartitioner.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00025 #ifndef VTKEXTENTRCBPARTITIONER_H_ 00026 #define VTKEXTENTRCBPARTITIONER_H_ 00027 00028 #include "vtkCommonExecutionModelModule.h" // For export macro 00029 #include "vtkObject.h" 00030 #include <vector> // For STL vector 00031 #include <cassert> // For assert 00032 #include <string> // For std::string 00033 00034 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkExtentRCBPartitioner : public vtkObject 00035 { 00036 public: 00037 static vtkExtentRCBPartitioner *New(); 00038 vtkTypeMacro(vtkExtentRCBPartitioner,vtkObject); 00039 void PrintSelf(ostream &oss, vtkIndent indent ); 00040 00042 00043 void SetNumberOfPartitions( const int N ) 00044 { 00045 assert( "pre: Number of partitions requested must be > 0" && (N >= 0) ); 00046 this->Reset(); 00047 this->NumberOfPartitions = N; 00048 } 00050 00052 00054 void SetGlobalExtent(int imin,int imax,int jmin,int jmax,int kmin,int kmax) 00055 { 00056 this->Reset(); 00057 this->GlobalExtent[0] = imin; 00058 this->GlobalExtent[1] = imax; 00059 this->GlobalExtent[2] = jmin; 00060 this->GlobalExtent[3] = jmax; 00061 this->GlobalExtent[4] = kmin; 00062 this->GlobalExtent[5] = kmax; 00063 } 00064 void SetGlobalExtent( int ext[6] ) 00065 { 00066 this->SetGlobalExtent( ext[0], ext[1], ext[2], ext[3], ext[4], ext[5] ); 00067 } 00069 00071 00072 vtkSetMacro(DuplicateNodes,int); 00073 vtkGetMacro(DuplicateNodes,int); 00074 vtkBooleanMacro(DuplicateNodes,int); 00076 00078 00079 vtkSetMacro(NumberOfGhostLayers,int); 00080 vtkGetMacro(NumberOfGhostLayers,int); 00082 00084 00085 vtkGetMacro(NumExtents,int); 00087 00089 void Partition(); 00090 00092 void GetPartitionExtent( const int idx, int ext[6] ); 00093 00094 protected: 00095 vtkExtentRCBPartitioner(); 00096 ~vtkExtentRCBPartitioner(); 00097 00099 00101 void Reset() 00102 { 00103 this->PartitionExtents.clear(); 00104 this->NumExtents = 0; 00105 this->ExtentIsPartitioned = false; 00106 } 00108 00112 void ExtendGhostLayers( int ext[6] ); 00113 00115 00118 void GetGhostedExtent( 00119 int ext[6], const int minIdx, const int maxIdx ) 00120 { 00121 ext[minIdx]-=this->NumberOfGhostLayers; 00122 ext[maxIdx]+=this->NumberOfGhostLayers; 00123 ext[minIdx] = (ext[minIdx] < this->GlobalExtent[minIdx])? 00124 this->GlobalExtent[minIdx] : ext[minIdx]; 00125 ext[maxIdx] = (ext[maxIdx] > this->GlobalExtent[maxIdx])? 00126 this->GlobalExtent[maxIdx] : ext[maxIdx]; 00127 } 00129 00132 void AcquireDataDescription(); 00133 00135 void GetExtent( const int idx, int ext[6] ); 00136 00138 void AddExtent(int ext[6]); 00139 00142 void ReplaceExtent(const int idx, int ext[6]); 00143 00145 void SplitExtent(int parent[6],int s1[6],int s2[6],int splitDimension); 00146 00149 int GetNumberOfTotalExtents(); 00150 00153 int GetNumberOfNodes( int ext[6] ); 00154 00157 int GetNumberOfCells( int ext[6] ); 00158 00160 int GetLongestDimensionLength( int ext[6] ); 00161 00163 int GetLongestDimension( int ext[6] ); 00164 00166 void PrintExtent( std::string name, int ext[6] ); 00167 00168 int NumberOfGhostLayers; 00169 int DataDescription; 00170 int GlobalExtent[6]; 00171 int NumberOfPartitions; 00172 int NumExtents; 00173 00174 int DuplicateNodes; // indicates whether nodes are duplicated between 00175 // partitions, so that they are abutting. This is 00176 // set to true by default. If disabled, the resulting 00177 // partitions will have gaps. 00178 00179 bool ExtentIsPartitioned; 00180 00181 // BTX 00182 std::vector<int> PartitionExtents; 00183 // ETX 00184 00185 private: 00186 vtkExtentRCBPartitioner( const vtkExtentRCBPartitioner& );// Not implemented 00187 void operator=( const vtkExtentRCBPartitioner& );// Not implemented 00188 }; 00189 00190 #endif /* VTKEXTENTRCBPARTITIONER_H_ */