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 =========================================================================*/
24 #ifndef VTKAMRFLASHREADERINTERNAL_HPP_
25 #define VTKAMRFLASHREADERINTERNAL_HPP_
26 
27 #include <cassert>
28 #include <vector>
29 #include <map>
30 #include <cstring>
31 #include <string>
32 
33 #include "vtkSetGet.h"
34 #include "vtkDataSet.h"
35 #include "vtkObject.h"
36 #include "vtkDataArray.h"
37 #include "vtkDoubleArray.h"
38 #include "vtkIntArray.h"
39 #include "vtkCellData.h"
40 #include "vtkByteSwap.h"
41 
42 #define H5_USE_16_API
43 #include "vtk_hdf5.h"
44 
45 //==============================================================================
46 // I N T E R N A L F L A S H R E A D E R
47 //==============================================================================
48 
49 #define FLASH_READER_MAX_DIMS 3
50 #define FLASH_READER_LEAF_BLOCK 1
51 #define FLASH_READER_FLASH3_FFV8 8
52 #define FLASH_READER_FLASH3_FFV9 9
53 
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 tagBlock
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 // ----------------------------------------------------------------------------
127 // Class vtkFlashReaderInternal (begin)
128 // ----------------------------------------------------------------------------
129 
130 
132 {
133 public:
136 
137  int NumberOfBlocks; // number of ALL blocks
138  int NumberOfLevels; // number of levels
139  int FileFormatVersion; // version of file format
140  int NumberOfParticles; // number of particles
141  int NumberOfLeafBlocks; // number of leaf blocks
142  int NumberOfDimensions; // number of dimensions
143  int NumberOfProcessors; // number of processors
144  int HaveProcessorsInfo; // processor Ids available?
145  int BlockGridDimensions[3]; // number of grid points
146  int BlockCellDimensions[3]; // number of divisions
147  int NumberOfChildrenPerBlock; // number of children per block
148  int NumberOfNeighborsPerBlock; // number of neighbors per block
149 
150  char * FileName; // Flash data file name
151  hid_t FileIndex; // file handle
152  double MinBounds[3]; // lower left of the bounding-box
153  double MaxBounds[3]; // upper right of the bounding box
156 
157  // blocks
158  std::vector< Block > Blocks;
159  std::vector< int > LeafBlocks;
160  std::vector< std::string > AttributeNames;
161 
162  // particles
164  std::vector< hid_t > ParticleAttributeTypes;
165  std::vector< std::string > ParticleAttributeNames;
166  std::map< std::string, int > ParticleAttributeNamesToIds;
167 
168 
169  int GetCycle();
170  double GetTime();
171 
172  void Init();
173  void SetFileName( char * fileName ) { this->FileName = fileName; }
174  const char* GetParticleName(char* variableName)
175  {
176  static std::string particleName;
177  particleName = GetSeparatedParticleName(std::string(variableName));
178  return particleName.c_str();
179  }
180 
181  void ReadMetaData();
183  void ReadDoubleScalars( hid_t fileIndx );
184  void ReadIntegerScalars( hid_t fileIndx );
185  void ReadVersionInformation( hid_t fileIndx );
187  ( hid_t fileIndx, bool bTmCycle = false ); // time and cycle only
189 
196 
198  ( hid_t dataIndx, const char * compName, double * dataBuff );
201  void GetBlockAttribute( const char *atribute, int blockIdx,
202  vtkDataSet *pDataSet );
203 };
204 
205 
206 
207 
208 // ----------------------------------------------------------------------------
209 // Class vtkFlashReaderInternal ( end )
210 // ----------------------------------------------------------------------------
211 #endif /* VTKAMRFLASHREADERINTERNAL_HPP_ */
212 // VTK-HeaderTest-Exclude: vtkAMRFlashReaderInternal.h
vtkFlashReaderInternal::FileIndex
hid_t FileIndex
Definition: vtkAMRFlashReaderInternal.h:151
vtkFlashReaderInternal::NumberOfLevels
int NumberOfLevels
Definition: vtkAMRFlashReaderInternal.h:138
tagBlock::Index
int Index
Definition: vtkAMRFlashReaderInternal.h:80
tagFlashReaderSimulationInformation::BuildDirectory
char BuildDirectory[80]
Definition: vtkAMRFlashReaderInternal.h:101
vtkFlashReaderInternal::FileFormatVersion
int FileFormatVersion
Definition: vtkAMRFlashReaderInternal.h:139
vtkFlashReaderInternal::SimulationInformation
FlashReaderSimulationInformation SimulationInformation
Definition: vtkAMRFlashReaderInternal.h:155
tagFlashReaderSimulationInformation::FileFormatVersion
int FileFormatVersion
Definition: vtkAMRFlashReaderInternal.h:96
tagFlashReaderSimulationInformation::FlashVersion
char FlashVersion[80]
Definition: vtkAMRFlashReaderInternal.h:99
vtkFlashReaderInternal::SimulationParameters
FlashReaderSimulationParameters SimulationParameters
Definition: vtkAMRFlashReaderInternal.h:154
FlashReaderIntegerScalar
struct tagFlashReaderIntegerScalar FlashReaderIntegerScalar
tagFlashReaderSimulationParameters::NumberOfXDivisions
int NumberOfXDivisions
Definition: vtkAMRFlashReaderInternal.h:70
vtkFlashReaderInternal::vtkFlashReaderInternal
vtkFlashReaderInternal()
Definition: vtkAMRFlashReaderInternal.h:134
tagFlashReaderSimulationParameters::NumberOfZDivisions
int NumberOfZDivisions
Definition: vtkAMRFlashReaderInternal.h:72
tagFlashReaderSimulationParameters
Definition: vtkAMRFlashReaderInternal.h:67
vtkFlashReaderInternal
Definition: vtkAMRFlashReaderInternal.h:132
tagFlashReaderSimulationParameters::NumberOfYDivisions
int NumberOfYDivisions
Definition: vtkAMRFlashReaderInternal.h:71
tagFlashReaderSimulationParameters::RedShift
double RedShift
Definition: vtkAMRFlashReaderInternal.h:75
tagBlock
Definition: vtkAMRFlashReaderInternal.h:79
tagFlashReaderIntegerScalar::Name
char Name[20]
Definition: vtkAMRFlashReaderInternal.h:56
tagFlashReaderSimulationInformation::SetupTimeStamp
char SetupTimeStamp[80]
Definition: vtkAMRFlashReaderInternal.h:105
vtkFlashReaderInternal::MaxBounds
double MaxBounds[3]
Definition: vtkAMRFlashReaderInternal.h:153
tagBlock::Center
double Center[3]
Definition: vtkAMRFlashReaderInternal.h:89
tagBlock::MaxBounds
double MaxBounds[3]
Definition: vtkAMRFlashReaderInternal.h:91
vtkSetGet.h
vtkFlashReaderInternal::ReadSimulationParameters
void ReadSimulationParameters(hid_t fileIndx, bool bTmCycle=false)
tagFlashReaderSimulationParameters::NumberOfBlocks
int NumberOfBlocks
Definition: vtkAMRFlashReaderInternal.h:68
vtkFlashReaderInternal::ReadMetaData
void ReadMetaData()
vtkFlashReaderInternal::ParticleName
std::string ParticleName
Definition: vtkAMRFlashReaderInternal.h:163
vtkFlashReaderInternal::NumberOfNeighborsPerBlock
int NumberOfNeighborsPerBlock
Definition: vtkAMRFlashReaderInternal.h:148
vtkFlashReaderInternal::GetTime
double GetTime()
tagFlashReaderSimulationParameters::NumberOfTimeSteps
int NumberOfTimeSteps
Definition: vtkAMRFlashReaderInternal.h:69
vtkFlashReaderInternal::ReadVersionInformation
void ReadVersionInformation(hid_t fileIndx)
vtkFlashReaderInternal::ReadParticleAttributesFLASH3
void ReadParticleAttributesFLASH3()
tagFlashReaderSimulationInformation::build_machine
char build_machine[80]
Definition: vtkAMRFlashReaderInternal.h:102
tagFlashReaderDoubleScalar::Name
char Name[20]
Definition: vtkAMRFlashReaderInternal.h:62
tagFlashReaderSimulationInformation::FileCreationTime
char FileCreationTime[80]
Definition: vtkAMRFlashReaderInternal.h:98
vtkFlashReaderInternal::Init
void Init()
tagFlashReaderSimulationInformation
Definition: vtkAMRFlashReaderInternal.h:95
vtkFlashReaderInternal::GetCycle
int GetCycle()
tagBlock::MinBounds
double MinBounds[3]
Definition: vtkAMRFlashReaderInternal.h:90
FlashReaderSimulationParameters
struct tagFlashReaderSimulationParameters FlashReaderSimulationParameters
vtkFlashReaderInternal::ReadIntegerScalars
void ReadIntegerScalars(hid_t fileIndx)
tagFlashReaderSimulationInformation::SetupCall
char SetupCall[400]
Definition: vtkAMRFlashReaderInternal.h:97
vtkFlashReaderInternal::NumberOfProcessors
int NumberOfProcessors
Definition: vtkAMRFlashReaderInternal.h:143
vtkFlashReaderInternal::ReadParticlesComponent
void ReadParticlesComponent(hid_t dataIndx, const char *compName, double *dataBuff)
tagFlashReaderSimulationInformation::BuildTimeStamp
char BuildTimeStamp[80]
Definition: vtkAMRFlashReaderInternal.h:106
vtkByteSwap.h
vtkFlashReaderInternal::Blocks
std::vector< Block > Blocks
Definition: vtkAMRFlashReaderInternal.h:158
tagBlock::Type
int Type
Definition: vtkAMRFlashReaderInternal.h:82
vtkFlashReaderInternal::ParticleAttributeNamesToIds
std::map< std::string, int > ParticleAttributeNamesToIds
Definition: vtkAMRFlashReaderInternal.h:166
vtkFlashReaderInternal::MinBounds
double MinBounds[3]
Definition: vtkAMRFlashReaderInternal.h:152
vtkFlashReaderInternal::AttributeNames
std::vector< std::string > AttributeNames
Definition: vtkAMRFlashReaderInternal.h:160
vtkFlashReaderInternal::NumberOfDimensions
int NumberOfDimensions
Definition: vtkAMRFlashReaderInternal.h:142
vtkFlashReaderInternal::HaveProcessorsInfo
int HaveProcessorsInfo
Definition: vtkAMRFlashReaderInternal.h:144
FlashReaderSimulationInformation
struct tagFlashReaderSimulationInformation FlashReaderSimulationInformation
vtkDoubleArray.h
tagBlock::MaxGlobalDivisionIds
int MaxGlobalDivisionIds[3]
Definition: vtkAMRFlashReaderInternal.h:88
vtkFlashReaderInternal::ReadBlockCenters
void ReadBlockCenters()
tagBlock::NeighborIds
int NeighborIds[6]
Definition: vtkAMRFlashReaderInternal.h:85
vtkFlashReaderInternal::GetParticleName
const char * GetParticleName(char *variableName)
Definition: vtkAMRFlashReaderInternal.h:174
tagFlashReaderSimulationInformation::CFlags
char CFlags[400]
Definition: vtkAMRFlashReaderInternal.h:103
vtkFlashReaderInternal::ReadBlockStructures
void ReadBlockStructures()
tagFlashReaderDoubleScalar
Definition: vtkAMRFlashReaderInternal.h:61
vtkFlashReaderInternal::ReadBlockTypes
void ReadBlockTypes()
tagFlashReaderSimulationInformation::FFlags
char FFlags[400]
Definition: vtkAMRFlashReaderInternal.h:104
tagFlashReaderSimulationInformation::BuildData
char BuildData[80]
Definition: vtkAMRFlashReaderInternal.h:100
tagBlock::ChildrenIds
int ChildrenIds[8]
Definition: vtkAMRFlashReaderInternal.h:84
vtkFlashReaderInternal::NumberOfLeafBlocks
int NumberOfLeafBlocks
Definition: vtkAMRFlashReaderInternal.h:141
vtkFlashReaderInternal::~vtkFlashReaderInternal
~vtkFlashReaderInternal()
Definition: vtkAMRFlashReaderInternal.h:135
vtkFlashReaderInternal::SetFileName
void SetFileName(char *fileName)
Definition: vtkAMRFlashReaderInternal.h:173
vtkFlashReaderInternal::ReadParticleAttributes
void ReadParticleAttributes()
vtkFlashReaderInternal::LeafBlocks
std::vector< int > LeafBlocks
Definition: vtkAMRFlashReaderInternal.h:159
vtkFlashReaderInternal::ReadRefinementLevels
void ReadRefinementLevels()
vtkObject.h
vtkDataSet.h
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkFlashReaderInternal::GetBlockMinMaxGlobalDivisionIds
void GetBlockMinMaxGlobalDivisionIds()
vtkFlashReaderInternal::FileName
char * FileName
Definition: vtkAMRFlashReaderInternal.h:150
vtkFlashReaderInternal::ReadDataAttributeNames
void ReadDataAttributeNames()
Block
struct tagBlock Block
tagFlashReaderSimulationParameters::Time
double Time
Definition: vtkAMRFlashReaderInternal.h:73
vtkIntArray.h
vtkFlashReaderInternal::NumberOfBlocks
int NumberOfBlocks
Definition: vtkAMRFlashReaderInternal.h:137
tagFlashReaderSimulationParameters::TimeStep
double TimeStep
Definition: vtkAMRFlashReaderInternal.h:74
vtkFlashReaderInternal::ParticleAttributeTypes
std::vector< hid_t > ParticleAttributeTypes
Definition: vtkAMRFlashReaderInternal.h:164
vtkFlashReaderInternal::BlockCellDimensions
int BlockCellDimensions[3]
Definition: vtkAMRFlashReaderInternal.h:146
vtkDataArray.h
GetSeparatedParticleName
static std::string GetSeparatedParticleName(const std::string &variable)
Definition: vtkAMRFlashReaderInternal.h:109
vtkCellData.h
FlashReaderDoubleScalar
struct tagFlashReaderDoubleScalar FlashReaderDoubleScalar
vtkFlashReaderInternal::ParticleAttributeNames
std::vector< std::string > ParticleAttributeNames
Definition: vtkAMRFlashReaderInternal.h:165
tagBlock::ProcessorId
int ProcessorId
Definition: vtkAMRFlashReaderInternal.h:86
tagFlashReaderIntegerScalar
Definition: vtkAMRFlashReaderInternal.h:55
tagFlashReaderIntegerScalar::Value
int Value
Definition: vtkAMRFlashReaderInternal.h:57
tagBlock::MinGlobalDivisionIds
int MinGlobalDivisionIds[3]
Definition: vtkAMRFlashReaderInternal.h:87
vtkFlashReaderInternal::GetBlockAttribute
void GetBlockAttribute(const char *atribute, int blockIdx, vtkDataSet *pDataSet)
vtkFlashReaderInternal::NumberOfParticles
int NumberOfParticles
Definition: vtkAMRFlashReaderInternal.h:140
tagBlock::Level
int Level
Definition: vtkAMRFlashReaderInternal.h:81
tagFlashReaderDoubleScalar::Value
double Value
Definition: vtkAMRFlashReaderInternal.h:63
vtkgl::variable
GLenum GLenum variable
Definition: vtkgl.h:15941
vtkFlashReaderInternal::ReadDoubleScalars
void ReadDoubleScalars(hid_t fileIndx)
vtkgl::string
GLsizei const GLchar ** string
Definition: vtkgl.h:12011
vtkFlashReaderInternal::BlockGridDimensions
int BlockGridDimensions[3]
Definition: vtkAMRFlashReaderInternal.h:145
vtkFlashReaderInternal::ReadProcessorIds
void ReadProcessorIds()
tagBlock::ParentId
int ParentId
Definition: vtkAMRFlashReaderInternal.h:83
vtkFlashReaderInternal::ReadBlockBounds
void ReadBlockBounds()
vtkFlashReaderInternal::NumberOfChildrenPerBlock
int NumberOfChildrenPerBlock
Definition: vtkAMRFlashReaderInternal.h:147