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