VTK  9.2.20221001
PIOAdaptor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: PIOAdaptor.h
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 #ifndef PIOAdaptor_h
16 #define PIOAdaptor_h
17 
18 #include "vtkDataArraySelection.h"
20 #include "vtkMultiBlockDataSet.h"
21 
22 #include "PIOData.h"
23 
24 #include <vector>
25 
26 VTK_ABI_NAMESPACE_BEGIN
28 
29 // class to hold information about chunk/material variables
31 {
32 public:
34  std::string var; // actual variable
35  std::string baseVar; // variable used to derive actual variable
36  std::string material_name; // full name of the material
37  uint32_t material_number;
38 };
39 
41 {
42 public:
45 
46  int initializeGlobal(const char* DumpDescFile);
47  int initializeDump(int timeStep);
48 
49  // Time step change requires new geometry and data
52 
53  int GetNumberOfTimeSteps() { return static_cast<int>(this->CycleIndex.size()); }
54  double GetSimulationTime(int step) { return this->SimulationTime[step]; }
55  double GetCycleIndex(int step) { return this->CycleIndex[step]; }
56  double GetPIOFileIndex(int step) { return this->PIOFileIndex[step]; }
57 
58  int GetNumberOfVariables() { return (int)this->variableName.size(); }
59  const char* GetVariableName(int indx) { return this->variableName[indx].c_str(); }
60  int GetNumberOfDefaultVariables() { return (int)this->variableDefault.size(); }
61  const char* GetVariableDefault(int indx) { return this->variableDefault[indx].c_str(); }
62 
63  // Read pio dump file AMR as hypertree grid rather than unstructured grid
64  bool GetHyperTreeGrid() { return this->useHTG; }
65  void SetHyperTreeGrid(bool val) { this->useHTG = val; }
66 
67  // Read pio dump file tracer information
68  bool GetTracers() { return this->useTracer; }
69  void SetTracers(bool val) { this->useTracer = val; }
70 
71  // Read pio dump file variable data as 64 bit float
72  bool GetFloat64() { return this->useFloat64; }
73  void SetFloat64(bool val) { this->useFloat64 = val; }
74 
75 protected:
76  // Collect the metadata
77  int parsePIOFile(const char* DumpDescFile);
78  int collectMetaData(const char* DumpDescFile);
81  void addMaterialVariable(vtkStdString& pioFieldName, std::vector<std::string> matident);
83  std::string& prefix, std::string& baseVar, std::string& var, std::vector<std::string> matident);
85 
86  // Create the unstructured grid for tracers
88 
89  // Create the unstructured grid for AMR
91 
93  int numberOfCells, // Number of cells all levels
94  int* cell_level, // Level within AMR
95  int64_t* cell_daughter, // Daughter ID, 0 indicates no daughter
96  double* cell_center[1]); // Cell center
97 
99  int numberOfCells, // Number of cells all levels
100  int* cell_level, // Level within AMR
101  int64_t* cell_daughter, // Daughter ID, 0 indicates no daughter
102  double* cell_center[2]); // Cell center
103 
105  int numberOfCells, // Number of cells all levels
106  int* cell_level, // Level within AMR
107  int64_t* cell_daughter, // Daughter ID, 0 indicates no daughter
108  double* cell_center[3]); // Cell center
109 
110  // Create the hypertree grid
112 
113  int count_hypertree(int64_t curIndex, int64_t* daughter);
114 
116  vtkHyperTreeGridNonOrientedCursor* treeCursor, int64_t curIndex, int64_t* daughter);
117 
118  // Add variable data to the unstructured grid
121  int64_t* daughter, // Indicates top level cell or not
122  double* data[], // Data for all cells
123  int numberOfCells,
124  int numberOfComponents); // Number of components in data
125 
126  // Add variable data to the hypertree grid
129  double* data[], // Data for all cells
130  int numberOfComponents); // Number of components in data
131 
132  // Used in parallel reader and load balancing
134  int Rank;
136 
137  // Structure to access the dump file data
139 
140  // Time series of dumps
142  std::string dumpBaseName; // base name to use for dumps
143  std::vector<std::string> dumpDirectory; // directories holding dumps
144  std::vector<std::string> dumpFileName; // all dump files
145 
146  // Time step information
147  std::vector<double> CycleIndex; // Times as cycle index
148  std::vector<double> SimulationTime; // Times as simulation time
149  std::vector<double> PIOFileIndex; // Index into dump files
150 
151  // Type of block structures to create within multiblock dataset
152  bool useHTG;
153  bool useTracer;
156 
157  // Cell variable data and initially enabled variables
158  std::vector<std::string> variableName;
159  std::vector<std::string> variableDefault;
160 
161  // total number of cells in the mesh. needed when loading material variables.
162  // obtained by summing all values in pio field global_numcells
163  int64_t numCells;
164 
165  // Record the ordering of the cells when building the hypertree grid
166  // Needed so that the data will line up correctly
167  std::vector<int> indexNodeLeaf;
168 
169  // list of material variables
170  std::map<std::string, PIOMaterialVariable*> matVariables;
172 
173  struct AdaptorImpl;
174  AdaptorImpl* Impl;
175 };
176 
177 VTK_ABI_NAMESPACE_END
178 #endif
std::vector< double > SimulationTime
Definition: PIOAdaptor.h:148
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:58
int numMaterials
Definition: PIOAdaptor.h:171
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:153
int count_hypertree(int64_t curIndex, int64_t *daughter)
double GetSimulationTime(int step)
Definition: PIOAdaptor.h:54
void add_amr_UG_scalar(vtkMultiBlockDataSet *grid, vtkStdString varName, int64_t *daughter, double *data[], int numberOfCells, int numberOfComponents)
vtkMultiProcessController * Controller
Definition: PIOAdaptor.h:133
PIO_DATA * pioData
Definition: PIOAdaptor.h:138
bool GetHyperTreeGrid()
Definition: PIOAdaptor.h:64
void create_geometry(vtkMultiBlockDataSet *grid)
void SetTracers(bool val)
Definition: PIOAdaptor.h:69
std::string descFileName
Definition: PIOAdaptor.h:141
std::map< std::string, PIOMaterialVariable * > matVariables
Definition: PIOAdaptor.h:170
int parsePIOFile(const char *DumpDescFile)
double GetCycleIndex(int step)
Definition: PIOAdaptor.h:55
void addMaterialVariable(vtkStdString &pioFieldName, std::vector< std::string > matident)
bool hasTracers
Definition: PIOAdaptor.h:155
int initializeDump(int timeStep)
void load_variable_data_HTG(vtkMultiBlockDataSet *grid, vtkDataArraySelection *cellSelection)
void create_tracer_UG(vtkMultiBlockDataSet *grid)
bool GetTracers()
Definition: PIOAdaptor.h:68
std::vector< int > indexNodeLeaf
Definition: PIOAdaptor.h:167
std::vector< std::string > dumpFileName
Definition: PIOAdaptor.h:144
void addMaterialVariableEntries(std::string &prefix, std::string &baseVar, std::string &var, std::vector< std::string > matident)
std::vector< std::string > variableDefault
Definition: PIOAdaptor.h:159
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:72
const char * GetVariableDefault(int indx)
Definition: PIOAdaptor.h:61
void load_variable_data(vtkMultiBlockDataSet *grid, vtkDataArraySelection *cellSelection)
std::vector< double > PIOFileIndex
Definition: PIOAdaptor.h:149
int GetNumberOfTimeSteps()
Definition: PIOAdaptor.h:53
bool useHTG
Definition: PIOAdaptor.h:152
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:60
std::vector< std::string > dumpDirectory
Definition: PIOAdaptor.h:143
double GetPIOFileIndex(int step)
Definition: PIOAdaptor.h:56
void collectVariableMetaData()
int initializeGlobal(const char *DumpDescFile)
AdaptorImpl * Impl
Definition: PIOAdaptor.h:173
int64_t numCells
Definition: PIOAdaptor.h:163
void SetFloat64(bool val)
Definition: PIOAdaptor.h:73
PIOAdaptor(vtkMultiProcessController *ctrl)
std::vector< double > CycleIndex
Definition: PIOAdaptor.h:147
void collectMaterialVariableMetaData()
bool useFloat64
Definition: PIOAdaptor.h:154
int collectMetaData(const char *DumpDescFile)
int TotalRank
Definition: PIOAdaptor.h:135
void SetHyperTreeGrid(bool val)
Definition: PIOAdaptor.h:65
std::string dumpBaseName
Definition: PIOAdaptor.h:142
std::vector< std::string > variableName
Definition: PIOAdaptor.h:158
void load_variable_data_UG(vtkMultiBlockDataSet *grid, vtkDataArraySelection *cellSelection)
const char * GetVariableName(int indx)
Definition: PIOAdaptor.h:59
void create_amr_HTG(vtkMultiBlockDataSet *grid)
std::string material_name
Definition: PIOAdaptor.h:36
std::string var
Definition: PIOAdaptor.h:34
std::string prefix
Definition: PIOAdaptor.h:33
uint32_t material_number
Definition: PIOAdaptor.h:37
std::string baseVar
Definition: PIOAdaptor.h:35
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:110
@ data
Definition: vtkX3D.h:327
@ string
Definition: vtkX3D.h:502