VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkWindBladeReader.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 =========================================================================*/ 00032 #ifndef __vtkWindBladeReader_h 00033 #define __vtkWindBladeReader_h 00034 00035 #include "vtkIOGeometryModule.h" // For export macro 00036 #include "vtkStructuredGridAlgorithm.h" 00037 00038 class vtkDataArraySelection; 00039 class vtkCallbackCommand; 00040 class vtkStringArray; 00041 class vtkFloatArray; 00042 class vtkIntArray; 00043 class vtkPoints; 00044 class vtkStructuredGrid; 00045 class vtkUnstructuredGrid; 00046 class vtkMultiBlockDataSetAglorithm; 00047 class vtkStructuredGridAlgorithm; 00048 class WindBladeReaderInternal; 00049 00050 class VTKIOGEOMETRY_EXPORT vtkWindBladeReader : public vtkStructuredGridAlgorithm 00051 { 00052 public: 00053 static vtkWindBladeReader *New(); 00054 vtkTypeMacro(vtkWindBladeReader,vtkStructuredGridAlgorithm); 00055 void PrintSelf(ostream& os, vtkIndent indent); 00056 00057 vtkSetStringMacro(Filename); 00058 vtkGetStringMacro(Filename); 00059 00060 vtkSetVector6Macro(WholeExtent, int); 00061 vtkGetVector6Macro(WholeExtent, int); 00062 00063 vtkSetVector6Macro(SubExtent, int); 00064 vtkGetVector6Macro(SubExtent, int); 00065 00067 00068 vtkStructuredGrid *GetFieldOutput(); // Output port 0 00069 vtkUnstructuredGrid *GetBladeOutput(); // Output port 1 00070 vtkStructuredGrid *GetGroundOutput(); // Output port 2 00072 00074 00077 int GetNumberOfPointArrays(); 00078 const char* GetPointArrayName(int index); 00080 00081 int GetPointArrayStatus(const char* name); 00082 void SetPointArrayStatus(const char* name, int status); 00083 00084 void DisableAllPointArrays(); 00085 void EnableAllPointArrays(); 00086 00087 protected: 00088 //BTX 00089 static float DRY_AIR_CONSTANT; 00090 static int NUM_PART_SIDES; // Blade parts rhombus 00091 const static int NUM_BASE_SIDES; // Base pyramid 00092 const static int LINE_SIZE; 00093 static int DIMENSION; 00094 static int BYTES_PER_DATA; 00095 static int SCALAR; 00096 static int VECTOR; 00097 static int FLOAT; 00098 static int INTEGER; 00099 //ETX 00100 00101 vtkWindBladeReader(); 00102 ~vtkWindBladeReader(); 00103 00104 char* Filename; // Base file name 00105 00106 // Extent information 00107 vtkIdType NumberOfTuples; // Number of tuples in subextent 00108 00109 // Field 00110 int WholeExtent[6]; // Extents of entire grid 00111 int SubExtent[6]; // Processor grid extent 00112 int UpdateExtent[6]; 00113 int Dimension[3]; // Size of entire grid 00114 int SubDimension[3]; // Size of processor grid 00115 00116 // Ground 00117 int GExtent[6]; // Extents of ground grid 00118 int GSubExtent[6]; // Processor grid extent 00119 int GDimension[3]; // Size of ground grid 00120 00121 float Step[3]; // Spacing delta 00122 int UseTopographyFile; // Topography or flat 00123 vtkStdString TopographyFile; // Name of topography data file 00124 vtkPoints* Points; // Structured grid geometry 00125 vtkPoints* GPoints; // Structured grid geometry for ground 00126 vtkPoints* BPoints; // Unstructured grid geometry 00127 float Compression; // Stretching at Z surface [0,1] 00128 float Fit; // Cubic or quadratic [0,1] 00129 00130 // Rectilinear coordinate spacing 00131 vtkFloatArray* XSpacing; 00132 vtkFloatArray* YSpacing; 00133 vtkFloatArray* ZSpacing; 00134 float* ZTopographicValues; 00135 float ZMinValue; 00136 00137 // Variable information 00138 int NumberOfFileVariables; // Number of variables in data file 00139 int NumberOfDerivedVariables; // Number of variables derived from file 00140 int NumberOfVariables; // Number of variables to display 00141 00142 vtkStringArray* DivideVariables; // Divide data by density at read 00143 vtkStdString* VariableName; // Names of each variable 00144 int* VariableStruct; // SCALAR or VECTOR 00145 int* VariableCompSize; // Number of components 00146 int* VariableBasicType; // FLOAT or INTEGER 00147 int* VariableByteCount; // Number of bytes in basic type 00148 long int* VariableOffset; // Offset into data file 00149 unsigned int BlockSize; // Size of every data block 00150 int GBlockSize; // Size of every data block 00151 00152 vtkFloatArray** Data; // Actual data arrays 00153 vtkStdString RootDirectory; // Directory where the .wind file is. 00154 vtkStdString DataDirectory; // Location of actual data 00155 vtkStdString DataBaseName; // Base name of files 00156 00157 // Time step information 00158 int NumberOfTimeSteps; // Number of time steps 00159 int TimeStepFirst; // First time step 00160 int TimeStepLast; // Last time step 00161 int TimeStepDelta; // Delta on time steps 00162 double* TimeSteps; // Actual times available for request 00163 00164 // Turbine information 00165 int NumberOfBladeTowers; // Number of turbines 00166 int NumberOfBladePoints; // Points for drawing parts of blades 00167 int NumberOfBladeCells; // Turbines * Blades * Parts 00168 00169 vtkFloatArray* XPosition; // Location of tower 00170 vtkFloatArray* YPosition; // Location of tower 00171 vtkFloatArray* HubHeight; // Height of tower 00172 vtkFloatArray* AngularVeloc; // Angular Velocity 00173 vtkFloatArray* BladeLength; // Blade length 00174 vtkIntArray* BladeCount; // Number of blades per tower 00175 00176 int UseTurbineFile; // Turbine data available 00177 vtkStdString TurbineDirectory; // Turbine unstructured data 00178 vtkStdString TurbineTowerName; // Name of tower file 00179 vtkStdString TurbineBladeName; // Base name of time series blade data 00180 int NumberOfLinesToSkip; // New format has lines that need to be skipped in 00181 // blade files 00182 00183 // Selected field of interest 00184 vtkDataArraySelection* PointDataArraySelection; 00185 00186 // Observer to modify this object when array selections are modified 00187 vtkCallbackCommand* SelectionObserver; 00188 00189 00190 // Read the header file describing the dataset 00191 virtual bool ReadGlobalData(); 00192 void ReadDataVariables(istream& inStr); 00193 virtual bool FindVariableOffsets(); 00194 00195 // Turbine methods 00196 virtual void SetupBladeData(); 00197 virtual void LoadBladeData(int timeStep); 00198 00199 // Calculate the coordinates 00200 void FillCoordinates(); 00201 void FillGroundCoordinates(); 00202 void CreateCoordinates(); 00203 virtual void CreateZTopography(float* zdata); 00204 float GDeform(float sigma, float sigmaMax, int flag); 00205 void Spline(float* x, float* y, int n, float yp1, float ypn, float* y2); 00206 void Splint(float* xa, float* ya, float* y2a, int n, float x, float* y, int); 00207 00208 // Load a variable from data file 00209 virtual void LoadVariableData(int var); 00210 00211 // Variables which must be divided by density after being read from file 00212 void DivideByDensity(const char* name); 00213 00214 // Calculate derived variables 00215 virtual void CalculatePressure(int pres, int prespre, int tempg, int density); 00216 virtual void CalculateVorticity(int vort, int uvw, int density); 00217 00218 // convenience functions shared between serial and parallel version 00219 void InitFieldData(vtkInformationVector *outVector, 00220 std::ostringstream &fileName, 00221 vtkStructuredGrid *field); 00222 void SetUpFieldVars(vtkStructuredGrid *field); 00223 void InitBladeData(vtkInformationVector *outVector); 00224 void SetUpGroundData(vtkInformationVector *outVector); 00225 void InitPressureData(int pressure, int prespre, 00226 float *&pressureData, float *&prespreData); 00227 void SetUpPressureData(float* pressureData, float* prespreData, 00228 float* tempgData, float* densityData); 00229 void SetUpVorticityData(float* uData, float* vData, float *densityData, 00230 float* vortData); 00231 void InitVariableData(int var, int &numberOfComponents, float *&varData, 00232 int &planeSize, int &rowSize); 00233 bool SetUpGlobalData(const std::string &fileName, std::stringstream& inStr); 00234 void ProcessZCoords(float *topoData, float *zValues); 00235 void ReadBladeHeader(const std::string &fileName, std::stringstream &inStr, 00236 int &numColumns); 00237 void ReadBladeData(std::stringstream &inStr); 00238 00239 virtual int RequestInformation(vtkInformation *, vtkInformationVector **, 00240 vtkInformationVector *); 00241 virtual int RequestData( 00242 vtkInformation* request, 00243 vtkInformationVector** inputVector, 00244 vtkInformationVector* outputVector); 00245 00246 static void SelectionCallback( 00247 vtkObject *caller, 00248 unsigned long eid, 00249 void *clientdata, 00250 void *calldata); 00251 00252 static void EventCallback( 00253 vtkObject* caller, 00254 unsigned long eid, 00255 void* clientdata, void* calldata); 00256 00257 virtual int FillOutputPortInformation(int, vtkInformation*); 00259 00263 int ProcessRequest(vtkInformation *request, 00264 vtkInformationVector **inInfo, 00265 vtkInformationVector *outInfo); 00266 private: 00267 WindBladeReaderInternal * Internal; 00269 00270 vtkWindBladeReader(const vtkWindBladeReader&); // Not implemented. 00271 void operator=(const vtkWindBladeReader&); // Not implemented. 00272 }; 00273 #endif