VTK  9.1.0
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 
54 {
55  char Name[20]; // name of the integer scalar
56  int Value; // value of the integer scalar
58 
60 {
61  char Name[20]; // name of the real scalar
62  double Value; // value of the real scalar
64 
66 {
67  int NumberOfBlocks; // number of all blocks
68  int NumberOfTimeSteps; // number of time steps
69  int NumberOfXDivisions; // number of divisions per block along x axis
70  int NumberOfYDivisions; // number of divisions per block along y axis
71  int NumberOfZDivisions; // number of divisions per block along z axis
72  double Time; // the time of this step
73  double TimeStep; // time interval
74  double RedShift;
76 
77 typedef struct tagBlock
78 {
79  int Index; // Id of the block
80  int Level; // LOD level
81  int Type; // a leaf block?
82  int ParentId; // Id of the parent block
83  int ChildrenIds[8]; // Ids of the children blocks
84  int NeighborIds[6]; // Ids of the neighboring blocks
85  int ProcessorId; // Id of the processor
86  int MinGlobalDivisionIds[3]; // first (global) division index
87  int MaxGlobalDivisionIds[3]; // last (global) division index
88  double Center[3]; // center of the block
89  double MinBounds[3]; // lower left of the bounding box
90  double MaxBounds[3]; // upper right of the bounding box
92 
94 {
96  char SetupCall[400];
97  char FileCreationTime[80];
98  char FlashVersion[80];
99  char BuildData[80];
100  char BuildDirectory[80];
101  char build_machine[80];
102  char CFlags[400];
103  char FFlags[400];
104  char SetupTimeStamp[80];
105  char BuildTimeStamp[80];
107 
109 {
110  std::string sepaName = variable;
111 
112  if (sepaName.length() > 9 && sepaName.substr(0, 9) == "particle_")
113  {
114  sepaName = std::string("Particles/") + sepaName.substr(9);
115  }
116  else
117  {
118  sepaName = std::string("Particles/") + sepaName;
119  }
120 
121  return sepaName;
122 }
123 
124 // ----------------------------------------------------------------------------
125 // Class vtkFlashReaderInternal (begin)
126 // ----------------------------------------------------------------------------
127 
129 {
130 public:
133 
134  int NumberOfBlocks; // number of ALL blocks
135  int NumberOfLevels; // number of levels
136  int FileFormatVersion; // version of file format
137  int NumberOfParticles; // number of particles
138  int NumberOfLeafBlocks; // number of leaf blocks
139  int NumberOfDimensions; // number of dimensions
140  int NumberOfProcessors; // number of processors
141  int HaveProcessorsInfo; // processor Ids available?
142  int BlockGridDimensions[3]; // number of grid points
143  int BlockCellDimensions[3]; // number of divisions
144  int NumberOfChildrenPerBlock; // number of children per block
145  int NumberOfNeighborsPerBlock; // number of neighbors per block
146 
147  char* FileName; // Flash data file name
148  hid_t FileIndex; // file handle
149  double MinBounds[3]; // lower left of the bounding-box
150  double MaxBounds[3]; // upper right of the bounding box
153 
154  // blocks
155  std::vector<Block> Blocks;
156  std::vector<int> LeafBlocks;
157  std::vector<std::string> AttributeNames;
158 
159  // particles
161  std::vector<hid_t> ParticleAttributeTypes;
162  std::vector<std::string> ParticleAttributeNames;
163  std::map<std::string, int> ParticleAttributeNamesToIds;
164 
165  int GetCycle();
166  double GetTime();
167 
168  void Init();
169  void SetFileName(VTK_FILEPATH char* fileName) { this->FileName = fileName; }
170  const char* GetParticleName(char* variableName)
171  {
172  static std::string particleName;
173  particleName = GetSeparatedParticleName(std::string(variableName));
174  return particleName.c_str();
175  }
176 
177  void ReadMetaData();
179  void ReadDoubleScalars(hid_t fileIndx);
180  void ReadIntegerScalars(hid_t fileIndx);
181  void ReadVersionInformation(hid_t fileIndx);
182  void ReadSimulationParameters(hid_t fileIndx, bool bTmCycle = false); // time and cycle only
184 
191 
192  void ReadParticlesComponent(hid_t dataIndx, const char* compName, double* dataBuff);
195  void GetBlockAttribute(const char* attribute, int blockIdx, vtkDataSet* pDataSet);
196 };
197 
198 // ----------------------------------------------------------------------------
199 // Class vtkFlashReaderInternal ( end )
200 // ----------------------------------------------------------------------------
201 #endif /* vtkAMRFlashReaderInternal_h */
202 // VTK-HeaderTest-Exclude: vtkAMRFlashReaderInternal.h
vtkFlashReaderInternal::FileIndex
hid_t FileIndex
Definition: vtkAMRFlashReaderInternal.h:148
vtkFlashReaderInternal::Blocks
std::vector< Block > Blocks
Definition: vtkAMRFlashReaderInternal.h:155
vtkFlashReaderInternal::NumberOfLevels
int NumberOfLevels
Definition: vtkAMRFlashReaderInternal.h:135
tagBlock::Index
int Index
Definition: vtkAMRFlashReaderInternal.h:79
tagFlashReaderSimulationInformation::BuildDirectory
char BuildDirectory[80]
Definition: vtkAMRFlashReaderInternal.h:100
vtkFlashReaderInternal::FileFormatVersion
int FileFormatVersion
Definition: vtkAMRFlashReaderInternal.h:136
vtkFlashReaderInternal::SimulationInformation
FlashReaderSimulationInformation SimulationInformation
Definition: vtkAMRFlashReaderInternal.h:152
tagFlashReaderSimulationInformation::FileFormatVersion
int FileFormatVersion
Definition: vtkAMRFlashReaderInternal.h:95
tagFlashReaderSimulationInformation::FlashVersion
char FlashVersion[80]
Definition: vtkAMRFlashReaderInternal.h:98
vtkFlashReaderInternal::SimulationParameters
FlashReaderSimulationParameters SimulationParameters
Definition: vtkAMRFlashReaderInternal.h:151
VTK_FILEPATH
#define VTK_FILEPATH
Definition: vtkWrappingHints.h:46
FlashReaderIntegerScalar
struct tagFlashReaderIntegerScalar FlashReaderIntegerScalar
tagFlashReaderSimulationParameters::NumberOfXDivisions
int NumberOfXDivisions
Definition: vtkAMRFlashReaderInternal.h:69
vtkFlashReaderInternal::vtkFlashReaderInternal
vtkFlashReaderInternal()
Definition: vtkAMRFlashReaderInternal.h:131
tagFlashReaderSimulationParameters::NumberOfZDivisions
int NumberOfZDivisions
Definition: vtkAMRFlashReaderInternal.h:71
tagFlashReaderSimulationParameters
Definition: vtkAMRFlashReaderInternal.h:66
vtkFlashReaderInternal
Definition: vtkAMRFlashReaderInternal.h:129
tagFlashReaderSimulationParameters::NumberOfYDivisions
int NumberOfYDivisions
Definition: vtkAMRFlashReaderInternal.h:70
tagFlashReaderSimulationParameters::RedShift
double RedShift
Definition: vtkAMRFlashReaderInternal.h:74
tagBlock
Definition: vtkAMRFlashReaderInternal.h:78
tagFlashReaderIntegerScalar::Name
char Name[20]
Definition: vtkAMRFlashReaderInternal.h:55
tagFlashReaderSimulationInformation::SetupTimeStamp
char SetupTimeStamp[80]
Definition: vtkAMRFlashReaderInternal.h:104
vtkFlashReaderInternal::LeafBlocks
std::vector< int > LeafBlocks
Definition: vtkAMRFlashReaderInternal.h:156
vtkFlashReaderInternal::MaxBounds
double MaxBounds[3]
Definition: vtkAMRFlashReaderInternal.h:150
tagBlock::Center
double Center[3]
Definition: vtkAMRFlashReaderInternal.h:88
tagBlock::MaxBounds
double MaxBounds[3]
Definition: vtkAMRFlashReaderInternal.h:90
vtkFlashReaderInternal::ReadSimulationParameters
void ReadSimulationParameters(hid_t fileIndx, bool bTmCycle=false)
tagFlashReaderSimulationParameters::NumberOfBlocks
int NumberOfBlocks
Definition: vtkAMRFlashReaderInternal.h:67
vtkFlashReaderInternal::ReadMetaData
void ReadMetaData()
vtkFlashReaderInternal::ParticleName
std::string ParticleName
Definition: vtkAMRFlashReaderInternal.h:160
vtkFlashReaderInternal::ParticleAttributeNamesToIds
std::map< std::string, int > ParticleAttributeNamesToIds
Definition: vtkAMRFlashReaderInternal.h:163
vtkFlashReaderInternal::NumberOfNeighborsPerBlock
int NumberOfNeighborsPerBlock
Definition: vtkAMRFlashReaderInternal.h:145
vtkFlashReaderInternal::GetTime
double GetTime()
tagFlashReaderSimulationParameters::NumberOfTimeSteps
int NumberOfTimeSteps
Definition: vtkAMRFlashReaderInternal.h:68
vtkFlashReaderInternal::ReadVersionInformation
void ReadVersionInformation(hid_t fileIndx)
vtkFlashReaderInternal::ReadParticleAttributesFLASH3
void ReadParticleAttributesFLASH3()
tagFlashReaderSimulationInformation::build_machine
char build_machine[80]
Definition: vtkAMRFlashReaderInternal.h:101
tagFlashReaderDoubleScalar::Name
char Name[20]
Definition: vtkAMRFlashReaderInternal.h:61
tagFlashReaderSimulationInformation::FileCreationTime
char FileCreationTime[80]
Definition: vtkAMRFlashReaderInternal.h:97
vtkFlashReaderInternal::GetBlockAttribute
void GetBlockAttribute(const char *attribute, int blockIdx, vtkDataSet *pDataSet)
vtkFlashReaderInternal::Init
void Init()
tagFlashReaderSimulationInformation
Definition: vtkAMRFlashReaderInternal.h:94
vtkFlashReaderInternal::GetCycle
int GetCycle()
tagBlock::MinBounds
double MinBounds[3]
Definition: vtkAMRFlashReaderInternal.h:89
FlashReaderSimulationParameters
struct tagFlashReaderSimulationParameters FlashReaderSimulationParameters
vtkFlashReaderInternal::ReadIntegerScalars
void ReadIntegerScalars(hid_t fileIndx)
tagFlashReaderSimulationInformation::SetupCall
char SetupCall[400]
Definition: vtkAMRFlashReaderInternal.h:96
vtkFlashReaderInternal::NumberOfProcessors
int NumberOfProcessors
Definition: vtkAMRFlashReaderInternal.h:140
vtkFlashReaderInternal::ReadParticlesComponent
void ReadParticlesComponent(hid_t dataIndx, const char *compName, double *dataBuff)
tagFlashReaderSimulationInformation::BuildTimeStamp
char BuildTimeStamp[80]
Definition: vtkAMRFlashReaderInternal.h:105
vtkByteSwap.h
tagBlock::Type
int Type
Definition: vtkAMRFlashReaderInternal.h:81
vtkFlashReaderInternal::MinBounds
double MinBounds[3]
Definition: vtkAMRFlashReaderInternal.h:149
vtkFlashReaderInternal::NumberOfDimensions
int NumberOfDimensions
Definition: vtkAMRFlashReaderInternal.h:139
vtkFlashReaderInternal::HaveProcessorsInfo
int HaveProcessorsInfo
Definition: vtkAMRFlashReaderInternal.h:141
FlashReaderSimulationInformation
struct tagFlashReaderSimulationInformation FlashReaderSimulationInformation
vtkDoubleArray.h
tagBlock::MaxGlobalDivisionIds
int MaxGlobalDivisionIds[3]
Definition: vtkAMRFlashReaderInternal.h:87
vtkFlashReaderInternal::ReadBlockCenters
void ReadBlockCenters()
tagBlock::NeighborIds
int NeighborIds[6]
Definition: vtkAMRFlashReaderInternal.h:84
vtkFlashReaderInternal::GetParticleName
const char * GetParticleName(char *variableName)
Definition: vtkAMRFlashReaderInternal.h:170
tagFlashReaderSimulationInformation::CFlags
char CFlags[400]
Definition: vtkAMRFlashReaderInternal.h:102
vtkFlashReaderInternal::ReadBlockStructures
void ReadBlockStructures()
tagFlashReaderDoubleScalar
Definition: vtkAMRFlashReaderInternal.h:60
vtkFlashReaderInternal::ReadBlockTypes
void ReadBlockTypes()
tagFlashReaderSimulationInformation::FFlags
char FFlags[400]
Definition: vtkAMRFlashReaderInternal.h:103
tagFlashReaderSimulationInformation::BuildData
char BuildData[80]
Definition: vtkAMRFlashReaderInternal.h:99
tagBlock::ChildrenIds
int ChildrenIds[8]
Definition: vtkAMRFlashReaderInternal.h:83
vtkFlashReaderInternal::NumberOfLeafBlocks
int NumberOfLeafBlocks
Definition: vtkAMRFlashReaderInternal.h:138
vtkFlashReaderInternal::~vtkFlashReaderInternal
~vtkFlashReaderInternal()
Definition: vtkAMRFlashReaderInternal.h:132
vtkFlashReaderInternal::ReadParticleAttributes
void ReadParticleAttributes()
vtkFlashReaderInternal::ReadRefinementLevels
void ReadRefinementLevels()
vtkObject.h
vtkFlashReaderInternal::AttributeNames
std::vector< std::string > AttributeNames
Definition: vtkAMRFlashReaderInternal.h:157
vtkDataSet.h
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:166
vtkFlashReaderInternal::GetBlockMinMaxGlobalDivisionIds
void GetBlockMinMaxGlobalDivisionIds()
vtkFlashReaderInternal::FileName
char * FileName
Definition: vtkAMRFlashReaderInternal.h:147
vtkFlashReaderInternal::ReadDataAttributeNames
void ReadDataAttributeNames()
Block
struct tagBlock Block
tagFlashReaderSimulationParameters::Time
double Time
Definition: vtkAMRFlashReaderInternal.h:72
vtkX3D::string
@ string
Definition: vtkX3D.h:496
vtkIntArray.h
vtkFlashReaderInternal::NumberOfBlocks
int NumberOfBlocks
Definition: vtkAMRFlashReaderInternal.h:134
tagFlashReaderSimulationParameters::TimeStep
double TimeStep
Definition: vtkAMRFlashReaderInternal.h:73
vtkFlashReaderInternal::BlockCellDimensions
int BlockCellDimensions[3]
Definition: vtkAMRFlashReaderInternal.h:143
vtkDataArray.h
GetSeparatedParticleName
static std::string GetSeparatedParticleName(const std::string &variable)
Definition: vtkAMRFlashReaderInternal.h:108
vtkCellData.h
FlashReaderDoubleScalar
struct tagFlashReaderDoubleScalar FlashReaderDoubleScalar
tagBlock::ProcessorId
int ProcessorId
Definition: vtkAMRFlashReaderInternal.h:85
tagFlashReaderIntegerScalar
Definition: vtkAMRFlashReaderInternal.h:54
tagFlashReaderIntegerScalar::Value
int Value
Definition: vtkAMRFlashReaderInternal.h:56
tagBlock::MinGlobalDivisionIds
int MinGlobalDivisionIds[3]
Definition: vtkAMRFlashReaderInternal.h:86
vtkFlashReaderInternal::SetFileName
void SetFileName(VTK_FILEPATH char *fileName)
Definition: vtkAMRFlashReaderInternal.h:169
vtkFlashReaderInternal::NumberOfParticles
int NumberOfParticles
Definition: vtkAMRFlashReaderInternal.h:137
tagBlock::Level
int Level
Definition: vtkAMRFlashReaderInternal.h:80
tagFlashReaderDoubleScalar::Value
double Value
Definition: vtkAMRFlashReaderInternal.h:62
vtkFlashReaderInternal::ParticleAttributeTypes
std::vector< hid_t > ParticleAttributeTypes
Definition: vtkAMRFlashReaderInternal.h:161
vtkFlashReaderInternal::ReadDoubleScalars
void ReadDoubleScalars(hid_t fileIndx)
vtkFlashReaderInternal::BlockGridDimensions
int BlockGridDimensions[3]
Definition: vtkAMRFlashReaderInternal.h:142
vtkFlashReaderInternal::ReadProcessorIds
void ReadProcessorIds()
tagBlock::ParentId
int ParentId
Definition: vtkAMRFlashReaderInternal.h:82
vtkFlashReaderInternal::ReadBlockBounds
void ReadBlockBounds()
vtkFlashReaderInternal::ParticleAttributeNames
std::vector< std::string > ParticleAttributeNames
Definition: vtkAMRFlashReaderInternal.h:162
vtkFlashReaderInternal::NumberOfChildrenPerBlock
int NumberOfChildrenPerBlock
Definition: vtkAMRFlashReaderInternal.h:144