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:
56  void PrintSelf(ostream& os, vtkIndent indent);
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 
81  const char* GetPointArrayName(int index);
83 
84  int GetPointArrayStatus(const char* name);
85  void SetPointArrayStatus(const char* name, int status);
86 
89 
90 protected:
91 
92  static float DRY_AIR_CONSTANT;
93  static int NUM_PART_SIDES; // Blade parts rhombus
94  const static int NUM_BASE_SIDES; // Base pyramid
95  const static 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 
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
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
222  std::ostringstream &fileName,
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 
243  virtual int RequestData(
244  vtkInformation* request,
245  vtkInformationVector** inputVector,
246  vtkInformationVector* outputVector);
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 
260 
268  vtkInformationVector **inInfo,
269  vtkInformationVector *outInfo);
270 
271 private:
272  WindBladeReaderInternal * Internal;
273 
274  vtkWindBladeReader(const vtkWindBladeReader&) VTK_DELETE_FUNCTION;
275  void operator=(const vtkWindBladeReader&) VTK_DELETE_FUNCTION;
276 };
277 #endif
supports function callbacks
Store on/off settings for data arrays for a vtkSource.
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:42
a simple class to control print indentation
Definition: vtkIndent.h:40
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:46
abstract base class for most VTK objects
Definition: vtkObject.h:60
represent and manipulate 3D points
Definition: vtkPoints.h:40
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:49
a vtkAbstractArray subclass for strings
Superclass for algorithms that produce only structured grid as output.
topologically regular array of data
dataset represents arbitrary combinations of all possible cell types
class for reading WindBlade data files
vtkStdString TopographyFile
vtkCallbackCommand * SelectionObserver
void SetPointArrayStatus(const char *name, int status)
static void EventCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
vtkIntArray * BladeCount
int GetNumberOfPointArrays()
The following methods allow selective reading of solutions fields.
vtkFloatArray * HubHeight
vtkFloatArray * XSpacing
float GDeform(float sigma, float sigmaMax, int flag)
void ProcessZCoords(float *topoData, float *zValues)
void Spline(float *x, float *y, int n, float yp1, float ypn, float *y2)
virtual bool FindVariableOffsets()
void SetUpGroundData(vtkInformationVector *outVector)
vtkStdString DataDirectory
void ReadDataVariables(istream &inStr)
vtkFloatArray * ZSpacing
vtkFloatArray * BladeLength
vtkStdString * VariableName
int ProcessRequest(vtkInformation *request, vtkInformationVector **inInfo, vtkInformationVector *outInfo)
We intercept the requests to check for which port information is being requested for and if there is ...
vtkFloatArray * YPosition
vtkUnstructuredGrid * GetBladeOutput()
vtkStdString TurbineTowerName
vtkFloatArray * AngularVeloc
virtual void CreateZTopography(float *zdata)
void ReadBladeData(std::stringstream &inStr)
virtual void CalculatePressure(int pres, int prespre, int tempg, int density)
void SetUpFieldVars(vtkStructuredGrid *field)
void InitBladeData(vtkInformationVector *outVector)
static const int LINE_SIZE
void EnableAllPointArrays()
int GetPointArrayStatus(const char *name)
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
vtkFloatArray ** Data
static void SelectionCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
static float DRY_AIR_CONSTANT
vtkStdString TurbineBladeName
vtkStdString RootDirectory
vtkStringArray * DivideVariables
virtual bool ReadGlobalData()
void InitPressureData(int pressure, int prespre, float *&pressureData, float *&prespreData)
vtkStructuredGrid * GetFieldOutput()
Get the reader's output.
const char * GetPointArrayName(int index)
void Splint(float *xa, float *ya, float *y2a, int n, float x, float *y, int)
virtual void CalculateVorticity(int vort, int uvw, int density)
void InitFieldData(vtkInformationVector *outVector, std::ostringstream &fileName, vtkStructuredGrid *field)
void InitVariableData(int var, int &numberOfComponents, float *&varData, int &planeSize, int &rowSize)
virtual void LoadVariableData(int var)
virtual void SetupBladeData()
vtkFloatArray * YSpacing
vtkStdString TurbineDirectory
vtkFloatArray * XPosition
virtual void LoadBladeData(int timeStep)
void SetUpVorticityData(float *uData, float *vData, const float *densityData, float *vortData)
static const int NUM_BASE_SIDES
bool SetUpGlobalData(const std::string &fileName, std::stringstream &inStr)
void DisableAllPointArrays()
void SetUpPressureData(float *pressureData, float *prespreData, const float *tempgData, const float *densityData)
vtkDataArraySelection * PointDataArraySelection
void DivideByDensity(const char *name)
static vtkWindBladeReader * New()
virtual int FillOutputPortInformation(int, vtkInformation *)
Fill the output port information objects for this algorithm.
void ReadBladeHeader(const std::string &fileName, std::stringstream &inStr, int &numColumns)
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkStructuredGrid * GetGroundOutput()
void FillGroundCoordinates()
@ field
Definition: vtkX3D.h:177
@ name
Definition: vtkX3D.h:219
@ index
Definition: vtkX3D.h:246
@ string
Definition: vtkX3D.h:490
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
int vtkIdType
Definition: vtkType.h:287