VTK  9.7.20260723
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
73 vtkGetMacro(MaximumCells, int);
75
77
80 vtkGetMacro(MaximumPoints, int);
82
84
92 VTK_DEPRECATED_IN_9_8_0("Use GetNumberOfCellArrays instead.")
93 virtual int GetNumberOfCellVars();
94 VTK_DEPRECATED_IN_9_8_0("Use GetNumberOfPointArrays instead.")
95 virtual int GetNumberOfPointVars();
97
99
105
107
113 vtkSetMacro(UseDimensionedArrayNames, bool);
114 vtkGetMacro(UseDimensionedArrayNames, bool);
115 vtkBooleanMacro(UseDimensionedArrayNames, bool);
117
119
130 const char* GetPointArrayName(int index);
131 int GetPointArrayStatus(const char* name);
132 void SetPointArrayStatus(const char* name, int status);
136
138 const char* GetCellArrayName(int index);
139 int GetCellArrayStatus(const char* name);
140 void SetCellArrayStatus(const char* name, int status);
143
145
154 std::string GetDimensionName(int idx);
156 int GetDimensionCurrentIndex(const std::string& dim);
157 void SetDimensionCurrentIndex(const std::string& dim, int idx);
158 int GetDimensionSize(const std::string& dim);
160
162
166 vtkSetMacro(VerticalDimension, std::string);
167 vtkGetMacro(VerticalDimension, std::string);
169
171
175 void SetVerticalLevel(int level);
178
179 vtkGetVector2Macro(VerticalLevelRange, int);
180
181 vtkSetMacro(LayerThickness, int);
182 vtkGetMacro(LayerThickness, int);
183 vtkGetVector2Macro(LayerThicknessRange, int);
184
185 void SetCenterLon(int val);
186 vtkGetVector2Macro(CenterLonRange, int);
187
188 vtkSetMacro(ProjectLatLon, bool);
189 vtkGetMacro(ProjectLatLon, bool);
190
192
205 vtkSetMacro(UsePrimaryGrid, bool);
206 vtkGetMacro(UsePrimaryGrid, bool);
208
209 vtkSetMacro(IsAtmosphere, bool);
210 vtkGetMacro(IsAtmosphere, bool);
211
212 vtkSetMacro(IsZeroCentered, bool);
213 vtkGetMacro(IsZeroCentered, bool);
214
215 vtkSetMacro(ShowMultilayerView, bool);
216 vtkGetMacro(ShowMultilayerView, bool);
217
221 static int CanReadFile(VTK_FILEPATH const char* filename);
222
224
225protected:
227 ~vtkMPASReader() override;
230
231 char* FileName; // First field part file giving path
232
233 size_t NumberOfTimeSteps; // Temporal domain
234 double DTime; // The current time
235
236 // Observer to modify this object when array selections are modified
238
241
242 static void SelectionCallback(
243 vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
244
245 // Selected field of interest
248
253 void UpdateDimensions(bool force = false);
254
257
260
263
264 bool ProjectLatLon; // User option
265 bool UsePrimaryGrid; // User option
266 bool OnASphere; // Data file attribute
270
273 double CenterRad;
274
276
277private:
278 enum GeometryType
279 {
280 SphericalDual,
281 SphericalPrimary,
282 ProjectedDual,
283 ProjectedPrimary,
284 Planar
285 };
286
287 GeometryType Geometry;
288
289 // geometry
290 size_t MaximumNVertLevels;
291 size_t NumberOfCells;
292 size_t NumberOfPoints;
293 int CellOffset;
294 size_t PointOffset;
295 size_t PointsPerCell;
296 int MaximumCells;
297 int MaximumPoints;
298
299 struct LoadState;
300
301 void SetDefaults();
302 int GetNcDims();
303 int GetNcAtts();
304 int CheckParams();
305 int GetNcVars(const char* cellDimName, const char* pointDimName);
306 int ReadAndOutputGrid(LoadState& state);
307 int BuildVarArrays();
308 int AllocSphericalDualGeometry(LoadState& state);
309 int AllocSphericalPrimaryGeometry(LoadState& state);
310 int AllocProjectedDualGeometry(LoadState& state);
311 int AllocProjectedPrimaryGeometry(LoadState& state);
312 int AllocPlanarGeometry(LoadState& state);
313 void ShiftLonData(LoadState& state);
314 int AddMirrorPoint(LoadState& state, int index, double dividerX, double offset);
315 void FixPoints(LoadState& state);
316 int EliminateXWrap(LoadState& state);
317 void OutputPoints(LoadState& state);
318 void OutputCells(LoadState& state);
319 unsigned char GetCellType(int numPoints);
320
321 vtkDataArray* LoadPointVarData(LoadState& state, int variable);
322 vtkDataArray* LoadCellVarData(LoadState& state, int variable);
323 vtkDataArray* LookupPointDataArray(int varIdx);
324 vtkDataArray* LookupCellDataArray(int varIdx);
325
334 void LoadTimeFieldData(vtkUnstructuredGrid* dataset);
335
336 vtkMPASReader(const vtkMPASReader&) = delete;
337 void operator=(const vtkMPASReader&) = delete;
338
339 class Internal;
340 Internal* Internals;
341};
342
343VTK_ABI_NAMESPACE_END
344#endif
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.
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)
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
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