VTK  9.2.6
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  vtkSetFilePathMacro(Filename);
59  vtkGetFilePathMacro(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  static float DRY_AIR_CONSTANT;
92  static int NUM_PART_SIDES; // Blade parts rhombus
93  static const int NUM_BASE_SIDES; // Base pyramid
94  static const int LINE_SIZE;
95  static int DIMENSION;
96  static int BYTES_PER_DATA;
97  static int SCALAR;
98  static int VECTOR;
99  static int FLOAT;
100  static int INTEGER;
101 
103  ~vtkWindBladeReader() override;
104 
105  char* Filename; // Base file name
106 
107  // Extent information
108  vtkIdType NumberOfTuples; // Number of tuples in subextent
109 
110  // Field
111  int WholeExtent[6]; // Extents of entire grid
112  int SubExtent[6]; // Processor grid extent
113  int UpdateExtent[6];
114  int Dimension[3]; // Size of entire grid
115  int SubDimension[3]; // Size of processor grid
116 
117  // Ground
118  int GExtent[6]; // Extents of ground grid
119  int GSubExtent[6]; // Processor grid extent
120  int GDimension[3]; // Size of ground grid
121 
122  float Step[3]; // Spacing delta
123  int UseTopographyFile; // Topography or flat
124  vtkStdString TopographyFile; // Name of topography data file
125  vtkPoints* Points; // Structured grid geometry
126  vtkPoints* GPoints; // Structured grid geometry for ground
127  vtkPoints* BPoints; // Unstructured grid geometry
128  float Compression; // Stretching at Z surface [0,1]
129  float Fit; // Cubic or quadratic [0,1]
130 
131  // Rectilinear coordinate spacing
136  float ZMinValue;
137 
138  // Variable information
139  int NumberOfFileVariables; // Number of variables in data file
140  int NumberOfDerivedVariables; // Number of variables derived from file
141  int NumberOfVariables; // Number of variables to display
142 
143  vtkStringArray* DivideVariables; // Divide data by density at read
144  vtkStdString* VariableName; // Names of each variable
145  int* VariableStruct; // SCALAR or VECTOR
146  int* VariableCompSize; // Number of components
147  int* VariableBasicType; // FLOAT or INTEGER
148  int* VariableByteCount; // Number of bytes in basic type
149  long int* VariableOffset; // Offset into data file
150  size_t BlockSize; // Size of every data block
151  size_t GBlockSize; // Size of every data block
152 
153  vtkFloatArray** Data; // Actual data arrays
154  vtkStdString RootDirectory; // Directory where the .wind file is.
155  vtkStdString DataDirectory; // Location of actual data
156  vtkStdString DataBaseName; // Base name of files
157 
158  // Time step information
159  int NumberOfTimeSteps; // Number of time steps
160  int TimeStepFirst; // First time step
161  int TimeStepLast; // Last time step
162  int TimeStepDelta; // Delta on time steps
163  double* TimeSteps; // Actual times available for request
164 
165  // Turbine information
166  int NumberOfBladeTowers; // Number of turbines
167  int NumberOfBladePoints; // Points for drawing parts of blades
168  int NumberOfBladeCells; // Turbines * Blades * Parts
169 
170  vtkFloatArray* XPosition; // Location of tower
171  vtkFloatArray* YPosition; // Location of tower
172  vtkFloatArray* HubHeight; // Height of tower
173  vtkFloatArray* AngularVeloc; // Angular Velocity
174  vtkFloatArray* BladeLength; // Blade length
175  vtkIntArray* BladeCount; // Number of blades per tower
176 
177  int UseTurbineFile; // Turbine data available
178  vtkStdString TurbineDirectory; // Turbine unstructured data
179  vtkStdString TurbineTowerName; // Name of tower file
180  vtkStdString TurbineBladeName; // Base name of time series blade data
181  int NumberOfLinesToSkip; // New format has lines that need to be skipped in
182  // blade files
183 
184  // Selected field of interest
186 
187  // Observer to modify this object when array selections are modified
189 
190  // Read the header file describing the dataset
191  virtual bool ReadGlobalData();
192  void ReadDataVariables(istream& inStr);
193  virtual bool FindVariableOffsets();
194 
195  // Turbine methods
196  virtual void SetupBladeData();
197  virtual void LoadBladeData(int timeStep);
198 
199  // Calculate the coordinates
200  void FillCoordinates();
201  void FillGroundCoordinates();
202  void CreateCoordinates();
203  virtual void CreateZTopography(float* zdata);
204  float GDeform(float sigma, float sigmaMax, int flag);
205  void Spline(float* x, float* y, int n, float yp1, float ypn, float* y2);
206  void Splint(float* xa, float* ya, float* y2a, int n, float x, float* y, int);
207 
208  // Load a variable from data file
209  virtual void LoadVariableData(int var);
210 
211  // Variables which must be divided by density after being read from file
212  void DivideByDensity(const char* name);
213 
214  // Calculate derived variables
215  virtual void CalculatePressure(int pres, int prespre, int tempg, int density);
216  virtual void CalculateVorticity(int vort, int uvw, int density);
217 
218  // convenience functions shared between serial and parallel version
219  void InitFieldData(
220  vtkInformationVector* outVector, std::ostringstream& fileName, vtkStructuredGrid* field);
221  void SetUpFieldVars(vtkStructuredGrid* field);
222  void InitBladeData(vtkInformationVector* outVector);
223  void SetUpGroundData(vtkInformationVector* outVector);
224  void InitPressureData(int pressure, int prespre, float*& pressureData, float*& prespreData);
225  void SetUpPressureData(
226  float* pressureData, float* prespreData, const float* tempgData, const float* densityData);
227  void SetUpVorticityData(float* uData, float* vData, const float* densityData, float* vortData);
228  void InitVariableData(
229  int var, int& numberOfComponents, float*& varData, int& planeSize, int& rowSize);
230  bool SetUpGlobalData(const std::string& fileName, std::stringstream& inStr);
231  void ProcessZCoords(float* topoData, float* zValues);
232  void ReadBladeHeader(const std::string& fileName, std::stringstream& inStr, int& numColumns);
233  void ReadBladeData(std::stringstream& inStr);
234 
236  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
237  vtkInformationVector* outputVector) override;
238 
239  static void SelectionCallback(
240  vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
241 
242  static void EventCallback(vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
243 
244  int FillOutputPortInformation(int, vtkInformation*) override;
245 
253  vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outInfo) override;
254 
255 private:
256  WindBladeReaderInternal* Internal;
257 
258  vtkWindBladeReader(const vtkWindBladeReader&) = delete;
259  void operator=(const vtkWindBladeReader&) = delete;
260 };
261 #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.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:38
vtkFloatArray ** Data
abstract base class for most VTK objects
Definition: vtkObject.h:62
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:332
vtkStdString RootDirectory
static const int LINE_SIZE
vtkFloatArray * HubHeight
static vtkStructuredGridAlgorithm * New()
int vtkTypeBool
Definition: vtkABI.h:69
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, etc.
Superclass for algorithms that produce only structured grid as output.
dataset represents arbitrary combinations of all possible cell types
vtkStringArray * DivideVariables
vtkStdString TurbineTowerName
vtkTypeBool ProcessRequest(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
see vtkAlgorithm for details
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