VTK
vtkMPASReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMPASReader.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 =========================================================================*/
15 /*=========================================================================
16 
17 Copyright (c) 2002-2005 Los Alamos National Laboratory
18 
19 This software and ancillary information known as vtk_ext (and herein
20 called "SOFTWARE") is made available under the terms described below.
21 The SOFTWARE has been approved for release with associated LA_CC
22 Number 99-44, granted by Los Alamos National Laboratory in July 1999.
23 
24 Unless otherwise indicated, this SOFTWARE has been authored by an
25 employee or employees of the University of California, operator of the
26 Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with
27 the United States Department of Energy.
28 
29 The United States Government has rights to use, reproduce, and
30 distribute this SOFTWARE. The public may copy, distribute, prepare
31 derivative works and publicly display this SOFTWARE without charge,
32 provided that this Notice and any statement of authorship are
33 reproduced on all copies.
34 
35 Neither the U. S. Government, the University of California, nor the
36 Advanced Computing Laboratory makes any warranty, either express or
37 implied, nor assumes any liability or responsibility for the use of
38 this SOFTWARE.
39 
40 If SOFTWARE is modified to produce derivative works, such modified
41 SOFTWARE should be clearly marked, so as not to confuse it with the
42 version available from Los Alamos National Laboratory.
43 
44 =========================================================================*/
80 #ifndef vtkMPASReader_h
81 #define vtkMPASReader_h
82 
83 #include "vtkIONetCDFModule.h" // For export macro
85 
86 #include <string> // for std::string
87 
88 class vtkCallbackCommand;
90 class vtkDoubleArray;
91 class vtkStdString;
92 class vtkStringArray;
93 
94 class VTKIONETCDF_EXPORT vtkMPASReader : public vtkUnstructuredGridAlgorithm
95 {
96  public:
97  static vtkMPASReader *New();
99  void PrintSelf(ostream& os, vtkIndent indent) override;
100 
102 
105  vtkSetStringMacro(FileName);
106  vtkGetStringMacro(FileName);
108 
110 
113  vtkGetMacro(MaximumCells, int);
115 
117 
120  vtkGetMacro(MaximumPoints, int);
122 
124 
127  virtual int GetNumberOfCellVars();
128  virtual int GetNumberOfPointVars();
130 
132 
138 
140 
146  vtkSetMacro(UseDimensionedArrayNames, bool)
147  vtkGetMacro(UseDimensionedArrayNames, bool)
148  vtkBooleanMacro(UseDimensionedArrayNames, bool)
150 
152 
157  int GetNumberOfPointArrays();
158  const char* GetPointArrayName(int index);
159  int GetPointArrayStatus(const char* name);
160  void SetPointArrayStatus(const char* name, int status);
161  void DisableAllPointArrays();
162  void EnableAllPointArrays();
164 
165  int GetNumberOfCellArrays();
166  const char* GetCellArrayName(int index);
167  int GetCellArrayStatus(const char* name);
168  void SetCellArrayStatus(const char* name, int status);
169  void DisableAllCellArrays();
170  void EnableAllCellArrays();
171 
173 
181  vtkIdType GetNumberOfDimensions();
182  std::string GetDimensionName(int idx);
183  vtkStringArray* GetAllDimensions();
184  int GetDimensionCurrentIndex(const std::string &dim);
185  void SetDimensionCurrentIndex(const std::string &dim, int idx);
186  int GetDimensionSize(const std::string &dim);
188 
190 
194  vtkSetMacro(VerticalDimension, std::string)
195  vtkGetMacro(VerticalDimension, std::string)
197 
199 
203  void SetVerticalLevel(int level);
204  int GetVerticalLevel();
206 
207  vtkGetVector2Macro(VerticalLevelRange, int)
208 
209  vtkSetMacro(LayerThickness, int)
210  vtkGetMacro(LayerThickness, int)
211  vtkGetVector2Macro(LayerThicknessRange, int)
212 
213  void SetCenterLon(int val);
214  vtkGetVector2Macro(CenterLonRange, int)
215 
216  vtkSetMacro(ProjectLatLon, bool)
217  vtkGetMacro(ProjectLatLon, bool)
218 
219  vtkSetMacro(IsAtmosphere, bool)
220  vtkGetMacro(IsAtmosphere, bool)
221 
222  vtkSetMacro(IsZeroCentered, bool)
223  vtkGetMacro(IsZeroCentered, bool)
224 
225  vtkSetMacro(ShowMultilayerView, bool)
226  vtkGetMacro(ShowMultilayerView, bool)
227 
231  static int CanReadFile(const char *filename);
232 
233  vtkMTimeType GetMTime() override;
234 
235  protected:
236  vtkMPASReader();
237  ~vtkMPASReader() override;
238  void ReleaseNcData();
239  void DestroyData();
240 
241  char *FileName; // First field part file giving path
242 
243  size_t NumberOfTimeSteps; // Temporal domain
244  double DTime; // The current time
245 
246  // Observer to modify this object when array selections are modified
247  vtkCallbackCommand* SelectionObserver;
248 
249  int RequestData(vtkInformation *, vtkInformationVector **,
250  vtkInformationVector *) override;
251  int RequestInformation(vtkInformation *, vtkInformationVector **,
252  vtkInformationVector *) override;
253 
254 
255  static void SelectionCallback(vtkObject* caller, unsigned long eid,
256  void* clientdata, void* calldata);
257 
258  // Selected field of interest
259  vtkDataArraySelection* PointDataArraySelection;
260  vtkDataArraySelection* CellDataArraySelection;
261 
266  void UpdateDimensions(bool force = false);
267 
268  std::string VerticalDimension;
269  int VerticalLevelRange[2];
270 
271  int LayerThickness;
272  int LayerThicknessRange[2];
273 
274  int CenterLon;
275  int CenterLonRange[2];
276 
278  {
281  Planar
282  };
283 
285 
286  bool ProjectLatLon; // User option
287  bool OnASphere; // Data file attribute
291 
293  bool DoBugFix;
294  double CenterRad;
295 
297 
298  // geometry
303  size_t PointOffset;
305  size_t CurrentExtraPoint; // current extra point
306  size_t CurrentExtraCell; // current extra cell
307  double* PointX; // x coord of point
308  double* PointY; // y coord of point
309  double* PointZ; // z coord of point
310  size_t ModNumPoints;
311  size_t ModNumCells;
312  int* OrigConnections; // original connections
313  int* ModConnections; // modified connections
314  size_t* CellMap; // maps from added cell to original cell #
315  size_t* PointMap; // maps from added point to original point #
317  int MaximumCells; // max cells
318  int MaximumPoints; // max points
319 
320  void SetDefaults();
321  int GetNcDims();
322  int GetNcAtts();
323  int CheckParams();
324  int GetNcVars(const char* cellDimName, const char* pointDimName);
325  int ReadAndOutputGrid();
326  int BuildVarArrays();
327  int AllocSphericalGeometry();
328  int AllocProjectedGeometry();
329  int AllocPlanarGeometry();
330  void ShiftLonData();
331  int AddMirrorPoint(int index, double dividerX, double offset);
332  void FixPoints();
333  int EliminateXWrap();
334  void OutputPoints();
335  void OutputCells();
336  unsigned char GetCellType();
337 
338  vtkDataArray* LoadPointVarData(int variable);
339  vtkDataArray* LoadCellVarData(int variable);
340  vtkDataArray* LookupPointDataArray(int varIdx);
341  vtkDataArray* LookupCellDataArray(int varIdx);
342 
351  void LoadTimeFieldData(vtkUnstructuredGrid *dataset);
352 
353  private:
354  vtkMPASReader(const vtkMPASReader&) = delete;
355  void operator=(const vtkMPASReader&) = delete;
356 
357  class Internal;
358  Internal *Internals;
359 };
360 
361 #endif
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:40
GeometryType Geometry
size_t PointsPerCell
size_t ModNumPoints
abstract base class for most VTK objects
Definition: vtkObject.h:59
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
size_t * CellMap
static vtkUnstructuredGridAlgorithm * New()
size_t PointOffset
double * PointZ
a vtkAbstractArray subclass for strings
bool IncludeTopography
size_t CurrentExtraPoint
int * OrigConnections
int vtkIdType
Definition: vtkType.h:347
Read an MPAS netCDF file.
Definition: vtkMPASReader.h:94
dynamic, self-adjusting array of double
double * PointX
bool UseDimensionedArrayNames
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
supports function callbacks
double * PointY
a simple class to control print indentation
Definition: vtkIndent.h:39
Store on/off settings for data arrays for a vtkSource.
dataset represents arbitrary combinations of all possible cell types
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
size_t NumberOfPoints
size_t CurrentExtraCell
Superclass for algorithms that produce only unstructured grid as output.
size_t MaximumNVertLevels
Store zero or more vtkInformation instances.
int * MaximumLevelPoint
vtkUnstructuredGrid * GetOutput()
Get the output data object for a port on this algorithm.
int * ModConnections
size_t ModNumCells
size_t NumberOfCells
size_t * PointMap
bool ShowMultilayerView