VTK
dox/Parallel/vtkWindBladeReader.h
Go to the documentation of this file.
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();    // Output port 0
00077   vtkUnstructuredGrid *GetBladeOutput();  // Output port 1
00078   vtkStructuredGrid *GetGroundOutput();      // Output port 2
00080 
00082 
00085   int GetNumberOfPointArrays();
00086   const char* GetPointArrayName(int index);
00088 
00089   int  GetPointArrayStatus(const char* name);
00090   void SetPointArrayStatus(const char* name, int status);
00091 
00092   void DisableAllPointArrays();
00093   void EnableAllPointArrays();
00094 
00095 protected:
00096   vtkWindBladeReader();
00097   ~vtkWindBladeReader();
00098 
00099   char* Filename;   // Base file name
00100   FILE* FilePtr;   // Open file pointer
00101 
00102   int Rank;    // Number of this processor
00103   int TotalRank;   // Number of processors
00104 
00105   // Extent information
00106   vtkIdType NumberOfTuples;  // Number of tuples in subextent
00107 
00108   // Field
00109   int WholeExtent[6];  // Extents of entire grid
00110   int SubExtent[6];  // Processor grid extent
00111   int UpdateExtent[6];
00112   int Dimension[3];  // Size of entire grid
00113   int SubDimension[3];  // Size of processor grid
00114 
00115   // Ground
00116   int GExtent[6];      // Extents of ground grid
00117   int GSubExtent[6];  // Processor grid extent
00118   int GDimension[3];   // Size of ground grid
00119 
00120   float Step[3];  // Spacing delta
00121   int UseTopographyFile;  // Topography or flat
00122   vtkStdString TopographyFile;  // Name of topography data file
00123   vtkPoints* Points;   // Structured grid geometry
00124   vtkPoints* GPoints;   // Structured grid geometry for ground
00125   vtkPoints* BPoints;   // Unstructured grid geometry
00126   float Compression;   // Stretching at Z surface [0,1]
00127   float Fit;    // Cubic or quadratic [0,1]
00128 
00129   // Rectilinear coordinate spacing
00130   vtkFloatArray* xSpacing;
00131   vtkFloatArray* ySpacing;
00132   vtkFloatArray* zSpacing;
00133   float* zTopographicValues;
00134   float zMinValue;
00135 
00136   // Variable information
00137   int NumberOfFileVariables;  // Number of variables in data file
00138   int NumberOfDerivedVariables;  // Number of variables derived from file
00139   int NumberOfVariables;  // Number of variables to display
00140 
00141   vtkStringArray* DivideVariables; // Divide data by density at read
00142   vtkStdString* VariableName;  // Names of each variable
00143   int* VariableStruct;   // SCALAR or VECTOR
00144   int* VariableCompSize;  // Number of components
00145   int* VariableBasicType;  // FLOAT or INTEGER
00146   int* VariableByteCount;  // Number of bytes in basic type
00147   long int* VariableOffset;  // Offset into data file
00148   int BlockSize;   // Size of every data block
00149   int GBlockSize;  // Size of every data block
00150 
00151   vtkFloatArray** data;   // Actual data arrays
00152   vtkStdString RootDirectory; // Directory where the .wind file is.
00153   vtkStdString DataDirectory;  // Location of actual data
00154   vtkStdString DataBaseName;  // Base name of files
00155 
00156   // Time step information
00157   int NumberOfTimeSteps;  // Number of time steps
00158   int TimeStepFirst;   // First time step
00159   int TimeStepLast;   // Last time step
00160   int TimeStepDelta;   // Delta on time steps
00161   double* TimeSteps;   // Actual times available for request
00162 
00163   // Turbine information
00164   int NumberOfBladeTowers;  // Number of turbines
00165   int NumberOfBladePoints;  // Points for drawing parts of blades
00166   int NumberOfBladeCells;  // Turbines * Blades * Parts
00167 
00168   vtkFloatArray* XPosition;  // Location of tower
00169   vtkFloatArray* YPosition;  // Location of tower
00170   vtkFloatArray* HubHeight;  // Height of tower
00171   vtkIntArray* BladeCount;  // Number of blades per tower
00172 
00173   int UseTurbineFile;   // Turbine data available
00174   vtkStdString TurbineDirectory; // Turbine unstructured data
00175   vtkStdString TurbineTowerName; // Name of tower file
00176   vtkStdString TurbineBladeName; // Base name of time series blade data
00177 
00178   // Selected field of interest
00179   vtkDataArraySelection* PointDataArraySelection;
00180 
00181   // Observer to modify this object when array selections are modified
00182   vtkCallbackCommand* SelectionObserver;
00183 
00184   // Controlls initializing and querrying MPI
00185   vtkMultiProcessController * MPIController; 
00186 
00187   // Read the header file describing the dataset
00188   void ReadGlobalData();
00189   void ReadDataVariables(ifstream& inStr);
00190   void FindVariableOffsets();
00191 
00192   // Turbine methods
00193   void SetupBladeData();
00194   void LoadBladeData(int timeStep);
00195 
00196   // Calculate the coordinates
00197   void FillCoordinates();
00198   void FillGroundCoordinates();
00199   void CreateCoordinates();
00200   void CreateZTopography(float* zdata);
00201   float GDeform(float sigma, float sigmaMax, int flag);
00202   void spline(float* x, float* y, int n, float yp1, float ypn, float* y2);
00203   void splint(float* xa, float* ya, float* y2a, int n, float x, float* y, int);
00204 
00205   // Load a variable from data file
00206   void LoadVariableData(int var);
00207 
00208   // Variables which must be divided by density after being read from file
00209   void DivideByDensity(const char* name);
00210 
00211   // Calculate derived variables
00212   void CalculateVorticity(int vort, int uvw, int density);
00213   void CalculatePressure(int pres, int prespre, int tempg, int density);
00214 
00215   virtual int RequestData(
00216     vtkInformation* request, 
00217     vtkInformationVector** inputVector,
00218     vtkInformationVector* outputVector);
00219 
00220   virtual int RequestInformation(
00221     vtkInformation* request,
00222     vtkInformationVector** inputVector,
00223     vtkInformationVector* outputVector);
00224 
00225   static void SelectionCallback(
00226     vtkObject *caller, 
00227     unsigned long eid,
00228     void *clientdata, 
00229     void *calldata);
00230 
00231   static void EventCallback(
00232     vtkObject* caller, 
00233     unsigned long eid,
00234     void* clientdata, void* calldata);
00235 
00236   virtual int FillOutputPortInformation(int, vtkInformation*);
00237 
00238 private:
00239   vtkWindBladeReader(const vtkWindBladeReader&);  // Not implemented.
00240   void operator=(const vtkWindBladeReader&);  // Not implemented.
00241 };
00242 #endif
00243