VTK  9.7.20260929
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
38
39#ifndef vtkMPASReader_h
40#define vtkMPASReader_h
41
42#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_8_0
43#include "vtkIONetCDFModule.h" // For export macro
45
46#include <string> // for std::string
47
48VTK_ABI_NAMESPACE_BEGIN
51class vtkDoubleArray;
52class vtkStringArray;
53
54class VTKIONETCDF_EXPORT vtkMPASReader : public vtkUnstructuredGridAlgorithm
55{
56public:
57 static vtkMPASReader* New();
59 void PrintSelf(ostream& os, vtkIndent indent) override;
60
62
68
70
78
80
83 vtkGetMacro(MaximumCells, int);
85
87
90 vtkGetMacro(MaximumPoints, int);
92
94
102 VTK_DEPRECATED_IN_9_8_0("Use GetNumberOfCellArrays instead.")
103 virtual int GetNumberOfCellVars();
104 VTK_DEPRECATED_IN_9_8_0("Use GetNumberOfPointArrays instead.")
105 virtual int GetNumberOfPointVars();
107
109
115
117
123 vtkSetMacro(UseDimensionedArrayNames, bool);
124 vtkGetMacro(UseDimensionedArrayNames, bool);
125 vtkBooleanMacro(UseDimensionedArrayNames, bool);
127
129
140 const char* GetPointArrayName(int index);
141 int GetPointArrayStatus(const char* name);
142 void SetPointArrayStatus(const char* name, int status);
146
148 const char* GetCellArrayName(int index);
149 int GetCellArrayStatus(const char* name);
150 void SetCellArrayStatus(const char* name, int status);
153
155
166 int GetDimensionCurrentIndex(const std::string& dim);
167 void SetDimensionCurrentIndex(const std::string& dim, int idx);
168 int GetDimensionSize(const std::string& dim);
170
172
176 vtkSetMacro(VerticalDimension, std::string);
177 vtkGetMacro(VerticalDimension, std::string);
179
181
185 void SetVerticalLevel(int level);
188
189 vtkGetVector2Macro(VerticalLevelRange, int);
190
191 vtkSetMacro(LayerThickness, int);
192 vtkGetMacro(LayerThickness, int);
193 vtkGetVector2Macro(LayerThicknessRange, int);
194
195 void SetCenterLon(int val);
196 vtkGetVector2Macro(CenterLonRange, int);
197
198 vtkSetMacro(ProjectLatLon, bool);
199 vtkGetMacro(ProjectLatLon, bool);
200
202
215 vtkSetMacro(UsePrimaryGrid, bool);
216 vtkGetMacro(UsePrimaryGrid, 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(VTK_FILEPATH const char* filename);
232
234
235protected:
237 ~vtkMPASReader() override;
240
241 char* FileName; // File containing the grid
242 char* HistoryFileName; // Optional file containing the fields
243
244 size_t NumberOfTimeSteps; // Temporal domain
245 double DTime; // The current time
246
247 // Observer to modify this object when array selections are modified
249
252
253 static void SelectionCallback(
254 vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
255
256 // Selected field of interest
259
264 void UpdateDimensions(bool force = false);
265
268
271
274
275 bool ProjectLatLon; // User option
276 bool UsePrimaryGrid; // User option
277 bool OnASphere; // Data file attribute
281
284 double CenterRad;
285
287
288private:
289 enum GeometryType
290 {
291 SphericalDual,
292 SphericalPrimary,
293 ProjectedDual,
294 ProjectedPrimary,
295 Planar
296 };
297
298 GeometryType Geometry;
299
300 // geometry
301 size_t MaximumNVertLevels;
302 size_t NumberOfCells;
303 size_t NumberOfPoints;
304 int CellOffset;
305 size_t PointOffset;
306 size_t PointsPerCell;
307 int MaximumCells;
308 int MaximumPoints;
309
310 struct LoadState;
311
312 void SetDefaults();
313 int GetNcDims();
314 int GetHistoryNcDims();
315 int GetNcAtts();
316 int CheckParams();
317 int GetNcVars(const char* cellDimName, const char* pointDimName);
318 int ReadAndOutputGrid(LoadState& state);
319 int BuildVarArrays();
320 int AllocSphericalDualGeometry(LoadState& state);
321 int AllocSphericalPrimaryGeometry(LoadState& state);
322 int AllocProjectedDualGeometry(LoadState& state);
323 int AllocProjectedPrimaryGeometry(LoadState& state);
324 int AllocPlanarGeometry(LoadState& state);
325 void ShiftLonData(LoadState& state);
326 int AddMirrorPoint(LoadState& state, int index, double dividerX, double offset);
327 void FixPoints(LoadState& state);
328 int EliminateXWrap(LoadState& state);
329 void OutputPoints(LoadState& state);
330 void OutputCells(LoadState& state);
331 unsigned char GetCellType(int numPoints);
332
333 vtkDataArray* LoadPointVarData(LoadState& state, int variable);
334 vtkDataArray* LoadCellVarData(LoadState& state, int variable);
335 vtkDataArray* LookupPointDataArray(int varIdx);
336 vtkDataArray* LookupCellDataArray(int varIdx);
337
346 void LoadTimeFieldData(vtkUnstructuredGrid* dataset);
347
348 vtkMPASReader(const vtkMPASReader&) = delete;
349 void operator=(const vtkMPASReader&) = delete;
350
351 class Internal;
352 Internal* Internals;
353};
354
355VTK_ABI_NAMESPACE_END
356#endif
int idx
Definition HexCnBasis.h:79
supports function callbacks
Store on/off settings for data arrays, etc.
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Read an MPAS netCDF file.
void UpdateDimensions(bool force=false)
Update the list of available dimensions.
int GetNumberOfPointArrays()
The following methods allow selective reading of solutions fields.
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void DestroyData()
vtkCallbackCommand * SelectionObserver
int CenterLonRange[2]
static int CanReadFile(const char *filename)
Returns true if the given file can be read.
virtual int GetNumberOfPointVars()
Get the number of data variables at the cell centers and points.
vtkSetFilePathMacro(HistoryFileName)
Specify an optional MPAS history file from which to read field data.
void SetPointArrayStatus(const char *name, int status)
The following methods allow selective reading of solutions fields.
void EnableAllPointArrays()
The following methods allow selective reading of solutions fields.
int GetDimensionCurrentIndex(const std::string &dim)
If the point/cell arrays contain dimensions other than Time, nCells, or nVertices,...
int GetCellArrayStatus(const char *name)
int GetVerticalLevel()
Convenience function for setting/querying [GS]etDimensionCurrentIndex for the dimension returned by G...
vtkIdType GetNumberOfDimensions()
If the point/cell arrays contain dimensions other than Time, nCells, or nVertices,...
std::string GetDimensionName(int idx)
If the point/cell arrays contain dimensions other than Time, nCells, or nVertices,...
const char * GetCellArrayName(int index)
vtkGetFilePathMacro(FileName)
Specify file name of MPAS data file to read.
int VerticalLevelRange[2]
void EnableAllCellArrays()
void SetDimensionCurrentIndex(const std::string &dim, int idx)
If the point/cell arrays contain dimensions other than Time, nCells, or nVertices,...
void SetCellArrayStatus(const char *name, int status)
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkStringArray * GetAllDimensions()
If the point/cell arrays contain dimensions other than Time, nCells, or nVertices,...
int LayerThicknessRange[2]
int GetNumberOfCellArrays()
vtkDataArraySelection * PointDataArraySelection
static void SelectionCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
vtkGetFilePathMacro(HistoryFileName)
Specify an optional MPAS history file from which to read field data.
std::string VerticalDimension
static vtkMPASReader * New()
void DisableAllPointArrays()
The following methods allow selective reading of solutions fields.
virtual int GetNumberOfCellVars()
Get the number of data variables at the cell centers and points.
void SetVerticalLevel(int level)
Convenience function for setting/querying [GS]etDimensionCurrentIndex for the dimension returned by G...
int GetDimensionSize(const std::string &dim)
If the point/cell arrays contain dimensions other than Time, nCells, or nVertices,...
int GetPointArrayStatus(const char *name)
The following methods allow selective reading of solutions fields.
void DisableAllCellArrays()
const char * GetPointArrayName(int index)
The following methods allow selective reading of solutions fields.
vtkUnstructuredGrid * GetOutput()
Get the reader's output.
vtkSetFilePathMacro(FileName)
Specify file name of MPAS data file to read.
void ReleaseNcData()
vtkDataArraySelection * CellDataArraySelection
vtkMTimeType GetMTime() override
Return this object's modified time.
bool UseDimensionedArrayNames
void SetCenterLon(int val)
size_t NumberOfTimeSteps
char * HistoryFileName
a vtkAbstractArray subclass for strings
dataset represents arbitrary combinations of all possible cell types
#define vtkDataArray
#define VTK_DEPRECATED_IN_9_8_0(reason)
int vtkIdType
Definition vtkType.h:363
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:318
#define VTK_FILEPATH