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 =========================================================================*/
30 #ifndef vtkWindBladeReader_h
31 #define vtkWindBladeReader_h
32 
33 #include "vtkIOGeometryModule.h" // For export macro
35 
37 class vtkCallbackCommand;
38 class vtkStringArray;
39 class vtkFloatArray;
40 class vtkIntArray;
41 class vtkPoints;
42 class vtkStructuredGrid;
44 class vtkMultiBlockDataSetAglorithm;
46 class WindBladeReaderInternal;
47 
48 class VTKIOGEOMETRY_EXPORT vtkWindBladeReader : public vtkStructuredGridAlgorithm
49 {
50 public:
51  static vtkWindBladeReader *New();
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
55  vtkSetStringMacro(Filename);
56  vtkGetStringMacro(Filename);
57 
58  vtkSetVector6Macro(WholeExtent, int);
59  vtkGetVector6Macro(WholeExtent, int);
60 
61  vtkSetVector6Macro(SubExtent, int);
62  vtkGetVector6Macro(SubExtent, int);
63 
67  vtkStructuredGrid *GetFieldOutput(); // Output port 0
68  vtkUnstructuredGrid *GetBladeOutput(); // Output port 1
69  vtkStructuredGrid *GetGroundOutput(); // Output port 2
70 
72 
77  int GetNumberOfPointArrays();
78  const char* GetPointArrayName(int index);
80 
81  int GetPointArrayStatus(const char* name);
82  void SetPointArrayStatus(const char* name, int status);
83 
84  void DisableAllPointArrays();
85  void EnableAllPointArrays();
86 
87 protected:
88 
89  static float DRY_AIR_CONSTANT;
90  static int NUM_PART_SIDES; // Blade parts rhombus
91  static const int NUM_BASE_SIDES; // Base pyramid
92  static const int LINE_SIZE;
93  static int DIMENSION;
94  static int BYTES_PER_DATA;
95  static int SCALAR;
96  static int VECTOR;
97  static int FLOAT;
98  static int INTEGER;
99 
101  ~vtkWindBladeReader() override;
102 
103  char* Filename; // Base file name
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  size_t BlockSize; // Size of every data block
149  size_t 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  vtkFloatArray* AngularVeloc; // Angular Velocity
172  vtkFloatArray* BladeLength; // Blade length
173  vtkIntArray* BladeCount; // Number of blades per tower
174 
175  int UseTurbineFile; // Turbine data available
176  vtkStdString TurbineDirectory; // Turbine unstructured data
177  vtkStdString TurbineTowerName; // Name of tower file
178  vtkStdString TurbineBladeName; // Base name of time series blade data
179  int NumberOfLinesToSkip; // New format has lines that need to be skipped in
180  // blade files
181 
182  // Selected field of interest
184 
185  // Observer to modify this object when array selections are modified
187 
188 
189  // Read the header file describing the dataset
190  virtual bool ReadGlobalData();
191  void ReadDataVariables(istream& inStr);
192  virtual bool FindVariableOffsets();
193 
194  // Turbine methods
195  virtual void SetupBladeData();
196  virtual void LoadBladeData(int timeStep);
197 
198  // Calculate the coordinates
199  void FillCoordinates();
200  void FillGroundCoordinates();
201  void CreateCoordinates();
202  virtual void CreateZTopography(float* zdata);
203  float GDeform(float sigma, float sigmaMax, int flag);
204  void Spline(float* x, float* y, int n, float yp1, float ypn, float* y2);
205  void Splint(float* xa, float* ya, float* y2a, int n, float x, float* y, int);
206 
207  // Load a variable from data file
208  virtual void LoadVariableData(int var);
209 
210  // Variables which must be divided by density after being read from file
211  void DivideByDensity(const char* name);
212 
213  // Calculate derived variables
214  virtual void CalculatePressure(int pres, int prespre, int tempg, int density);
215  virtual void CalculateVorticity(int vort, int uvw, int density);
216 
217  // convenience functions shared between serial and parallel version
218  void InitFieldData(vtkInformationVector *outVector,
219  std::ostringstream &fileName,
221  void SetUpFieldVars(vtkStructuredGrid *field);
222  void InitBladeData(vtkInformationVector *outVector);
223  void SetUpGroundData(vtkInformationVector *outVector);
224  void InitPressureData(int pressure, int prespre,
225  float *&pressureData, float *&prespreData);
226  void SetUpPressureData(float* pressureData, float* prespreData,
227  const float* tempgData, const float* densityData);
228  void SetUpVorticityData(float* uData, float* vData, const float *densityData,
229  float* vortData);
230  void InitVariableData(int var, int &numberOfComponents, float *&varData,
231  int &planeSize, int &rowSize);
232  bool SetUpGlobalData(const std::string &fileName, std::stringstream& inStr);
233  void ProcessZCoords(float *topoData, float *zValues);
234  void ReadBladeHeader(const std::string &fileName, std::stringstream &inStr,
235  int &numColumns);
236  void ReadBladeData(std::stringstream &inStr);
237 
239  vtkInformationVector *) override;
240  int RequestData(
241  vtkInformation* request,
242  vtkInformationVector** inputVector,
243  vtkInformationVector* outputVector) override;
244 
245  static void SelectionCallback(
246  vtkObject *caller,
247  unsigned long eid,
248  void *clientdata,
249  void *calldata);
250 
251  static void EventCallback(
252  vtkObject* caller,
253  unsigned long eid,
254  void* clientdata, void* calldata);
255 
256  int FillOutputPortInformation(int, vtkInformation*) override;
257 
264  int ProcessRequest(vtkInformation *request,
265  vtkInformationVector **inInfo,
266  vtkInformationVector *outInfo) override;
267 
268 private:
269  WindBladeReaderInternal * Internal;
270 
271  vtkWindBladeReader(const vtkWindBladeReader&) = delete;
272  void operator=(const vtkWindBladeReader&) = delete;
273 };
274 #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:34
vtkFloatArray ** Data
abstract base class for most VTK objects
Definition: vtkObject.h:53
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:35
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
a vtkAbstractArray subclass for strings
int vtkIdType
Definition: vtkType.h:345
vtkStdString RootDirectory
static const int LINE_SIZE
vtkFloatArray * HubHeight
static vtkStructuredGridAlgorithm * New()
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
vtkFloatArray * BladeLength
supports function callbacks
vtkFloatArray * XPosition
vtkStdString * VariableName
a simple class to control print indentation
Definition: vtkIndent.h:33
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:33