VTK  9.7.1
vtkMPASReader.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright (c) 2002-2005 Los Alamos National Laboratory
3 // SPDX-License-Identifier: BSD-3-Clause-Sandia-LANL-California-USGov
39 #ifndef vtkMPASReader_h
40 #define vtkMPASReader_h
41 
42 #include "vtkIONetCDFModule.h" // For export macro
44 
45 #include <string> // for std::string
46 
47 VTK_ABI_NAMESPACE_BEGIN
48 class vtkCallbackCommand;
50 class vtkDoubleArray;
51 class vtkStringArray;
52 
53 class VTKIONETCDF_EXPORT vtkMPASReader : public vtkUnstructuredGridAlgorithm
54 {
55 public:
56  static vtkMPASReader* New();
58  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
61 
64  vtkSetFilePathMacro(FileName);
65  vtkGetFilePathMacro(FileName);
67 
69 
72  vtkGetMacro(MaximumCells, int);
74 
76 
79  vtkGetMacro(MaximumPoints, int);
81 
83 
86  virtual int GetNumberOfCellVars();
87  virtual int GetNumberOfPointVars();
89 
91 
97 
99 
105  vtkSetMacro(UseDimensionedArrayNames, bool);
106  vtkGetMacro(UseDimensionedArrayNames, bool);
107  vtkBooleanMacro(UseDimensionedArrayNames, bool);
109 
111 
121  int GetNumberOfPointArrays();
122  const char* GetPointArrayName(int index);
123  int GetPointArrayStatus(const char* name);
124  void SetPointArrayStatus(const char* name, int status);
125  void DisableAllPointArrays();
126  void EnableAllPointArrays();
128 
129  int GetNumberOfCellArrays();
130  const char* GetCellArrayName(int index);
131  int GetCellArrayStatus(const char* name);
132  void SetCellArrayStatus(const char* name, int status);
133  void DisableAllCellArrays();
134  void EnableAllCellArrays();
135 
137 
145  vtkIdType GetNumberOfDimensions();
146  std::string GetDimensionName(int idx);
147  vtkStringArray* GetAllDimensions();
148  int GetDimensionCurrentIndex(const std::string& dim);
149  void SetDimensionCurrentIndex(const std::string& dim, int idx);
150  int GetDimensionSize(const std::string& dim);
152 
154 
158  vtkSetMacro(VerticalDimension, std::string);
159  vtkGetMacro(VerticalDimension, std::string);
161 
163 
167  void SetVerticalLevel(int level);
168  int GetVerticalLevel();
170 
171  vtkGetVector2Macro(VerticalLevelRange, int);
172 
173  vtkSetMacro(LayerThickness, int);
174  vtkGetMacro(LayerThickness, int);
175  vtkGetVector2Macro(LayerThicknessRange, int);
176 
177  void SetCenterLon(int val);
178  vtkGetVector2Macro(CenterLonRange, int);
179 
180  vtkSetMacro(ProjectLatLon, bool);
181  vtkGetMacro(ProjectLatLon, bool);
182 
184 
197  vtkSetMacro(UsePrimaryGrid, bool);
198  vtkGetMacro(UsePrimaryGrid, bool);
200 
201  vtkSetMacro(IsAtmosphere, bool);
202  vtkGetMacro(IsAtmosphere, bool);
203 
204  vtkSetMacro(IsZeroCentered, bool);
205  vtkGetMacro(IsZeroCentered, bool);
206 
207  vtkSetMacro(ShowMultilayerView, bool);
208  vtkGetMacro(ShowMultilayerView, bool);
209 
213  static int CanReadFile(VTK_FILEPATH const char* filename);
214 
215  vtkMTimeType GetMTime() override;
216 
217 protected:
218  vtkMPASReader();
219  ~vtkMPASReader() override;
220  void ReleaseNcData();
221  void DestroyData();
222 
223  char* FileName; // First field part file giving path
224 
225  size_t NumberOfTimeSteps; // Temporal domain
226  double DTime; // The current time
227 
228  // Observer to modify this object when array selections are modified
230 
233 
234  static void SelectionCallback(
235  vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
236 
237  // Selected field of interest
240 
245  void UpdateDimensions(bool force = false);
246 
248  int VerticalLevelRange[2];
249 
251  int LayerThicknessRange[2];
252 
254  int CenterLonRange[2];
255 
256  bool ProjectLatLon; // User option
257  bool UsePrimaryGrid; // User option
258  bool OnASphere; // Data file attribute
262 
264  bool DoBugFix;
265  double CenterRad;
266 
268 
269 private:
270  enum GeometryType
271  {
272  SphericalDual,
273  SphericalPrimary,
274  ProjectedDual,
275  ProjectedPrimary,
276  Planar
277  };
278 
279  GeometryType Geometry;
280 
281  // geometry
282  size_t MaximumNVertLevels;
283  size_t NumberOfCells;
284  size_t NumberOfPoints;
285  int CellOffset;
286  size_t PointOffset;
287  size_t PointsPerCell;
288  int MaximumCells;
289  int MaximumPoints;
290 
291  struct LoadState;
292 
293  void SetDefaults();
294  int GetNcDims();
295  int GetNcAtts();
296  int CheckParams();
297  int GetNcVars(const char* cellDimName, const char* pointDimName);
298  int ReadAndOutputGrid(LoadState& state);
299  int BuildVarArrays();
300  int AllocSphericalDualGeometry(LoadState& state);
301  int AllocSphericalPrimaryGeometry(LoadState& state);
302  int AllocProjectedDualGeometry(LoadState& state);
303  int AllocProjectedPrimaryGeometry(LoadState& state);
304  int AllocPlanarGeometry(LoadState& state);
305  void ShiftLonData(LoadState& state);
306  int AddMirrorPoint(LoadState& state, int index, double dividerX, double offset);
307  void FixPoints(LoadState& state);
308  int EliminateXWrap(LoadState& state);
309  void OutputPoints(LoadState& state);
310  void OutputCells(LoadState& state);
311  unsigned char GetCellType(int numPoints);
312 
313  vtkDataArray* LoadPointVarData(LoadState& state, int variable);
314  vtkDataArray* LoadCellVarData(LoadState& state, int variable);
315  vtkDataArray* LookupPointDataArray(int varIdx);
316  vtkDataArray* LookupCellDataArray(int varIdx);
317 
326  void LoadTimeFieldData(vtkUnstructuredGrid* dataset);
327 
328  vtkMPASReader(const vtkMPASReader&) = delete;
329  void operator=(const vtkMPASReader&) = delete;
330 
331  class Internal;
332  Internal* Internals;
333 };
334 
335 VTK_ABI_NAMESPACE_END
336 #endif
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
abstract base class for most VTK objects
Definition: vtkObject.h:52
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
size_t NumberOfTimeSteps
static vtkUnstructuredGridAlgorithm * New()
a vtkAbstractArray subclass for strings
bool IncludeTopography
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
int vtkIdType
Definition: vtkType.h:363
vtkDataArraySelection * PointDataArraySelection
Read an MPAS netCDF file.
Definition: vtkMPASReader.h:53
dynamic, self-adjusting array of double
bool UseDimensionedArrayNames
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
supports function callbacks
VTKIOCATALYSTCONDUIT_EXPORT int GetCellType(const std::string &shape)
Get vtk cell type from conduit shape name throw a runtime_error on unsupported type.
a simple class to control print indentation
Definition: vtkIndent.h:28
Store on/off settings for data arrays, etc.
dataset represents arbitrary combinations of all possible cell types
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
virtual vtkMTimeType GetMTime()
Return this object's modified time.
Superclass for algorithms that produce only unstructured grid as output.
std::string VerticalDimension
#define VTK_FILEPATH
vtkCallbackCommand * SelectionObserver
Store zero or more vtkInformation instances.
vtkUnstructuredGrid * GetOutput()
Get the output data object for a port on this algorithm.
vtkDataArraySelection * CellDataArraySelection
bool ShowMultilayerView