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 =========================================================================*/
33 #ifndef vtkWindBladeReader_h
34 #define vtkWindBladeReader_h
35 
36 #include "vtkIOGeometryModule.h" // For export macro
38 
40 class vtkCallbackCommand;
41 class vtkStringArray;
42 class vtkFloatArray;
43 class vtkIntArray;
44 class vtkPoints;
45 class vtkStructuredGrid;
47 class vtkMultiBlockDataSetAglorithm;
49 class WindBladeReaderInternal;
50 
51 class VTKIOGEOMETRY_EXPORT vtkWindBladeReader : public vtkStructuredGridAlgorithm
52 {
53 public:
54  static vtkWindBladeReader *New();
56  void PrintSelf(ostream& os, vtkIndent indent) override;
57 
58  vtkSetStringMacro(Filename);
59  vtkGetStringMacro(Filename);
60 
61  vtkSetVector6Macro(WholeExtent, int);
62  vtkGetVector6Macro(WholeExtent, int);
63 
64  vtkSetVector6Macro(SubExtent, int);
65  vtkGetVector6Macro(SubExtent, int);
66 
70  vtkStructuredGrid *GetFieldOutput(); // Output port 0
71  vtkUnstructuredGrid *GetBladeOutput(); // Output port 1
72  vtkStructuredGrid *GetGroundOutput(); // Output port 2
73 
75 
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 
90 protected:
91 
92  static float DRY_AIR_CONSTANT;
93  static int NUM_PART_SIDES; // Blade parts rhombus
94  static const int NUM_BASE_SIDES; // Base pyramid
95  static const int LINE_SIZE;
96  static int DIMENSION;
97  static int BYTES_PER_DATA;
98  static int SCALAR;
99  static int VECTOR;
100  static int FLOAT;
101  static int INTEGER;
102 
104  ~vtkWindBladeReader() override;
105 
106  char* Filename; // Base file name
107 
108  // Extent information
109  vtkIdType NumberOfTuples; // Number of tuples in subextent
110 
111  // Field
112  int WholeExtent[6]; // Extents of entire grid
113  int SubExtent[6]; // Processor grid extent
114  int UpdateExtent[6];
115  int Dimension[3]; // Size of entire grid
116  int SubDimension[3]; // Size of processor grid
117 
118  // Ground
119  int GExtent[6]; // Extents of ground grid
120  int GSubExtent[6]; // Processor grid extent
121  int GDimension[3]; // Size of ground grid
122 
123  float Step[3]; // Spacing delta
124  int UseTopographyFile; // Topography or flat
125  vtkStdString TopographyFile; // Name of topography data file
126  vtkPoints* Points; // Structured grid geometry
127  vtkPoints* GPoints; // Structured grid geometry for ground
128  vtkPoints* BPoints; // Unstructured grid geometry
129  float Compression; // Stretching at Z surface [0,1]
130  float Fit; // Cubic or quadratic [0,1]
131 
132  // Rectilinear coordinate spacing
137  float ZMinValue;
138 
139  // Variable information
140  int NumberOfFileVariables; // Number of variables in data file
141  int NumberOfDerivedVariables; // Number of variables derived from file
142  int NumberOfVariables; // Number of variables to display
143 
144  vtkStringArray* DivideVariables; // Divide data by density at read
145  vtkStdString* VariableName; // Names of each variable
146  int* VariableStruct; // SCALAR or VECTOR
147  int* VariableCompSize; // Number of components
148  int* VariableBasicType; // FLOAT or INTEGER
149  int* VariableByteCount; // Number of bytes in basic type
150  long int* VariableOffset; // Offset into data file
151  size_t BlockSize; // Size of every data block
152  size_t GBlockSize; // Size of every data block
153 
154  vtkFloatArray** Data; // Actual data arrays
155  vtkStdString RootDirectory; // Directory where the .wind file is.
156  vtkStdString DataDirectory; // Location of actual data
157  vtkStdString DataBaseName; // Base name of files
158 
159  // Time step information
160  int NumberOfTimeSteps; // Number of time steps
161  int TimeStepFirst; // First time step
162  int TimeStepLast; // Last time step
163  int TimeStepDelta; // Delta on time steps
164  double* TimeSteps; // Actual times available for request
165 
166  // Turbine information
167  int NumberOfBladeTowers; // Number of turbines
168  int NumberOfBladePoints; // Points for drawing parts of blades
169  int NumberOfBladeCells; // Turbines * Blades * Parts
170 
171  vtkFloatArray* XPosition; // Location of tower
172  vtkFloatArray* YPosition; // Location of tower
173  vtkFloatArray* HubHeight; // Height of tower
174  vtkFloatArray* AngularVeloc; // Angular Velocity
175  vtkFloatArray* BladeLength; // Blade length
176  vtkIntArray* BladeCount; // Number of blades per tower
177 
178  int UseTurbineFile; // Turbine data available
179  vtkStdString TurbineDirectory; // Turbine unstructured data
180  vtkStdString TurbineTowerName; // Name of tower file
181  vtkStdString TurbineBladeName; // Base name of time series blade data
182  int NumberOfLinesToSkip; // New format has lines that need to be skipped in
183  // blade files
184 
185  // Selected field of interest
187 
188  // Observer to modify this object when array selections are modified
190 
191 
192  // Read the header file describing the dataset
193  virtual bool ReadGlobalData();
194  void ReadDataVariables(istream& inStr);
195  virtual bool FindVariableOffsets();
196 
197  // Turbine methods
198  virtual void SetupBladeData();
199  virtual void LoadBladeData(int timeStep);
200 
201  // Calculate the coordinates
202  void FillCoordinates();
203  void FillGroundCoordinates();
204  void CreateCoordinates();
205  virtual void CreateZTopography(float* zdata);
206  float GDeform(float sigma, float sigmaMax, int flag);
207  void Spline(float* x, float* y, int n, float yp1, float ypn, float* y2);
208  void Splint(float* xa, float* ya, float* y2a, int n, float x, float* y, int);
209 
210  // Load a variable from data file
211  virtual void LoadVariableData(int var);
212 
213  // Variables which must be divided by density after being read from file
214  void DivideByDensity(const char* name);
215 
216  // Calculate derived variables
217  virtual void CalculatePressure(int pres, int prespre, int tempg, int density);
218  virtual void CalculateVorticity(int vort, int uvw, int density);
219 
220  // convenience functions shared between serial and parallel version
221  void InitFieldData(vtkInformationVector *outVector,
222  std::ostringstream &fileName,
224  void SetUpFieldVars(vtkStructuredGrid *field);
225  void InitBladeData(vtkInformationVector *outVector);
226  void SetUpGroundData(vtkInformationVector *outVector);
227  void InitPressureData(int pressure, int prespre,
228  float *&pressureData, float *&prespreData);
229  void SetUpPressureData(float* pressureData, float* prespreData,
230  const float* tempgData, const float* densityData);
231  void SetUpVorticityData(float* uData, float* vData, const float *densityData,
232  float* vortData);
233  void InitVariableData(int var, int &numberOfComponents, float *&varData,
234  int &planeSize, int &rowSize);
235  bool SetUpGlobalData(const std::string &fileName, std::stringstream& inStr);
236  void ProcessZCoords(float *topoData, float *zValues);
237  void ReadBladeHeader(const std::string &fileName, std::stringstream &inStr,
238  int &numColumns);
239  void ReadBladeData(std::stringstream &inStr);
240 
242  vtkInformationVector *) override;
243  int RequestData(
244  vtkInformation* request,
245  vtkInformationVector** inputVector,
246  vtkInformationVector* outputVector) override;
247 
248  static void SelectionCallback(
249  vtkObject *caller,
250  unsigned long eid,
251  void *clientdata,
252  void *calldata);
253 
254  static void EventCallback(
255  vtkObject* caller,
256  unsigned long eid,
257  void* clientdata, void* calldata);
258 
259  int FillOutputPortInformation(int, vtkInformation*) override;
260 
267  int ProcessRequest(vtkInformation *request,
268  vtkInformationVector **inInfo,
269  vtkInformationVector *outInfo) override;
270 
271 private:
272  WindBladeReaderInternal * Internal;
273 
274  vtkWindBladeReader(const vtkWindBladeReader&) = delete;
275  void operator=(const vtkWindBladeReader&) = delete;
276 };
277 #endif
int FillOutputPortInformation(int port, vtkInformation *info) override
Fill the output port information objects for this algorithm.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
int ProcessRequest(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
see vtkAlgorithm for details
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:40
vtkFloatArray ** Data
abstract base class for most VTK objects
Definition: vtkObject.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static float DRY_AIR_CONSTANT
Store vtkAlgorithm input/output information.
vtkStdString TopographyFile
vtkFloatArray * XSpacing
vtkFloatArray * ZSpacing
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
a vtkAbstractArray subclass for strings
int vtkIdType
Definition: vtkType.h:347
vtkStdString RootDirectory
static const int LINE_SIZE
vtkFloatArray * HubHeight
static vtkStructuredGridAlgorithm * New()
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
vtkFloatArray * BladeLength
supports function callbacks
vtkFloatArray * XPosition
vtkStdString * VariableName
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkStdString TurbineBladeName
vtkIntArray * BladeCount
Store on/off settings for data arrays for a vtkSource.
Superclass for algorithms that produce only structured grid as output.
dataset represents arbitrary combinations of all possible cell types
vtkStringArray * DivideVariables
vtkStdString TurbineTowerName
vtkFloatArray * YPosition
vtkDataArraySelection * PointDataArraySelection
topologically regular array of data
vtkStdString DataDirectory
vtkStdString TurbineDirectory
Store zero or more vtkInformation instances.
vtkCallbackCommand * SelectionObserver
static const int NUM_BASE_SIDES
vtkFloatArray * YSpacing
vtkFloatArray * AngularVeloc
class for reading WindBlade data files
represent and manipulate 3D points
Definition: vtkPoints.h:39