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