VTK  9.0.1
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 =========================================================================*/
77 #ifndef vtkMPASReader_h
78 #define vtkMPASReader_h
79 
80 #include "vtkIONetCDFModule.h" // For export macro
82 
83 #include <string> // for std::string
84 
85 class vtkCallbackCommand;
87 class vtkDoubleArray;
88 class vtkStdString;
89 class vtkStringArray;
90 
91 class VTKIONETCDF_EXPORT vtkMPASReader : public vtkUnstructuredGridAlgorithm
92 {
93 public:
94  static vtkMPASReader* New();
96  void PrintSelf(ostream& os, vtkIndent indent) override;
97 
99 
102  vtkSetStringMacro(FileName);
103  vtkGetStringMacro(FileName);
105 
107 
110  vtkGetMacro(MaximumCells, int);
112 
114 
117  vtkGetMacro(MaximumPoints, int);
119 
121 
124  virtual int GetNumberOfCellVars();
125  virtual int GetNumberOfPointVars();
127 
129 
135 
137 
143  vtkSetMacro(UseDimensionedArrayNames, bool);
144  vtkGetMacro(UseDimensionedArrayNames, bool);
145  vtkBooleanMacro(UseDimensionedArrayNames, bool);
147 
149 
154  int GetNumberOfPointArrays();
155  const char* GetPointArrayName(int index);
156  int GetPointArrayStatus(const char* name);
157  void SetPointArrayStatus(const char* name, int status);
158  void DisableAllPointArrays();
159  void EnableAllPointArrays();
161 
162  int GetNumberOfCellArrays();
163  const char* GetCellArrayName(int index);
164  int GetCellArrayStatus(const char* name);
165  void SetCellArrayStatus(const char* name, int status);
166  void DisableAllCellArrays();
167  void EnableAllCellArrays();
168 
170 
178  vtkIdType GetNumberOfDimensions();
179  std::string GetDimensionName(int idx);
180  vtkStringArray* GetAllDimensions();
181  int GetDimensionCurrentIndex(const std::string& dim);
182  void SetDimensionCurrentIndex(const std::string& dim, int idx);
183  int GetDimensionSize(const std::string& dim);
185 
187 
191  vtkSetMacro(VerticalDimension, std::string);
192  vtkGetMacro(VerticalDimension, std::string);
194 
196 
200  void SetVerticalLevel(int level);
201  int GetVerticalLevel();
203 
204  vtkGetVector2Macro(VerticalLevelRange, int);
205 
206  vtkSetMacro(LayerThickness, int);
207  vtkGetMacro(LayerThickness, int);
208  vtkGetVector2Macro(LayerThicknessRange, int);
209 
210  void SetCenterLon(int val);
211  vtkGetVector2Macro(CenterLonRange, int);
212 
213  vtkSetMacro(ProjectLatLon, bool);
214  vtkGetMacro(ProjectLatLon, bool);
215 
216  vtkSetMacro(IsAtmosphere, bool);
217  vtkGetMacro(IsAtmosphere, bool);
218 
219  vtkSetMacro(IsZeroCentered, bool);
220  vtkGetMacro(IsZeroCentered, bool);
221 
222  vtkSetMacro(ShowMultilayerView, bool);
223  vtkGetMacro(ShowMultilayerView, bool);
224 
228  static int CanReadFile(const char* filename);
229 
230  vtkMTimeType GetMTime() override;
231 
232 protected:
233  vtkMPASReader();
234  ~vtkMPASReader() override;
235  void ReleaseNcData();
236  void DestroyData();
237 
238  char* FileName; // First field part file giving path
239 
240  size_t NumberOfTimeSteps; // Temporal domain
241  double DTime; // The current time
242 
243  // Observer to modify this object when array selections are modified
245 
248 
249  static void SelectionCallback(
250  vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
251 
252  // Selected field of interest
255 
260  void UpdateDimensions(bool force = false);
261 
263  int VerticalLevelRange[2];
264 
266  int LayerThicknessRange[2];
267 
269  int CenterLonRange[2];
270 
272  {
275  Planar
276  };
277 
279 
280  bool ProjectLatLon; // User option
281  bool OnASphere; // Data file attribute
285 
287  bool DoBugFix;
288  double CenterRad;
289 
291 
292  // geometry
297  size_t PointOffset;
299  size_t CurrentExtraPoint; // current extra point
300  size_t CurrentExtraCell; // current extra cell
301  double* PointX; // x coord of point
302  double* PointY; // y coord of point
303  double* PointZ; // z coord of point
304  size_t ModNumPoints;
305  size_t ModNumCells;
306  int* OrigConnections; // original connections
307  int* ModConnections; // modified connections
308  size_t* CellMap; // maps from added cell to original cell #
309  size_t* PointMap; // maps from added point to original point #
311  int MaximumCells; // max cells
312  int MaximumPoints; // max points
313 
314  void SetDefaults();
315  int GetNcDims();
316  int GetNcAtts();
317  int CheckParams();
318  int GetNcVars(const char* cellDimName, const char* pointDimName);
319  int ReadAndOutputGrid();
320  int BuildVarArrays();
321  int AllocSphericalGeometry();
322  int AllocProjectedGeometry();
323  int AllocPlanarGeometry();
324  void ShiftLonData();
325  int AddMirrorPoint(int index, double dividerX, double offset);
326  void FixPoints();
327  int EliminateXWrap();
328  void OutputPoints();
329  void OutputCells();
330  unsigned char GetCellType();
331 
332  vtkDataArray* LoadPointVarData(int variable);
333  vtkDataArray* LoadCellVarData(int variable);
334  vtkDataArray* LookupPointDataArray(int varIdx);
335  vtkDataArray* LookupCellDataArray(int varIdx);
336 
345  void LoadTimeFieldData(vtkUnstructuredGrid* dataset);
346 
347 private:
348  vtkMPASReader(const vtkMPASReader&) = delete;
349  void operator=(const vtkMPASReader&) = delete;
350 
351  class Internal;
352  Internal* Internals;
353 };
354 
355 #endif
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:34
GeometryType Geometry
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
size_t PointsPerCell
size_t ModNumPoints
abstract base class for most VTK objects
Definition: vtkObject.h:62
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:293
size_t * CellMap
size_t NumberOfTimeSteps
static vtkUnstructuredGridAlgorithm * New()
size_t PointOffset
double * PointZ
a vtkAbstractArray subclass for strings
bool IncludeTopography
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
size_t CurrentExtraPoint
int * OrigConnections
int vtkIdType
Definition: vtkType.h:338
vtkDataArraySelection * PointDataArraySelection
Read an MPAS netCDF file.
Definition: vtkMPASReader.h:91
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:33
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:49
virtual vtkMTimeType GetMTime()
Return this object&#39;s modified time.
size_t NumberOfPoints
size_t CurrentExtraCell
Superclass for algorithms that produce only unstructured grid as output.
std::string VerticalDimension
size_t MaximumNVertLevels
vtkCallbackCommand * SelectionObserver
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
vtkDataArraySelection * CellDataArraySelection
size_t NumberOfCells
size_t * PointMap
bool ShowMultilayerView