VTK  9.3.20240419
PIOAdaptor.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright (c) Kitware, Inc.
3 // SPDX-FileCopyrightText: Copyright (c) 2021, Triad National Security, LLC
4 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-LANL-Triad-USGov
17 #ifndef PIOAdaptor_h
18 #define PIOAdaptor_h
19 
20 #include "vtkDataArraySelection.h"
22 #include "vtkMultiBlockDataSet.h"
23 
24 #include "PIOData.h"
25 #include "PIODataHDF5.h"
26 #include "PIODataPIO.h"
27 
28 #include <vector>
29 
30 VTK_ABI_NAMESPACE_BEGIN
32 
33 // class to hold information about chunk/material variables
35 {
36 public:
38  std::string var; // actual variable
39  std::string baseVar; // variable used to derive actual variable
40  std::string material_name; // full name of the material
41  uint32_t material_number;
42 };
43 
45 {
46 public:
49 
50  int initializeGlobal(const char* DumpDescFile);
51  int initializeDump(int timeStep);
52 
53  // Time step change requires new geometry and data
56 
57  int GetNumberOfTimeSteps() { return static_cast<int>(this->CycleIndex.size()); }
58  double GetSimulationTime(int step) { return this->SimulationTime[step]; }
59  double GetCycleIndex(int step) { return this->CycleIndex[step]; }
60  double GetPIOFileIndex(int step) { return this->PIOFileIndex[step]; }
61 
62  int GetNumberOfVariables() { return (int)this->variableName.size(); }
63  const char* GetVariableName(int indx) { return this->variableName[indx].c_str(); }
64  int GetNumberOfDefaultVariables() { return (int)this->variableDefault.size(); }
65  const char* GetVariableDefault(int indx) { return this->variableDefault[indx].c_str(); }
66 
67  // Read pio dump file AMR as hypertree grid rather than unstructured grid
68  bool GetHyperTreeGrid() { return this->useHTG; }
69  void SetHyperTreeGrid(bool val) { this->useHTG = val; }
70 
71  // Read pio dump file tracer information
72  bool GetTracers() { return this->useTracer; }
73  void SetTracers(bool val) { this->useTracer = val; }
74 
75  // Read pio dump file variable data as 64 bit float
76  bool GetFloat64() { return this->useFloat64; }
77  void SetFloat64(bool val) { this->useFloat64 = val; }
78 
79 protected:
80  // Collect the metadata
81  int parsePIOFile(const char* DumpDescFile);
82  PIO_DATA* openPIODataFile(const char* filename);
83  int collectMetaData(const char* DumpDescFile);
86  void addMaterialVariable(vtkStdString& pioFieldName, std::valarray<std::string> matident);
88  std::valarray<std::string> matident);
90 
91  // Create the unstructured grid for tracers
93 
94  // Create the unstructured grid for AMR
96 
98  int numberOfCells, // Number of cells all levels
99  int* cell_level, // Level within AMR
100  int64_t* cell_daughter, // Daughter ID, 0 indicates no daughter
101  double* cell_center[1]); // Cell center
102 
104  int numberOfCells, // Number of cells all levels
105  int* cell_level, // Level within AMR
106  int64_t* cell_daughter, // Daughter ID, 0 indicates no daughter
107  double* cell_center[2]); // Cell center
108 
110  int numberOfCells, // Number of cells all levels
111  int* cell_level, // Level within AMR
112  int64_t* cell_daughter, // Daughter ID, 0 indicates no daughter
113  double* cell_center[3]); // Cell center
114 
115  // Create the hypertree grid
117 
118  int count_hypertree(int64_t curIndex, int64_t* daughter);
119 
121  vtkHyperTreeGridNonOrientedCursor* treeCursor, int64_t curIndex, int64_t* daughter);
122 
123  // Add variable data to the unstructured grid
126  int64_t* daughter, // Indicates top level cell or not
127  double* data[], // Data for all cells
128  int numberOfCells,
129  int numberOfComponents); // Number of components in data
130 
131  // Add variable data to the hypertree grid
134  double* data[], // Data for all cells
135  int numberOfComponents); // Number of components in data
136 
137  // Used in parallel reader and load balancing
139  int Rank;
141 
142  // Structure to access the dump file data
144 
145  bool knownFormat; // whether the pio format is known or not
146  bool isHDF5; // what type of internal format the pio file is, either native pio or hdf5 variant
147 
148  // Time series of dumps
150  std::string dumpBaseName; // base name to use for dumps
151  std::vector<std::string> dumpDirectory; // directories holding dumps
152  std::vector<std::string> dumpFileName; // all dump files
153 
154  // Time step information
155  std::vector<double> CycleIndex; // Times as cycle index
156  std::vector<double> SimulationTime; // Times as simulation time
157  std::vector<double> PIOFileIndex; // Index into dump files
158 
159  // Type of block structures to create within multiblock dataset
160  bool useHTG;
161  bool useTracer;
164 
165  // Cell variable data and initially enabled variables
166  std::vector<std::string> variableName;
167  std::vector<std::string> variableDefault;
168 
169  // total number of cells in the mesh. needed when loading material variables.
170  // obtained by summing all values in pio field global_numcells
171  int64_t numCells;
172 
173  // Record the ordering of the cells when building the hypertree grid
174  // Needed so that the data will line up correctly
175  std::vector<int> indexNodeLeaf;
176 
177  // list of material variables
178  std::map<std::string, PIOMaterialVariable*> matVariables;
180 
181  struct AdaptorImpl;
182  AdaptorImpl* Impl;
183 };
184 
185 VTK_ABI_NAMESPACE_END
186 #endif
class for reading PIO (Parallel Input Output) data files
Definition: PIOAdaptor.h:45
std::vector< double > SimulationTime
Definition: PIOAdaptor.h:156
void addMaterialVariableEntries(std::string &prefix, std::string &baseVar, std::string &var, std::valarray< std::string > matident)
void create_amr_UG_3D(vtkMultiBlockDataSet *grid, int numberOfCells, int *cell_level, int64_t *cell_daughter, double *cell_center[3])
void build_hypertree(vtkHyperTreeGridNonOrientedCursor *treeCursor, int64_t curIndex, int64_t *daughter)
int GetNumberOfVariables()
Definition: PIOAdaptor.h:62
int numMaterials
Definition: PIOAdaptor.h:179
PIO_DATA * openPIODataFile(const char *filename)
void create_amr_UG_1D(vtkMultiBlockDataSet *grid, int numberOfCells, int *cell_level, int64_t *cell_daughter, double *cell_center[1])
void create_amr_UG(vtkMultiBlockDataSet *grid)
bool useTracer
Definition: PIOAdaptor.h:161
int count_hypertree(int64_t curIndex, int64_t *daughter)
double GetSimulationTime(int step)
Definition: PIOAdaptor.h:58
void add_amr_UG_scalar(vtkMultiBlockDataSet *grid, vtkStdString varName, int64_t *daughter, double *data[], int numberOfCells, int numberOfComponents)
vtkMultiProcessController * Controller
Definition: PIOAdaptor.h:138
PIO_DATA * pioData
Definition: PIOAdaptor.h:143
bool GetHyperTreeGrid()
Definition: PIOAdaptor.h:68
void create_geometry(vtkMultiBlockDataSet *grid)
void SetTracers(bool val)
Definition: PIOAdaptor.h:73
std::string descFileName
Definition: PIOAdaptor.h:149
void addMaterialVariable(vtkStdString &pioFieldName, std::valarray< std::string > matident)
std::map< std::string, PIOMaterialVariable * > matVariables
Definition: PIOAdaptor.h:178
int parsePIOFile(const char *DumpDescFile)
double GetCycleIndex(int step)
Definition: PIOAdaptor.h:59
bool hasTracers
Definition: PIOAdaptor.h:163
int initializeDump(int timeStep)
void load_variable_data_HTG(vtkMultiBlockDataSet *grid, vtkDataArraySelection *cellSelection)
void create_tracer_UG(vtkMultiBlockDataSet *grid)
bool GetTracers()
Definition: PIOAdaptor.h:72
std::vector< int > indexNodeLeaf
Definition: PIOAdaptor.h:175
std::vector< std::string > dumpFileName
Definition: PIOAdaptor.h:152
std::vector< std::string > variableDefault
Definition: PIOAdaptor.h:167
std::string trimString(const std::string &str)
void add_amr_HTG_scalar(vtkMultiBlockDataSet *grid, vtkStdString varName, double *data[], int numberOfComponents)
bool GetFloat64()
Definition: PIOAdaptor.h:76
const char * GetVariableDefault(int indx)
Definition: PIOAdaptor.h:65
void load_variable_data(vtkMultiBlockDataSet *grid, vtkDataArraySelection *cellSelection)
std::vector< double > PIOFileIndex
Definition: PIOAdaptor.h:157
int GetNumberOfTimeSteps()
Definition: PIOAdaptor.h:57
bool useHTG
Definition: PIOAdaptor.h:160
void create_amr_UG_2D(vtkMultiBlockDataSet *grid, int numberOfCells, int *cell_level, int64_t *cell_daughter, double *cell_center[2])
int GetNumberOfDefaultVariables()
Definition: PIOAdaptor.h:64
std::vector< std::string > dumpDirectory
Definition: PIOAdaptor.h:151
double GetPIOFileIndex(int step)
Definition: PIOAdaptor.h:60
void collectVariableMetaData()
int initializeGlobal(const char *DumpDescFile)
AdaptorImpl * Impl
Definition: PIOAdaptor.h:181
int64_t numCells
Definition: PIOAdaptor.h:171
void SetFloat64(bool val)
Definition: PIOAdaptor.h:77
PIOAdaptor(vtkMultiProcessController *ctrl)
bool knownFormat
Definition: PIOAdaptor.h:145
std::vector< double > CycleIndex
Definition: PIOAdaptor.h:155
void collectMaterialVariableMetaData()
bool useFloat64
Definition: PIOAdaptor.h:162
int collectMetaData(const char *DumpDescFile)
int TotalRank
Definition: PIOAdaptor.h:140
void SetHyperTreeGrid(bool val)
Definition: PIOAdaptor.h:69
std::string dumpBaseName
Definition: PIOAdaptor.h:150
std::vector< std::string > variableName
Definition: PIOAdaptor.h:166
void load_variable_data_UG(vtkMultiBlockDataSet *grid, vtkDataArraySelection *cellSelection)
const char * GetVariableName(int indx)
Definition: PIOAdaptor.h:63
bool isHDF5
Definition: PIOAdaptor.h:146
void create_amr_HTG(vtkMultiBlockDataSet *grid)
std::string material_name
Definition: PIOAdaptor.h:40
std::string var
Definition: PIOAdaptor.h:38
std::string prefix
Definition: PIOAdaptor.h:37
uint32_t material_number
Definition: PIOAdaptor.h:41
std::string baseVar
Definition: PIOAdaptor.h:39
class for reading PIO (Parallel Input Output) data files
Definition: PIOData.h:66
Store on/off settings for data arrays, etc.
Objects for traversal a HyperTreeGrid.
Composite dataset that organizes datasets into blocks.
Multiprocessing communication superclass.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:78
@ data
Definition: vtkX3D.h:315
@ string
Definition: vtkX3D.h:490