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