VTK  9.6.20260204
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 "vtkIONetCDFModule.h" // For export macro
44
45#include <string> // for std::string
46
47VTK_ABI_NAMESPACE_BEGIN
50class vtkDoubleArray;
51class vtkStringArray;
52
53class VTKIONETCDF_EXPORT vtkMPASReader : public vtkUnstructuredGridAlgorithm
54{
55public:
56 static vtkMPASReader* New();
58 void PrintSelf(ostream& os, vtkIndent indent) override;
59
61
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
122 const char* GetPointArrayName(int index);
123 int GetPointArrayStatus(const char* name);
124 void SetPointArrayStatus(const char* name, int status);
128
130 const char* GetCellArrayName(int index);
131 int GetCellArrayStatus(const char* name);
132 void SetCellArrayStatus(const char* name, int status);
135
137
146 std::string GetDimensionName(int idx);
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);
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
216
217protected:
219 ~vtkMPASReader() override;
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
247 std::string VerticalDimension;
249
252
255
256 bool ProjectLatLon; // User option
257 bool UsePrimaryGrid; // User option
258 bool OnASphere; // Data file attribute
262
265 double CenterRad;
266
268
269private:
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
335VTK_ABI_NAMESPACE_END
336#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.
vtkUnstructuredGrid * GetOutput(int idx)
Get the reader's output.
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...
~vtkMPASReader() override
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
int vtkIdType
Definition vtkType.h:354
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:309
#define VTK_FILEPATH