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 =========================================================================*/ 00026 #ifndef __vtkWindBladeReader_h 00027 #define __vtkWindBladeReader_h 00028 00029 00030 #include "vtkStructuredGridAlgorithm.h" 00031 00032 #define VTK_USE_MPI 00033 00034 const float DRY_AIR_CONSTANT = 287.04; 00035 const int NUM_PART_SIDES = 4; // Blade parts rhombus 00036 const int NUM_BASE_SIDES = 5; // Base pyramid 00037 const int LINE_SIZE = 256; 00038 const int DIMENSION = 3; 00039 const int BYTES_PER_DATA = 4; 00040 const int SCALAR = 1; 00041 const int VECTOR = 2; 00042 const int FLOAT = 1; 00043 const int INTEGER = 2; 00044 00045 class vtkWindBladeReaderPiece; 00046 class vtkDataArraySelection; 00047 class vtkCallbackCommand; 00048 class vtkMultiProcessController; 00049 class vtkStringArray; 00050 class vtkFloatArray; 00051 class vtkIntArray; 00052 class vtkPoints; 00053 class vtkStructuredGrid; 00054 class vtkUnstructuredGrid; 00055 class vtkMultiBlockDataSetAglorithm; 00056 class vtkStructuredGridAlgorithm; 00057 00058 class VTK_PARALLEL_EXPORT vtkWindBladeReader : public vtkStructuredGridAlgorithm 00059 { 00060 public: 00061 static vtkWindBladeReader *New(); 00062 vtkTypeMacro(vtkWindBladeReader,vtkStructuredGridAlgorithm); 00063 void PrintSelf(ostream& os, vtkIndent indent); 00064 00065 vtkSetStringMacro(Filename); 00066 vtkGetStringMacro(Filename); 00067 00068 vtkSetVector6Macro(WholeExtent, int); 00069 vtkGetVector6Macro(WholeExtent, int); 00070 00071 vtkSetVector6Macro(SubExtent, int); 00072 vtkGetVector6Macro(SubExtent, int); 00073 00075 00076 vtkStructuredGrid *GetFieldOutput(); 00077 vtkUnstructuredGrid *GetBladeOutput(); 00079 00081 00084 int GetNumberOfPointArrays(); 00085 const char* GetPointArrayName(int index); 00087 00088 int GetPointArrayStatus(const char* name); 00089 void SetPointArrayStatus(const char* name, int status); 00090 00091 void DisableAllPointArrays(); 00092 void EnableAllPointArrays(); 00093 00094 protected: 00095 vtkWindBladeReader(); 00096 ~vtkWindBladeReader(); 00097 00098 char* Filename; // Base file name 00099 FILE* FilePtr; // Open file pointer 00100 00101 int Rank; // Number of this processor 00102 int TotalRank; // Number of processors 00103 00104 // Extent information 00105 vtkIdType NumberOfTuples; // Number of tuples in subextent 00106 00107 int WholeExtent[6]; // Extents of entire grid 00108 int SubExtent[6]; // Processor grid extent 00109 int UpdateExtent[6]; 00110 int Dimension[3]; // Size of entire grid 00111 int SubDimension[3]; // Size of processor grid 00112 00113 float Step[3]; // Spacing delta 00114 int UseTopographyFile; // Topography or flat 00115 vtkStdString TopographyFile; // Name of topography data file 00116 vtkPoints* Points; // Structured grid geometry 00117 vtkPoints* BPoints; // Unstructured grid geometry 00118 float Compression; // Stretching at Z surface [0,1] 00119 float Fit; // Cubic or quadratic [0,1] 00120 00121 // Rectilinear coordinate spacing 00122 vtkFloatArray* xSpacing; 00123 vtkFloatArray* ySpacing; 00124 vtkFloatArray* zSpacing; 00125 float* zTopographicValues; 00126 00127 // Variable information 00128 int NumberOfFileVariables; // Number of variables in data file 00129 int NumberOfDerivedVariables; // Number of variables derived from file 00130 int NumberOfVariables; // Number of variables to display 00131 00132 vtkStringArray* DivideVariables; // Divide data by density at read 00133 vtkStdString* VariableName; // Names of each variable 00134 int* VariableStruct; // SCALAR or VECTOR 00135 int* VariableCompSize; // Number of components 00136 int* VariableBasicType; // FLOAT or INTEGER 00137 int* VariableByteCount; // Number of bytes in basic type 00138 long int* VariableOffset; // Offset into data file 00139 int BlockSize; // Size of every data block 00140 00141 vtkFloatArray** data; // Actual data arrays 00142 vtkStdString RootDirectory; // Directory where the .wind file is. 00143 vtkStdString DataDirectory; // Location of actual data 00144 vtkStdString DataBaseName; // Base name of files 00145 00146 // Time step information 00147 int NumberOfTimeSteps; // Number of time steps 00148 int TimeStepFirst; // First time step 00149 int TimeStepLast; // Last time step 00150 int TimeStepDelta; // Delta on time steps 00151 double* TimeSteps; // Actual times available for request 00152 00153 // Turbine information 00154 int NumberOfBladeTowers; // Number of turbines 00155 int NumberOfBladePoints; // Points for drawing parts of blades 00156 int NumberOfBladeCells; // Turbines * Blades * Parts 00157 00158 vtkFloatArray* XPosition; // Location of tower 00159 vtkFloatArray* YPosition; // Location of tower 00160 vtkFloatArray* HubHeight; // Height of tower 00161 vtkIntArray* BladeCount; // Number of blades per tower 00162 00163 int UseTurbineFile; // Turbine data available 00164 vtkStdString TurbineDirectory; // Turbine unstructured data 00165 vtkStdString TurbineTowerName; // Name of tower file 00166 vtkStdString TurbineBladeName; // Base name of time series blade data 00167 int NumberLinesToSkip; // New format has lines that need to skipped 00168 // in blade files 00169 00170 // Selected field of interest 00171 vtkDataArraySelection* PointDataArraySelection; 00172 00173 // Observer to modify this object when array selections are modified 00174 vtkCallbackCommand* SelectionObserver; 00175 00176 // Controlls initializing and querrying MPI 00177 vtkMultiProcessController * MPIController; 00178 00179 // Read the header file describing the dataset 00180 void ReadGlobalData(); 00181 void ReadDataVariables(ifstream& inStr); 00182 void FindVariableOffsets(); 00183 00184 // Turbine methods 00185 void SetupBladeData(); 00186 void LoadBladeData(int timeStep); 00187 00188 // Calculate the coordinates 00189 void FillCoordinates(); 00190 void CreateCoordinates(); 00191 void CreateZTopography(float* zdata); 00192 float GDeform(float sigma, float sigmaMax, int flag); 00193 void spline(float* x, float* y, int n, float yp1, float ypn, float* y2); 00194 void splint(float* xa, float* ya, float* y2a, int n, float x, float* y, int); 00195 00196 // Load a variable from data file 00197 void LoadVariableData(int var); 00198 00199 // Variables which must be divided by density after being read from file 00200 void DivideByDensity(const char* name); 00201 00202 // Calculate derived variables 00203 void CalculateVorticity(int vort, int uvw, int density); 00204 void CalculatePressure(int pres, int prespre, int tempg, int density); 00205 00206 virtual int RequestData( 00207 vtkInformation* request, 00208 vtkInformationVector** inputVector, 00209 vtkInformationVector* outputVector); 00210 00211 virtual int RequestInformation( 00212 vtkInformation* request, 00213 vtkInformationVector** inputVector, 00214 vtkInformationVector* outputVector); 00215 00216 static void SelectionCallback( 00217 vtkObject *caller, 00218 unsigned long eid, 00219 void *clientdata, 00220 void *calldata); 00221 00222 static void EventCallback( 00223 vtkObject* caller, 00224 unsigned long eid, 00225 void* clientdata, void* calldata); 00226 00227 virtual int FillOutputPortInformation(int, vtkInformation*); 00228 00229 private: 00230 vtkWindBladeReader(const vtkWindBladeReader&); // Not implemented. 00231 void operator=(const vtkWindBladeReader&); // Not implemented. 00232 }; 00233 #endif 00234