VTK  9.7.1
vtkAMRFlashReaderInternal.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
11 #ifndef vtkAMRFlashReaderInternal_h
12 #define vtkAMRFlashReaderInternal_h
13 
14 #include <cassert>
15 #include <cstring>
16 #include <map>
17 #include <string>
18 #include <vector>
19 
20 #include "vtkByteSwap.h"
21 #include "vtkCellData.h"
22 #include "vtkDataArray.h"
23 #include "vtkDataSet.h"
24 #include "vtkDoubleArray.h"
25 #include "vtkIntArray.h"
26 #include "vtkObject.h"
27 #include "vtkSetGet.h"
28 
29 #define H5_USE_16_API
30 #include "vtk_hdf5.h"
31 
32 //==============================================================================
33 // I N T E R N A L F L A S H R E A D E R
34 //==============================================================================
35 
36 #define FLASH_READER_MAX_DIMS 3
37 #define FLASH_READER_LEAF_BLOCK 1
38 #define FLASH_READER_FLASH3_FFV8 8
39 #define FLASH_READER_FLASH3_FFV9 9
40 
41 VTK_ABI_NAMESPACE_BEGIN
43 {
44  char Name[20]; // name of the integer scalar
45  int Value; // value of the integer scalar
47 
49 {
50  char Name[20]; // name of the real scalar
51  double Value; // value of the real scalar
53 
55 {
56  int NumberOfBlocks; // number of all blocks
57  int NumberOfTimeSteps; // number of time steps
58  int NumberOfXDivisions; // number of divisions per block along x axis
59  int NumberOfYDivisions; // number of divisions per block along y axis
60  int NumberOfZDivisions; // number of divisions per block along z axis
61  double Time; // the time of this step
62  double TimeStep; // time interval
63  double RedShift;
65 
66 typedef struct tagFlashReaderBlock
67 {
68  int Index; // Id of the block
69  int Level; // LOD level
70  int Type; // a leaf block?
71  int ParentId; // Id of the parent block
72  int ChildrenIds[8]; // Ids of the children blocks
73  int NeighborIds[6]; // Ids of the neighboring blocks
74  int ProcessorId; // Id of the processor
75  int MinGlobalDivisionIds[3]; // first (global) division index
76  int MaxGlobalDivisionIds[3]; // last (global) division index
77  double Center[3]; // center of the block
78  double MinBounds[3]; // lower left of the bounding box
79  double MaxBounds[3]; // upper right of the bounding box
81 
83 {
85  char SetupCall[400];
86  char FileCreationTime[80];
87  char FlashVersion[80];
88  char BuildData[80];
89  char BuildDirectory[80];
90  char build_machine[80];
91  char CFlags[400];
92  char FFlags[400];
93  char SetupTimeStamp[80];
94  char BuildTimeStamp[80];
96 
97 // ----------------------------------------------------------------------------
98 // Class vtkFlashReaderInternal (begin)
99 // ----------------------------------------------------------------------------
100 
102 {
103 public:
106 
107  int NumberOfBlocks; // number of ALL blocks
108  int NumberOfLevels; // number of levels
109  int FileFormatVersion; // version of file format
110  int NumberOfParticles; // number of particles
111  int NumberOfLeafBlocks; // number of leaf blocks
112  int NumberOfDimensions; // number of dimensions
113  int NumberOfProcessors; // number of processors
114  int HaveProcessorsInfo; // processor Ids available?
115  int BlockGridDimensions[3]; // number of grid points
116  int BlockCellDimensions[3]; // number of divisions
117  int NumberOfChildrenPerBlock; // number of children per block
118  int NumberOfNeighborsPerBlock; // number of neighbors per block
119 
120  char* FileName; // Flash data file name
121  hid_t FileIndex; // file handle
122  double MinBounds[3]; // lower left of the bounding-box
123  double MaxBounds[3]; // upper right of the bounding box
126 
127  // blocks
128  std::vector<FlashReaderBlock> Blocks;
129  std::vector<int> LeafBlocks;
130  std::vector<std::string> AttributeNames;
131 
132  // particles
134  std::vector<hid_t> ParticleAttributeTypes;
135  std::vector<std::string> ParticleAttributeNames;
136  std::map<std::string, int> ParticleAttributeNamesToIds;
137 
138  int GetCycle();
139  double GetTime();
140 
141  void Init();
142  void SetFileName(VTK_FILEPATH char* fileName) { this->FileName = fileName; }
143  const char* GetParticleName(char* variableName);
144 
145  void ReadMetaData();
146  void ReadProcessorIds();
147  void ReadDoubleScalars(hid_t fileIndx);
148  void ReadIntegerScalars(hid_t fileIndx);
149  void ReadVersionInformation(hid_t fileIndx);
150  void ReadSimulationParameters(hid_t fileIndx, bool bTmCycle = false); // time and cycle only
152 
153  void ReadBlockTypes();
154  void ReadBlockBounds();
155  void ReadBlockCenters();
156  void ReadBlockStructures();
157  void ReadRefinementLevels();
158  void ReadDataAttributeNames();
159 
160  void ReadParticlesComponent(hid_t dataIndx, const char* compName, double* dataBuff);
161  void ReadParticleAttributes();
163  void GetBlockAttribute(const char* attribute, int blockIdx, vtkDataSet* pDataSet);
164 
166  {
167  std::string sepaName = variable;
168 
169  if (sepaName.length() > 9 && sepaName.substr(0, 9) == "particle_")
170  {
171  sepaName = std::string("Particles/") + sepaName.substr(9);
172  }
173  else
174  {
175  sepaName = std::string("Particles/") + sepaName;
176  }
177 
178  return sepaName;
179  }
180 };
181 
182 // ----------------------------------------------------------------------------
183 // Class vtkFlashReaderInternal ( end )
184 // ----------------------------------------------------------------------------
185 VTK_ABI_NAMESPACE_END
186 #endif /* vtkAMRFlashReaderInternal_h */
187 // VTK-HeaderTest-Exclude: vtkAMRFlashReaderInternal.h
void ReadIntegerScalars(hid_t fileIndx)
FlashReaderSimulationInformation SimulationInformation
void ReadParticleAttributesFLASH3()
static std::string GetSeparatedParticleName(const std::string &variable)
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
const char * GetParticleName(char *variableName)
FlashReaderSimulationParameters SimulationParameters
std::vector< hid_t > ParticleAttributeTypes
void ReadDoubleScalars(hid_t fileIndx)
void ReadParticlesComponent(hid_t dataIndx, const char *compName, double *dataBuff)
struct tagFlashReaderSimulationParameters FlashReaderSimulationParameters
void SetFileName(char *fileName)
struct tagFlashReaderSimulationInformation FlashReaderSimulationInformation
int64_t hid_t
Definition: vtkHDFWriter.h:63
std::vector< FlashReaderBlock > Blocks
struct tagFlashReaderDoubleScalar FlashReaderDoubleScalar
void GetBlockMinMaxGlobalDivisionIds()
std::map< std::string, int > ParticleAttributeNamesToIds
void ReadSimulationParameters(hid_t fileIndx, bool bTmCycle=false)
#define VTK_FILEPATH
void GetBlockAttribute(const char *attribute, int blockIdx, vtkDataSet *pDataSet)
struct tagFlashReaderIntegerScalar FlashReaderIntegerScalar
std::vector< std::string > AttributeNames
std::vector< std::string > ParticleAttributeNames
struct tagFlashReaderBlock FlashReaderBlock
void ReadVersionInformation(hid_t fileIndx)