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 =========================================================================*/
32 #ifndef __vtkWindBladeReader_h
33 #define __vtkWindBladeReader_h
34 
35 
36 #include "vtkIOParallelModule.h" // For export macro
38 
39 class vtkWindBladeReaderPiece;
41 class vtkCallbackCommand;
43 class vtkStringArray;
44 class vtkFloatArray;
45 class vtkIntArray;
46 class vtkPoints;
47 class vtkStructuredGrid;
49 class vtkMultiBlockDataSetAglorithm;
51 class WindBladeReaderInternal;
52 
53 class VTKIOPARALLEL_EXPORT vtkWindBladeReader : public vtkStructuredGridAlgorithm
54 {
55 public:
56  static vtkWindBladeReader *New();
58  void PrintSelf(ostream& os, vtkIndent indent);
59 
60  vtkSetStringMacro(Filename);
61  vtkGetStringMacro(Filename);
62 
63  vtkSetVector6Macro(WholeExtent, int);
64  vtkGetVector6Macro(WholeExtent, int);
65 
66  vtkSetVector6Macro(SubExtent, int);
67  vtkGetVector6Macro(SubExtent, int);
68 
70 
71  vtkStructuredGrid *GetFieldOutput(); // Output port 0
72  vtkUnstructuredGrid *GetBladeOutput(); // Output port 1
73  vtkStructuredGrid *GetGroundOutput(); // Output port 2
75 
77 
80  int GetNumberOfPointArrays();
81  const char* GetPointArrayName(int index);
83 
84  int GetPointArrayStatus(const char* name);
85  void SetPointArrayStatus(const char* name, int status);
86 
87  void DisableAllPointArrays();
88  void EnableAllPointArrays();
89 
91 
95  virtual int ProcessRequest(vtkInformation *request,
96  vtkInformationVector **inInfo,
97  vtkInformationVector *outInfo);
99 
100 protected:
103 
104  char* Filename; // Base file name
105 
106  int Rank; // Number of this processor
107  int TotalRank; // Number of processors
108 
109  // Extent information
110  vtkIdType NumberOfTuples; // Number of tuples in subextent
111 
112  // Field
113  int WholeExtent[6]; // Extents of entire grid
114  int SubExtent[6]; // Processor grid extent
115  int UpdateExtent[6];
116  int Dimension[3]; // Size of entire grid
117  int SubDimension[3]; // Size of processor grid
118 
119  // Ground
120  int GExtent[6]; // Extents of ground grid
121  int GSubExtent[6]; // Processor grid extent
122  int GDimension[3]; // Size of ground grid
123 
124  float Step[3]; // Spacing delta
125  int UseTopographyFile; // Topography or flat
126  vtkStdString TopographyFile; // Name of topography data file
127  vtkPoints* Points; // Structured grid geometry
128  vtkPoints* GPoints; // Structured grid geometry for ground
129  vtkPoints* BPoints; // Unstructured grid geometry
130  float Compression; // Stretching at Z surface [0,1]
131  float Fit; // Cubic or quadratic [0,1]
132 
133  // Rectilinear coordinate spacing
138  float ZMinValue;
139 
140  // Variable information
141  int NumberOfFileVariables; // Number of variables in data file
142  int NumberOfDerivedVariables; // Number of variables derived from file
143  int NumberOfVariables; // Number of variables to display
144 
145  vtkStringArray* DivideVariables; // Divide data by density at read
146  vtkStdString* VariableName; // Names of each variable
147  int* VariableStruct; // SCALAR or VECTOR
148  int* VariableCompSize; // Number of components
149  int* VariableBasicType; // FLOAT or INTEGER
150  int* VariableByteCount; // Number of bytes in basic type
151  long int* VariableOffset; // Offset into data file
152  unsigned int BlockSize; // Size of every data block
153  int GBlockSize; // Size of every data block
154 
155  vtkFloatArray** Data; // Actual data arrays
156  vtkStdString RootDirectory; // Directory where the .wind file is.
157  vtkStdString DataDirectory; // Location of actual data
158  vtkStdString DataBaseName; // Base name of files
159 
160  // Time step information
161  int NumberOfTimeSteps; // Number of time steps
162  int TimeStepFirst; // First time step
163  int TimeStepLast; // Last time step
164  int TimeStepDelta; // Delta on time steps
165  double* TimeSteps; // Actual times available for request
166 
167  // Turbine information
168  int NumberOfBladeTowers; // Number of turbines
169  int NumberOfBladePoints; // Points for drawing parts of blades
170  int NumberOfBladeCells; // Turbines * Blades * Parts
171 
172  vtkFloatArray* XPosition; // Location of tower
173  vtkFloatArray* YPosition; // Location of tower
174  vtkFloatArray* HubHeight; // Height of tower
175  vtkFloatArray* AngularVeloc; // Angular Velocity
176  vtkFloatArray* BladeLength; // Blade length
177  vtkIntArray* BladeCount; // Number of blades per tower
178 
179  int UseTurbineFile; // Turbine data available
180  vtkStdString TurbineDirectory; // Turbine unstructured data
181  vtkStdString TurbineTowerName; // Name of tower file
182  vtkStdString TurbineBladeName; // Base name of time series blade data
183  int NumberOfLinesToSkip; // New format has lines that need to be skipped in
184  // blade files
185 
186  // Selected field of interest
188 
189  // Observer to modify this object when array selections are modified
191 
192  // Controls initializing and querrying MPI
194 
195  // Read the header file describing the dataset
196  bool ReadGlobalData();
197  void ReadDataVariables(istream& inStr);
198  bool FindVariableOffsets();
199 
200  // Turbine methods
201  void SetupBladeData();
202  void LoadBladeData(int timeStep);
203 
204  // Calculate the coordinates
205  void FillCoordinates();
206  void FillGroundCoordinates();
207  void CreateCoordinates();
208  void CreateZTopography(float* zdata);
209  float GDeform(float sigma, float sigmaMax, int flag);
210  void Spline(float* x, float* y, int n, float yp1, float ypn, float* y2);
211  void Splint(float* xa, float* ya, float* y2a, int n, float x, float* y, int);
212 
213  // Load a variable from data file
214  void LoadVariableData(int var);
215 
216  // Variables which must be divided by density after being read from file
217  void DivideByDensity(const char* name);
218 
219  // Calculate derived variables
220  void CalculateVorticity(int vort, int uvw, int density);
221  void CalculatePressure(int pres, int prespre, int tempg, int density);
222 
223  virtual int RequestData(
224  vtkInformation* request,
225  vtkInformationVector** inputVector,
226  vtkInformationVector* outputVector);
227 
228  virtual int RequestInformation(
229  vtkInformation* request,
230  vtkInformationVector** inputVector,
231  vtkInformationVector* outputVector);
232 
233  static void SelectionCallback(
234  vtkObject *caller,
235  unsigned long eid,
236  void *clientdata,
237  void *calldata);
238 
239  static void EventCallback(
240  vtkObject* caller,
241  unsigned long eid,
242  void* clientdata, void* calldata);
243 
244  virtual int FillOutputPortInformation(int, vtkInformation*);
245 
246  WindBladeReaderInternal * Internal;
247 
248 private:
249  vtkWindBladeReader(const vtkWindBladeReader&); // Not implemented.
250  void operator=(const vtkWindBladeReader&); // Not implemented.
251 };
252 #endif
253