File: vtkAMRFlashReaderInternal.h

package info (click to toggle)
paraview 5.11.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 497,236 kB
  • sloc: cpp: 3,171,290; ansic: 1,315,072; python: 134,290; xml: 103,324; sql: 65,887; sh: 5,286; javascript: 4,901; yacc: 4,383; java: 3,977; perl: 2,363; lex: 1,909; f90: 1,255; objc: 143; makefile: 119; tcl: 59; pascal: 50; fortran: 29
file content (204 lines) | stat: -rw-r--r-- 7,147 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkAMRFlashReaderInternal.hpp

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
/**
 * @class   vtkAMRFlashReaderInternal
 * @brief   Consists of the low-level Flash Reader used by the vtkAMRFlashReader.
 *
 * @sa
 *  vtkAMRFlashReader
 */

#ifndef vtkAMRFlashReaderInternal_h
#define vtkAMRFlashReaderInternal_h

#include <cassert>
#include <cstring>
#include <map>
#include <string>
#include <vector>

#include "vtkByteSwap.h"
#include "vtkCellData.h"
#include "vtkDataArray.h"
#include "vtkDataSet.h"
#include "vtkDoubleArray.h"
#include "vtkIntArray.h"
#include "vtkObject.h"
#include "vtkSetGet.h"

#define H5_USE_16_API
#include "vtk_hdf5.h"

//==============================================================================
//            I N T E R N A L   F L A S H     R E A D E R
//==============================================================================

#define FLASH_READER_MAX_DIMS 3
#define FLASH_READER_LEAF_BLOCK 1
#define FLASH_READER_FLASH3_FFV8 8
#define FLASH_READER_FLASH3_FFV9 9

VTK_ABI_NAMESPACE_BEGIN
typedef struct tagFlashReaderIntegerScalar
{
  char Name[20]; // name  of the integer scalar
  int Value;     // value of the integer scalar
} FlashReaderIntegerScalar;

typedef struct tagFlashReaderDoubleScalar
{
  char Name[20]; // name  of the real scalar
  double Value;  // value of the real scalar
} FlashReaderDoubleScalar;

typedef struct tagFlashReaderSimulationParameters
{
  int NumberOfBlocks;     // number of all blocks
  int NumberOfTimeSteps;  // number of time steps
  int NumberOfXDivisions; // number of divisions per block along x axis
  int NumberOfYDivisions; // number of divisions per block along y axis
  int NumberOfZDivisions; // number of divisions per block along z axis
  double Time;            // the time of this step
  double TimeStep;        // time interval
  double RedShift;
} FlashReaderSimulationParameters;

typedef struct tagFlashReaderBlock
{
  int Index;                   // Id of the block
  int Level;                   // LOD level
  int Type;                    // a leaf block?
  int ParentId;                // Id  of the parent block
  int ChildrenIds[8];          // Ids of the children    blocks
  int NeighborIds[6];          // Ids of the neighboring blocks
  int ProcessorId;             // Id  of the processor
  int MinGlobalDivisionIds[3]; // first (global) division index
  int MaxGlobalDivisionIds[3]; // last  (global) division index
  double Center[3];            // center of the block
  double MinBounds[3];         // lower left  of the bounding box
  double MaxBounds[3];         // upper right of the bounding box
} FlashReaderBlock;

typedef struct tagFlashReaderSimulationInformation
{
  int FileFormatVersion;
  char SetupCall[400];
  char FileCreationTime[80];
  char FlashVersion[80];
  char BuildData[80];
  char BuildDirectory[80];
  char build_machine[80];
  char CFlags[400];
  char FFlags[400];
  char SetupTimeStamp[80];
  char BuildTimeStamp[80];
} FlashReaderSimulationInformation;

static std::string GetSeparatedParticleName(const std::string& variable)
{
  std::string sepaName = variable;

  if (sepaName.length() > 9 && sepaName.substr(0, 9) == "particle_")
  {
    sepaName = std::string("Particles/") + sepaName.substr(9);
  }
  else
  {
    sepaName = std::string("Particles/") + sepaName;
  }

  return sepaName;
}

// ----------------------------------------------------------------------------
//                     Class  vtkFlashReaderInternal (begin)
// ----------------------------------------------------------------------------

class vtkFlashReaderInternal
{
public:
  vtkFlashReaderInternal() { this->Init(); }
  ~vtkFlashReaderInternal() { this->Init(); }

  int NumberOfBlocks;            // number of ALL blocks
  int NumberOfLevels;            // number of levels
  int FileFormatVersion;         // version of file format
  int NumberOfParticles;         // number of particles
  int NumberOfLeafBlocks;        // number of leaf blocks
  int NumberOfDimensions;        // number of dimensions
  int NumberOfProcessors;        // number of processors
  int HaveProcessorsInfo;        // processor Ids available?
  int BlockGridDimensions[3];    // number of grid points
  int BlockCellDimensions[3];    // number of divisions
  int NumberOfChildrenPerBlock;  // number of children  per block
  int NumberOfNeighborsPerBlock; // number of neighbors per block

  char* FileName;                                         // Flash data file name
  hid_t FileIndex;                                        // file handle
  double MinBounds[3];                                    // lower left  of the bounding-box
  double MaxBounds[3];                                    // upper right of the bounding box
  FlashReaderSimulationParameters SimulationParameters;   // CFD simulation
  FlashReaderSimulationInformation SimulationInformation; // CFD simulation

  // blocks
  std::vector<FlashReaderBlock> Blocks;
  std::vector<int> LeafBlocks;
  std::vector<std::string> AttributeNames;

  // particles
  std::string ParticleName;
  std::vector<hid_t> ParticleAttributeTypes;
  std::vector<std::string> ParticleAttributeNames;
  std::map<std::string, int> ParticleAttributeNamesToIds;

  int GetCycle();
  double GetTime();

  void Init();
  void SetFileName(VTK_FILEPATH char* fileName) { this->FileName = fileName; }
  const char* GetParticleName(char* variableName)
  {
    static std::string particleName;
    particleName = GetSeparatedParticleName(std::string(variableName));
    return particleName.c_str();
  }

  void ReadMetaData();
  void ReadProcessorIds();
  void ReadDoubleScalars(hid_t fileIndx);
  void ReadIntegerScalars(hid_t fileIndx);
  void ReadVersionInformation(hid_t fileIndx);
  void ReadSimulationParameters(hid_t fileIndx, bool bTmCycle = false); // time and cycle only
  void GetBlockMinMaxGlobalDivisionIds();

  void ReadBlockTypes();
  void ReadBlockBounds();
  void ReadBlockCenters();
  void ReadBlockStructures();
  void ReadRefinementLevels();
  void ReadDataAttributeNames();

  void ReadParticlesComponent(hid_t dataIndx, const char* compName, double* dataBuff);
  void ReadParticleAttributes();
  void ReadParticleAttributesFLASH3();
  void GetBlockAttribute(const char* attribute, int blockIdx, vtkDataSet* pDataSet);
};

// ----------------------------------------------------------------------------
//                     Class  vtkFlashReaderInternal ( end )
// ----------------------------------------------------------------------------
VTK_ABI_NAMESPACE_END
#endif /* vtkAMRFlashReaderInternal_h */
// VTK-HeaderTest-Exclude: vtkAMRFlashReaderInternal.h