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 <vector>
30 #include <map>
31 #include <cstring>
32 #include <string>
33 
34 #include "vtkSetGet.h"
35 #include "vtkDataSet.h"
36 #include "vtkObject.h"
37 #include "vtkDataArray.h"
38 #include "vtkDoubleArray.h"
39 #include "vtkIntArray.h"
40 #include "vtkCellData.h"
41 #include "vtkByteSwap.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 // ----------------------------------------------------------------------------
128 // Class vtkFlashReaderInternal (begin)
129 // ----------------------------------------------------------------------------
130 
131 
133 {
134 public:
137 
138  int NumberOfBlocks; // number of ALL blocks
139  int NumberOfLevels; // number of levels
140  int FileFormatVersion; // version of file format
141  int NumberOfParticles; // number of particles
142  int NumberOfLeafBlocks; // number of leaf blocks
143  int NumberOfDimensions; // number of dimensions
144  int NumberOfProcessors; // number of processors
145  int HaveProcessorsInfo; // processor Ids available?
146  int BlockGridDimensions[3]; // number of grid points
147  int BlockCellDimensions[3]; // number of divisions
148  int NumberOfChildrenPerBlock; // number of children per block
149  int NumberOfNeighborsPerBlock; // number of neighbors per block
150 
151  char * FileName; // Flash data file name
152  hid_t FileIndex; // file handle
153  double MinBounds[3]; // lower left of the bounding-box
154  double MaxBounds[3]; // upper right of the bounding box
157 
158  // blocks
159  std::vector< Block > Blocks;
160  std::vector< int > LeafBlocks;
161  std::vector< std::string > AttributeNames;
162 
163  // particles
165  std::vector< hid_t > ParticleAttributeTypes;
166  std::vector< std::string > ParticleAttributeNames;
167  std::map< std::string, int > ParticleAttributeNamesToIds;
168 
169 
170  int GetCycle();
171  double GetTime();
172 
173  void Init();
174  void SetFileName( char * fileName ) { this->FileName = fileName; }
175  const char* GetParticleName(char* variableName)
176  {
177  static std::string particleName;
178  particleName = GetSeparatedParticleName(std::string(variableName));
179  return particleName.c_str();
180  }
181 
182  void ReadMetaData();
183  void ReadProcessorIds();
184  void ReadDoubleScalars( hid_t fileIndx );
185  void ReadIntegerScalars( hid_t fileIndx );
186  void ReadVersionInformation( hid_t fileIndx );
188  ( hid_t fileIndx, bool bTmCycle = false ); // time and cycle only
190 
191  void ReadBlockTypes();
192  void ReadBlockBounds();
193  void ReadBlockCenters();
194  void ReadBlockStructures();
195  void ReadRefinementLevels();
196  void ReadDataAttributeNames();
197 
199  ( hid_t dataIndx, const char * compName, double * dataBuff );
200  void ReadParticleAttributes();
202  void GetBlockAttribute( const char *atribute, int blockIdx,
203  vtkDataSet *pDataSet );
204 };
205 
206 
207 
208 
209 // ----------------------------------------------------------------------------
210 // Class vtkFlashReaderInternal ( end )
211 // ----------------------------------------------------------------------------
212 #endif /* vtkAMRFlashReaderInternal_h */
213 // VTK-HeaderTest-Exclude: vtkAMRFlashReaderInternal.h
void ReadIntegerScalars(hid_t fileIndx)
FlashReaderSimulationInformation SimulationInformation
void ReadParticleAttributesFLASH3()
std::map< std::string, int > ParticleAttributeNamesToIds
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
const char * GetParticleName(char *variableName)
void GetBlockAttribute(const char *atribute, int blockIdx, vtkDataSet *pDataSet)
struct tagBlock Block
FlashReaderSimulationParameters SimulationParameters
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
std::vector< hid_t > ParticleAttributeTypes
struct tagFlashReaderDoubleScalar FlashReaderDoubleScalar
void GetBlockMinMaxGlobalDivisionIds()
static std::string GetSeparatedParticleName(const std::string &variable)
void ReadSimulationParameters(hid_t fileIndx, bool bTmCycle=false)
struct tagFlashReaderIntegerScalar FlashReaderIntegerScalar
std::vector< std::string > AttributeNames
std::vector< std::string > ParticleAttributeNames
void ReadVersionInformation(hid_t fileIndx)