VTK
vtkWindBladeReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkWindBladeReader.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
26 #ifndef __vtkWindBladeReader_h
27 #define __vtkWindBladeReader_h
28 
29 
31 
32 #define VTK_USE_MPI
33 
34 const float DRY_AIR_CONSTANT = 287.04;
35 const int NUM_PART_SIDES = 4; // Blade parts rhombus
36 const int NUM_BASE_SIDES = 5; // Base pyramid
37 const int LINE_SIZE = 256;
38 const int DIMENSION = 3;
39 const int BYTES_PER_DATA = 4;
40 const int SCALAR = 1;
41 const int VECTOR = 2;
42 const int FLOAT = 1;
43 const int INTEGER = 2;
44 
45 class vtkWindBladeReaderPiece;
47 class vtkCallbackCommand;
49 class vtkStringArray;
50 class vtkFloatArray;
51 class vtkIntArray;
52 class vtkPoints;
53 class vtkStructuredGrid;
55 class vtkMultiBlockDataSetAglorithm;
57 
59 {
60 public:
61  static vtkWindBladeReader *New();
63  void PrintSelf(ostream& os, vtkIndent indent);
64 
65  vtkSetStringMacro(Filename);
66  vtkGetStringMacro(Filename);
67 
68  vtkSetVector6Macro(WholeExtent, int);
69  vtkGetVector6Macro(WholeExtent, int);
70 
71  vtkSetVector6Macro(SubExtent, int);
72  vtkGetVector6Macro(SubExtent, int);
73 
75 
76  vtkStructuredGrid *GetFieldOutput(); // Output port 0
77  vtkUnstructuredGrid *GetBladeOutput(); // Output port 1
78  vtkStructuredGrid *GetGroundOutput(); // Output port 2
80 
82 
85  int GetNumberOfPointArrays();
86  const char* GetPointArrayName(int index);
88 
89  int GetPointArrayStatus(const char* name);
90  void SetPointArrayStatus(const char* name, int status);
91 
92  void DisableAllPointArrays();
93  void EnableAllPointArrays();
94 
95 protected:
98 
99  char* Filename; // Base file name
100  FILE* FilePtr; // Open file pointer
101 
102  int Rank; // Number of this processor
103  int TotalRank; // Number of processors
104 
105  // Extent information
106  vtkIdType NumberOfTuples; // Number of tuples in subextent
107 
108  // Field
109  int WholeExtent[6]; // Extents of entire grid
110  int SubExtent[6]; // Processor grid extent
111  int UpdateExtent[6];
112  int Dimension[3]; // Size of entire grid
113  int SubDimension[3]; // Size of processor grid
114 
115  // Ground
116  int GExtent[6]; // Extents of ground grid
117  int GSubExtent[6]; // Processor grid extent
118  int GDimension[3]; // Size of ground grid
119 
120  float Step[3]; // Spacing delta
121  int UseTopographyFile; // Topography or flat
122  vtkStdString TopographyFile; // Name of topography data file
123  vtkPoints* Points; // Structured grid geometry
124  vtkPoints* GPoints; // Structured grid geometry for ground
125  vtkPoints* BPoints; // Unstructured grid geometry
126  float Compression; // Stretching at Z surface [0,1]
127  float Fit; // Cubic or quadratic [0,1]
128 
129  // Rectilinear coordinate spacing
134  float zMinValue;
135 
136  // Variable information
137  int NumberOfFileVariables; // Number of variables in data file
138  int NumberOfDerivedVariables; // Number of variables derived from file
139  int NumberOfVariables; // Number of variables to display
140 
141  vtkStringArray* DivideVariables; // Divide data by density at read
142  vtkStdString* VariableName; // Names of each variable
143  int* VariableStruct; // SCALAR or VECTOR
144  int* VariableCompSize; // Number of components
145  int* VariableBasicType; // FLOAT or INTEGER
146  int* VariableByteCount; // Number of bytes in basic type
147  long int* VariableOffset; // Offset into data file
148  int BlockSize; // Size of every data block
149  int GBlockSize; // Size of every data block
150 
151  vtkFloatArray** data; // Actual data arrays
152  vtkStdString RootDirectory; // Directory where the .wind file is.
153  vtkStdString DataDirectory; // Location of actual data
154  vtkStdString DataBaseName; // Base name of files
155 
156  // Time step information
157  int NumberOfTimeSteps; // Number of time steps
158  int TimeStepFirst; // First time step
159  int TimeStepLast; // Last time step
160  int TimeStepDelta; // Delta on time steps
161  double* TimeSteps; // Actual times available for request
162 
163  // Turbine information
164  int NumberOfBladeTowers; // Number of turbines
165  int NumberOfBladePoints; // Points for drawing parts of blades
166  int NumberOfBladeCells; // Turbines * Blades * Parts
167 
168  vtkFloatArray* XPosition; // Location of tower
169  vtkFloatArray* YPosition; // Location of tower
170  vtkFloatArray* HubHeight; // Height of tower
171  vtkIntArray* BladeCount; // Number of blades per tower
172 
173  int UseTurbineFile; // Turbine data available
174  vtkStdString TurbineDirectory; // Turbine unstructured data
175  vtkStdString TurbineTowerName; // Name of tower file
176  vtkStdString TurbineBladeName; // Base name of time series blade data
177 
178  // Selected field of interest
180 
181  // Observer to modify this object when array selections are modified
183 
184  // Controlls initializing and querrying MPI
186 
187  // Read the header file describing the dataset
188  void ReadGlobalData();
189  void ReadDataVariables(ifstream& inStr);
190  void FindVariableOffsets();
191 
192  // Turbine methods
193  void SetupBladeData();
194  void LoadBladeData(int timeStep);
195 
196  // Calculate the coordinates
197  void FillCoordinates();
198  void FillGroundCoordinates();
199  void CreateCoordinates();
200  void CreateZTopography(float* zdata);
201  float GDeform(float sigma, float sigmaMax, int flag);
202  void spline(float* x, float* y, int n, float yp1, float ypn, float* y2);
203  void splint(float* xa, float* ya, float* y2a, int n, float x, float* y, int);
204 
205  // Load a variable from data file
206  void LoadVariableData(int var);
207 
208  // Variables which must be divided by density after being read from file
209  void DivideByDensity(const char* name);
210 
211  // Calculate derived variables
212  void CalculateVorticity(int vort, int uvw, int density);
213  void CalculatePressure(int pres, int prespre, int tempg, int density);
214 
215  virtual int RequestData(
216  vtkInformation* request,
217  vtkInformationVector** inputVector,
218  vtkInformationVector* outputVector);
219 
220  virtual int RequestInformation(
221  vtkInformation* request,
222  vtkInformationVector** inputVector,
223  vtkInformationVector* outputVector);
224 
225  static void SelectionCallback(
226  vtkObject *caller,
227  unsigned long eid,
228  void *clientdata,
229  void *calldata);
230 
231  static void EventCallback(
232  vtkObject* caller,
233  unsigned long eid,
234  void* clientdata, void* calldata);
235 
236  virtual int FillOutputPortInformation(int, vtkInformation*);
237 
238 private:
239  vtkWindBladeReader(const vtkWindBladeReader&); // Not implemented.
240  void operator=(const vtkWindBladeReader&); // Not implemented.
241 };
242 #endif
243