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 =========================================================================*/ 00022 #ifndef VTKEXTENTRCBPARTITIONER_H_ 00023 #define VTKEXTENTRCBPARTITIONER_H_ 00024 00025 #include "vtkCommonExecutionModelModule.h" // For export macro 00026 #include "vtkObject.h" 00027 #include <vector> // For STL vector 00028 #include <cassert> // For assert 00029 00030 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkExtentRCBPartitioner : public vtkObject 00031 { 00032 public: 00033 static vtkExtentRCBPartitioner *New(); 00034 vtkTypeMacro(vtkExtentRCBPartitioner,vtkObject); 00035 void PrintSelf(ostream &oss, vtkIndent indent ); 00036 00038 00039 void SetNumberOfPartitions( const int N ) 00040 { 00041 assert( "pre: Number of partitions requested must be > 0" && (N >= 0) ); 00042 this->Reset(); 00043 this->NumberOfPartitions = N; 00044 } 00046 00048 00050 void SetGlobalExtent(int imin,int imax,int jmin,int jmax,int kmin,int kmax) 00051 { 00052 this->Reset(); 00053 this->GlobalExtent[0] = imin; 00054 this->GlobalExtent[1] = imax; 00055 this->GlobalExtent[2] = jmin; 00056 this->GlobalExtent[3] = jmax; 00057 this->GlobalExtent[4] = kmin; 00058 this->GlobalExtent[5] = kmax; 00059 } 00060 void SetGlobalExtent( int ext[6] ) 00061 { 00062 this->SetGlobalExtent( ext[0], ext[1], ext[2], ext[3], ext[4], ext[5] ); 00063 } 00065 00067 00068 vtkSetMacro(NumberOfGhostLayers,int); 00069 vtkGetMacro(NumberOfGhostLayers,int); 00071 00073 00074 vtkGetMacro(NumExtents,int); 00076 00078 void Partition(); 00079 00081 void GetPartitionExtent( const int idx, int ext[6] ); 00082 00083 protected: 00084 vtkExtentRCBPartitioner(); 00085 ~vtkExtentRCBPartitioner(); 00086 00088 00090 void Reset() 00091 { 00092 this->PartitionExtents.clear(); 00093 this->NumExtents = 0; 00094 this->ExtentIsPartitioned = false; 00095 } 00097 00101 void ExtendGhostLayers( int ext[6] ); 00102 00104 00107 void GetGhostedExtent( 00108 int ext[6], const int minIdx, const int maxIdx ) 00109 { 00110 ext[minIdx]-=this->NumberOfGhostLayers; 00111 ext[maxIdx]+=this->NumberOfGhostLayers; 00112 ext[minIdx] = (ext[minIdx] < this->GlobalExtent[minIdx])? 00113 this->GlobalExtent[minIdx] : ext[minIdx]; 00114 ext[maxIdx] = (ext[maxIdx] > this->GlobalExtent[maxIdx])? 00115 this->GlobalExtent[maxIdx] : ext[maxIdx]; 00116 } 00118 00121 void AcquireDataDescription(); 00122 00124 void GetExtent( const int idx, int ext[6] ); 00125 00127 void AddExtent(int ext[6]); 00128 00131 void ReplaceExtent(const int idx, int ext[6]); 00132 00134 void SplitExtent(int parent[6],int s1[6],int s2[6],int splitDimension); 00135 00138 int GetNumberOfTotalExtents(); 00139 00142 int GetNumberOfNodes( int ext[6] ); 00143 00146 int GetNumberOfCells( int ext[6] ); 00147 00149 int GetLongestDimensionLength( int ext[6] ); 00150 00152 int GetLongestDimension( int ext[6] ); 00153 00155 void PrintExtent( std::string name, int ext[6] ); 00156 00157 int NumberOfGhostLayers; 00158 int DataDescription; 00159 int GlobalExtent[6]; 00160 int NumberOfPartitions; 00161 int NumExtents; 00162 bool ExtentIsPartitioned; 00163 00164 // BTX 00165 std::vector<int> PartitionExtents; 00166 // ETX 00167 00168 private: 00169 vtkExtentRCBPartitioner( const vtkExtentRCBPartitioner& );// Not implemented 00170 void operator=( const vtkExtentRCBPartitioner& );// Not implemented 00171 }; 00172 00173 #endif /* VTKEXTENTRCBPARTITIONER_H_ */