VTK  9.2.20230603
vtkAMRFlashReaderInternal.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkAMRFlashReaderInternal.hpp
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm 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 =========================================================================*/
23 #ifndef vtkAMRFlashReaderInternal_h
24 #define vtkAMRFlashReaderInternal_h
25 
26 #include <cassert>
27 #include <cstring>
28 #include <map>
29 #include <string>
30 #include <vector>
31 
32 #include "vtkByteSwap.h"
33 #include "vtkCellData.h"
34 #include "vtkDataArray.h"
35 #include "vtkDataSet.h"
36 #include "vtkDoubleArray.h"
37 #include "vtkIntArray.h"
38 #include "vtkObject.h"
39 #include "vtkSetGet.h"
40 
41 #define H5_USE_16_API
42 #include "vtk_hdf5.h"
43 
44 //==============================================================================
45 // I N T E R N A L F L A S H R E A D E R
46 //==============================================================================
47 
48 #define FLASH_READER_MAX_DIMS 3
49 #define FLASH_READER_LEAF_BLOCK 1
50 #define FLASH_READER_FLASH3_FFV8 8
51 #define FLASH_READER_FLASH3_FFV9 9
52 
53 VTK_ABI_NAMESPACE_BEGIN
55 {
56  char Name[20]; // name of the integer scalar
57  int Value; // value of the integer scalar
59 
61 {
62  char Name[20]; // name of the real scalar
63  double Value; // value of the real scalar
65 
67 {
68  int NumberOfBlocks; // number of all blocks
69  int NumberOfTimeSteps; // number of time steps
70  int NumberOfXDivisions; // number of divisions per block along x axis
71  int NumberOfYDivisions; // number of divisions per block along y axis
72  int NumberOfZDivisions; // number of divisions per block along z axis
73  double Time; // the time of this step
74  double TimeStep; // time interval
75  double RedShift;
77 
78 typedef struct tagFlashReaderBlock
79 {
80  int Index; // Id of the block
81  int Level; // LOD level
82  int Type; // a leaf block?
83  int ParentId; // Id of the parent block
84  int ChildrenIds[8]; // Ids of the children blocks
85  int NeighborIds[6]; // Ids of the neighboring blocks
86  int ProcessorId; // Id of the processor
87  int MinGlobalDivisionIds[3]; // first (global) division index
88  int MaxGlobalDivisionIds[3]; // last (global) division index
89  double Center[3]; // center of the block
90  double MinBounds[3]; // lower left of the bounding box
91  double MaxBounds[3]; // upper right of the bounding box
93 
95 {
97  char SetupCall[400];
98  char FileCreationTime[80];
99  char FlashVersion[80];
100  char BuildData[80];
101  char BuildDirectory[80];
102  char build_machine[80];
103  char CFlags[400];
104  char FFlags[400];
105  char SetupTimeStamp[80];
106  char BuildTimeStamp[80];
108 
110 {
111  std::string sepaName = variable;
112 
113  if (sepaName.length() > 9 && sepaName.substr(0, 9) == "particle_")
114  {
115  sepaName = std::string("Particles/") + sepaName.substr(9);
116  }
117  else
118  {
119  sepaName = std::string("Particles/") + sepaName;
120  }
121 
122  return sepaName;
123 }
124 
125 // ----------------------------------------------------------------------------
126 // Class vtkFlashReaderInternal (begin)
127 // ----------------------------------------------------------------------------
128 
130 {
131 public:
134 
135  int NumberOfBlocks; // number of ALL blocks
136  int NumberOfLevels; // number of levels
137  int FileFormatVersion; // version of file format
138  int NumberOfParticles; // number of particles
139  int NumberOfLeafBlocks; // number of leaf blocks
140  int NumberOfDimensions; // number of dimensions
141  int NumberOfProcessors; // number of processors
142  int HaveProcessorsInfo; // processor Ids available?
143  int BlockGridDimensions[3]; // number of grid points
144  int BlockCellDimensions[3]; // number of divisions
145  int NumberOfChildrenPerBlock; // number of children per block
146  int NumberOfNeighborsPerBlock; // number of neighbors per block
147 
148  char* FileName; // Flash data file name
149  hid_t FileIndex; // file handle
150  double MinBounds[3]; // lower left of the bounding-box
151  double MaxBounds[3]; // upper right of the bounding box
154 
155  // blocks
156  std::vector<FlashReaderBlock> Blocks;
157  std::vector<int> LeafBlocks;
158  std::vector<std::string> AttributeNames;
159 
160  // particles
162  std::vector<hid_t> ParticleAttributeTypes;
163  std::vector<std::string> ParticleAttributeNames;
164  std::map<std::string, int> ParticleAttributeNamesToIds;
165 
166  int GetCycle();
167  double GetTime();
168 
169  void Init();
170  void SetFileName(VTK_FILEPATH char* fileName) { this->FileName = fileName; }
171  const char* GetParticleName(char* variableName)
172  {
173  static std::string particleName;
174  particleName = GetSeparatedParticleName(std::string(variableName));
175  return particleName.c_str();
176  }
177 
178  void ReadMetaData();
180  void ReadDoubleScalars(hid_t fileIndx);
181  void ReadIntegerScalars(hid_t fileIndx);
182  void ReadVersionInformation(hid_t fileIndx);
183  void ReadSimulationParameters(hid_t fileIndx, bool bTmCycle = false); // time and cycle only
185 
192 
193  void ReadParticlesComponent(hid_t dataIndx, const char* compName, double* dataBuff);
196  void GetBlockAttribute(const char* attribute, int blockIdx, vtkDataSet* pDataSet);
197 };
198 
199 // ----------------------------------------------------------------------------
200 // Class vtkFlashReaderInternal ( end )
201 // ----------------------------------------------------------------------------
202 VTK_ABI_NAMESPACE_END
203 #endif /* vtkAMRFlashReaderInternal_h */
204 // VTK-HeaderTest-Exclude: vtkAMRFlashReaderInternal.h
abstract class to specify dataset behavior
Definition: vtkDataSet.h:174
void ReadIntegerScalars(hid_t fileIndx)
void ReadVersionInformation(hid_t fileIndx)
FlashReaderSimulationParameters SimulationParameters
std::map< std::string, int > ParticleAttributeNamesToIds
void ReadParticleAttributesFLASH3()
void GetBlockMinMaxGlobalDivisionIds()
std::vector< FlashReaderBlock > Blocks
FlashReaderSimulationInformation SimulationInformation
void GetBlockAttribute(const char *attribute, int blockIdx, vtkDataSet *pDataSet)
std::vector< std::string > AttributeNames
void ReadDoubleScalars(hid_t fileIndx)
void ReadParticlesComponent(hid_t dataIndx, const char *compName, double *dataBuff)
std::vector< std::string > ParticleAttributeNames
const char * GetParticleName(char *variableName)
void ReadSimulationParameters(hid_t fileIndx, bool bTmCycle=false)
std::vector< hid_t > ParticleAttributeTypes
void SetFileName(VTK_FILEPATH char *fileName)
@ string
Definition: vtkX3D.h:502
static std::string GetSeparatedParticleName(const std::string &variable)
struct tagFlashReaderBlock FlashReaderBlock
struct tagFlashReaderSimulationParameters FlashReaderSimulationParameters
struct tagFlashReaderDoubleScalar FlashReaderDoubleScalar
struct tagFlashReaderIntegerScalar FlashReaderIntegerScalar
struct tagFlashReaderSimulationInformation FlashReaderSimulationInformation
#define VTK_FILEPATH