VTK  9.0.20200705
vtkAMReXGridReaderInternal.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkAMReXGridReaderInternal.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 =========================================================================*/
23 #ifndef vtkAMReXGridReaderInternal_h
24 #define vtkAMReXGridReaderInternal_h
25 #ifndef __VTK_WRAP__
26 
27 #include <string>
28 #include <vector>
29 
30 #include "vtkDataSet.h"
31 
32 class vtkIndent;
33 
34 //==============================================================================
35 // I N T E R N A L A M R e X R E A D E R
36 //==============================================================================
37 
38 // ----------------------------------------------------------------------------
39 // Class RealDecriptor (begin)
40 // ----------------------------------------------------------------------------
41 
42 /*
43  floating point format specification (fmt):
44  - fmt[0] = # of bits per number
45  - fmt[1] = # of bits in exponent
46  - fmt[2] = # of bits in mantissa
47  - fmt[3] = start bit of sign
48  - fmt[4] = start bit of exponent
49  - fmt[5] = start bit of mantissa
50  - fmt[6] = high order mantissa bit (CRAY needs this)
51  - fmt[7] = bias of exponent
52 
53  64 11 52 0 1 12 0 1023 - IEEE Double
54 
55  byte order (ord) handles endianness (and defines size such as float or double)
56  - ord[0] = byte in 1st byte
57  - ord[1] = byte in 2nd byte
58  - ord[2] = byte in 3rd byte
59  - ord[3] = byte in 4th byte
60  - ...
61 */
62 
64 {
65 public:
67  RealDescriptor(const long* format, const int* order, int order_length);
68  const long* format() const&;
69  const std::vector<long>& formatarray() const&;
70  const int* order() const&;
71  const std::vector<int>& orderarray() const&;
72  int numBytes() const;
73  bool operator==(const RealDescriptor& rd) const;
74 
75 private:
76  std::vector<long> fr;
77  std::vector<int> ord;
78 };
79 
80 // ----------------------------------------------------------------------------
81 // Class RealDecriptor ( end )
82 // ----------------------------------------------------------------------------
83 
84 // ----------------------------------------------------------------------------
85 // Class vtkAMReXGridHeader (begin)
86 // ----------------------------------------------------------------------------
87 
89 {
90 public:
93  std::vector<std::string> variableNames;
94  int dim;
95  double time;
97  std::vector<double> problemDomainLoEnd;
98  std::vector<double> problemDomainHiEnd;
99  std::vector<int> refinementRatio;
100  std::vector<std::vector<std::vector<int>>> levelDomains;
101  std::vector<int> levelSteps;
102  std::vector<std::vector<double>> cellSize;
105  std::vector<int> levelSize;
106  std::vector<std::vector<std::vector<std::vector<double>>>> levelCells;
107  std::vector<std::string> levelPrefix;
108  std::vector<std::string> multiFabPrefix;
110 
112 
113  void PrintSelf(std::ostream& os, vtkIndent indent);
114  void PrintSelfGenericHeader(std::ostream& os, vtkIndent indent);
115  bool Parse(const std::string& headerData);
116  bool ParseGenericHeader(const std::string& headerData);
117 };
118 
119 // ----------------------------------------------------------------------------
120 // Class vtkAMReXGridHeader ( end )
121 // ----------------------------------------------------------------------------
122 
123 // ----------------------------------------------------------------------------
124 // Class vtkAMReXGridLevelHeader (begin)
125 // ----------------------------------------------------------------------------
126 
128 {
129  enum Version
130  {
131  Undefined_v1 = 0, // ---- undefined
132  Version_v1 = 1, // ---- auto converting version with headers
133  // ---- for each fab in the data files and
134  // ---- min and max values for each fab in the header
135  NoFabHeader_v1 = 2, // ---- no fab headers, no fab mins or maxes
136  NoFabHeaderMinMax_v1 = 3, // ---- no fab headers,
137  // ---- min and max values for each fab in the header
138  NoFabHeaderFAMinMax_v1 = 4 // ---- no fab headers, no fab mins or maxes,
139  // ---- min and max values for each FabArray in the header
140  };
141  enum Ordering
142  {
143  NormalOrder = 1,
144  ReverseOrder = 2
145  };
146 
147 public:
148  int level;
149  int dim;
151  int levelHow;
156  std::vector<std::vector<std::vector<int>>> levelBoxArrays;
159  std::vector<std::string> levelFABFile;
160  std::vector<long> levelFileOffset;
161  std::vector<std::vector<double>> levelMinimumsFAB;
162  std::vector<std::vector<double>> levelMaximumsFAB;
163  std::vector<double> levelFABArrayMinimum;
164  std::vector<double> levelFABArrayMaximum;
168 
170  void PrintSelf(std::ostream& os, vtkIndent indent);
171  void PrintSelfLevelHeader(std::ostream& os, vtkIndent indent);
172  bool Parse(int _level, int _dim, const std::string& headerData);
173  bool ParseLevelHeader(int _level, int _dim, const std::string& headerData);
174 };
175 
176 // ----------------------------------------------------------------------------
177 // Class vtkAMReXGridLevelHeader ( end )
178 // ----------------------------------------------------------------------------
179 
180 // ----------------------------------------------------------------------------
181 // Class vtkAMReXGridReaderInternal (begin)
182 // ----------------------------------------------------------------------------
183 
185 {
186 public:
189  void DestroyHeader();
190  void DestroyLevelHeader();
191  void PrintSelf(std::ostream& os, vtkIndent indent);
192  void SetFileName(char* fName);
193 
194  void ReadMetaData();
195  bool ReadHeader();
196  bool ReadLevelHeader();
197  int GetNumberOfLevels();
198  int GetBlockLevel(const int blockIdx);
199  int GetNumberOfBlocks();
200  int GetBlockIndexWithinLevel(int blockIdx, int level);
201  void GetBlockAttribute(const char* attribute, int blockIdx, vtkDataSet* pDataSet);
202  int GetOffsetOfAttribute(const char* attribute);
203  void ReadFAB(std::istream& is);
204  int ReadVersion(std::istream& is);
205  void ReadOrder(std::istream& is, std::vector<int>& ar);
206  void PrintOrder(std::vector<int>& ar);
207  void ReadFormat(std::istream& is, std::vector<long>& ar);
208  void PrintFormat(std::vector<long>& ar);
209  RealDescriptor* ReadRealDescriptor(std::istream& is);
210  int ReadBoxArray(std::istream& is, int* boxArray, int* boxArrayDim);
211  void PrintBoxArray(int* boxArray);
212  int ReadNumberOfAttributes(std::istream& is);
213  void ReadBlockAttribute(std::istream& is, int numberOfPoints, int size, char* buffer);
214  void Convert(
215  void* out, const void* in, long nitems, const RealDescriptor& ord, const RealDescriptor& ird);
216  void PermuteOrder(
217  void* out, const void* in, long nitems, const int* outord, const int* inord, int REALSIZE);
218 
223  friend class vtkAMReXGridHeader;
224  std::vector<vtkAMReXGridLevelHeader*> LevelHeader;
226 };
227 
228 // ----------------------------------------------------------------------------
229 // Class vtkAMReXGridReaderInternal ( end )
230 // ----------------------------------------------------------------------------
231 #endif
232 #endif /* vtkAMReXGridReaderInternal_h */
233 // VTK-HeaderTest-Exclude: vtkAMReXGridReaderInternal.h
vtkAMReXGridHeader::refinementRatio
std::vector< int > refinementRatio
Definition: vtkAMReXGridReaderInternal.h:99
vtkAMReXGridHeader::magicZero
int magicZero
Definition: vtkAMReXGridReaderInternal.h:104
vtkAMReXGridHeader::dim
int dim
Definition: vtkAMReXGridReaderInternal.h:94
vtkAMReXGridReaderInternal::vtkAMReXGridReaderInternal
vtkAMReXGridReaderInternal()
vtkAMReXGridReaderInternal::vtkAMReXGridLeveHeader
friend class vtkAMReXGridLeveHeader
Definition: vtkAMReXGridReaderInternal.h:225
vtkAMReXGridHeader::problemDomainLoEnd
std::vector< double > problemDomainLoEnd
Definition: vtkAMReXGridReaderInternal.h:97
vtkAMReXGridHeader::PrintSelf
void PrintSelf(std::ostream &os, vtkIndent indent)
vtkAMReXGridHeader
Definition: vtkAMReXGridReaderInternal.h:88
vtkAMReXGridReaderInternal::Header
vtkAMReXGridHeader * Header
Definition: vtkAMReXGridReaderInternal.h:222
vtkAMReXGridLevelHeader::levelHow
int levelHow
Definition: vtkAMReXGridReaderInternal.h:151
vtkAMReXGridHeader::PrintSelfGenericHeader
void PrintSelfGenericHeader(std::ostream &os, vtkIndent indent)
vtkAMReXGridLevelHeader::levelNumberOfGhostCells
int levelNumberOfGhostCells
Definition: vtkAMReXGridReaderInternal.h:153
vtkAMReXGridHeader::problemDomainHiEnd
std::vector< double > problemDomainHiEnd
Definition: vtkAMReXGridReaderInternal.h:98
vtkAMReXGridReaderInternal::DestroyHeader
void DestroyHeader()
vtkAMReXGridLevelHeader::dim
int dim
Definition: vtkAMReXGridReaderInternal.h:149
vtkAMReXGridHeader::finestLevel
int finestLevel
Definition: vtkAMReXGridReaderInternal.h:96
vtkAMReXGridReaderInternal::ReadLevelHeader
bool ReadLevelHeader()
RealDescriptor::order
const int * order() const &
vtkAMReXGridLevelHeader::levelMagicZero
int levelMagicZero
Definition: vtkAMReXGridReaderInternal.h:155
vtkAMReXGridLevelHeader::levelFabOnDiskPrefix
std::string levelFabOnDiskPrefix
Definition: vtkAMReXGridReaderInternal.h:158
vtkAMReXGridLevelHeader::levelNumberOfFABOnDisk
int levelNumberOfFABOnDisk
Definition: vtkAMReXGridReaderInternal.h:157
vtkAMReXGridHeader::variableNames
std::vector< std::string > variableNames
Definition: vtkAMReXGridReaderInternal.h:93
vtkAMReXGridLevelHeader::debugLevelHeader
bool debugLevelHeader
Definition: vtkAMReXGridReaderInternal.h:167
vtkAMReXGridHeader::variableNamesSize
int variableNamesSize
Definition: vtkAMReXGridReaderInternal.h:92
vtkAMReXGridReaderInternal::SetFileName
void SetFileName(char *fName)
vtkAMReXGridLevelHeader::vtkAMReXGridLevelHeader
vtkAMReXGridLevelHeader()
RealDescriptor::numBytes
int numBytes() const
vtkAMReXGridLevelHeader::levelMinimumsFAB
std::vector< std::vector< double > > levelMinimumsFAB
Definition: vtkAMReXGridReaderInternal.h:161
vtkAMReXGridReaderInternal::GetNumberOfBlocks
int GetNumberOfBlocks()
vtkAMReXGridLevelHeader::Parse
bool Parse(int _level, int _dim, const std::string &headerData)
vtkAMReXGridReaderInternal::ReadOrder
void ReadOrder(std::istream &is, std::vector< int > &ar)
RealDescriptor::format
const long * format() const &
vtkAMReXGridHeader::debugHeader
bool debugHeader
Definition: vtkAMReXGridReaderInternal.h:109
vtkAMReXGridLevelHeader::levelMaximumsFAB
std::vector< std::vector< double > > levelMaximumsFAB
Definition: vtkAMReXGridReaderInternal.h:162
vtkAMReXGridHeader::ParseGenericHeader
bool ParseGenericHeader(const std::string &headerData)
vtkAMReXGridReaderInternal::LevelHeader
std::vector< vtkAMReXGridLevelHeader * > LevelHeader
Definition: vtkAMReXGridReaderInternal.h:224
vtkAMReXGridHeader::vtkAMReXGridHeader
vtkAMReXGridHeader()
RealDescriptor::formatarray
const std::vector< long > & formatarray() const &
vtkAMReXGridReaderInternal::ReadHeader
bool ReadHeader()
vtkX3D::level
Definition: vtkX3D.h:401
vtkAMReXGridReaderInternal::ReadBoxArray
int ReadBoxArray(std::istream &is, int *boxArray, int *boxArrayDim)
vtkAMReXGridHeader::levelCells
std::vector< std::vector< std::vector< std::vector< double > > > > levelCells
Definition: vtkAMReXGridReaderInternal.h:106
vtkAMReXGridHeader::levelSize
std::vector< int > levelSize
Definition: vtkAMReXGridReaderInternal.h:105
RealDescriptor::RealDescriptor
RealDescriptor()
vtkAMReXGridReaderInternal::PrintOrder
void PrintOrder(std::vector< int > &ar)
vtkAMReXGridHeader::multiFabPrefix
std::vector< std::string > multiFabPrefix
Definition: vtkAMReXGridReaderInternal.h:108
vtkAMReXGridLevelHeader::levelFABFile
std::vector< std::string > levelFABFile
Definition: vtkAMReXGridReaderInternal.h:159
vtkAMReXGridHeader::Parse
bool Parse(const std::string &headerData)
vtkAMReXGridLevelHeader::levelFABArrayMaximum
std::vector< double > levelFABArrayMaximum
Definition: vtkAMReXGridReaderInternal.h:164
vtkAMReXGridLevelHeader::levelFileOffset
std::vector< long > levelFileOffset
Definition: vtkAMReXGridReaderInternal.h:160
vtkAMReXGridLevelHeader::levelVersion
int levelVersion
Definition: vtkAMReXGridReaderInternal.h:150
vtkAMReXGridReaderInternal::ReadNumberOfAttributes
int ReadNumberOfAttributes(std::istream &is)
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkAMReXGridReaderInternal::ReadFormat
void ReadFormat(std::istream &is, std::vector< long > &ar)
vtkAMReXGridReaderInternal::PrintSelf
void PrintSelf(std::ostream &os, vtkIndent indent)
vtkAMReXGridReaderInternal::GetNumberOfLevels
int GetNumberOfLevels()
vtkX3D::size
Definition: vtkX3D.h:259
vtkAMReXGridHeader::levelDomains
std::vector< std::vector< std::vector< int > > > levelDomains
Definition: vtkAMReXGridReaderInternal.h:100
vtkAMReXGridReaderInternal::GetOffsetOfAttribute
int GetOffsetOfAttribute(const char *attribute)
vtkAMReXGridHeader::levelPrefix
std::vector< std::string > levelPrefix
Definition: vtkAMReXGridReaderInternal.h:107
vtkAMReXGridReaderInternal::PrintBoxArray
void PrintBoxArray(int *boxArray)
vtkAMReXGridReaderInternal::PermuteOrder
void PermuteOrder(void *out, const void *in, long nitems, const int *outord, const int *inord, int REALSIZE)
vtkAMReXGridReaderInternal::ReadMetaData
void ReadMetaData()
vtkAMReXGridReaderInternal::~vtkAMReXGridReaderInternal
~vtkAMReXGridReaderInternal()
vtkAMReXGridLevelHeader::levelNumberOfComponents
int levelNumberOfComponents
Definition: vtkAMReXGridReaderInternal.h:152
vtkAMReXGridLevelHeader::PrintSelf
void PrintSelf(std::ostream &os, vtkIndent indent)
vtkDataSet.h
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkX3D::string
Definition: vtkX3D.h:496
vtkAMReXGridHeader::cellSize
std::vector< std::vector< double > > cellSize
Definition: vtkAMReXGridReaderInternal.h:102
vtkAMReXGridLevelHeader::levelFABArrayMinimum
std::vector< double > levelFABArrayMinimum
Definition: vtkAMReXGridReaderInternal.h:163
vtkAMReXGridReaderInternal
Consists of the low-level AMReX Reader used by the vtkAMReXGridReader.
Definition: vtkAMReXGridReaderInternal.h:184
vtkAMReXGridReaderInternal::ReadBlockAttribute
void ReadBlockAttribute(std::istream &is, int numberOfPoints, int size, char *buffer)
vtkAMReXGridHeader::levelSteps
std::vector< int > levelSteps
Definition: vtkAMReXGridReaderInternal.h:101
vtkAMReXGridReaderInternal::ReadFAB
void ReadFAB(std::istream &is)
vtkAMReXGridHeader::geometryCoord
int geometryCoord
Definition: vtkAMReXGridReaderInternal.h:103
vtkAMReXGridLevelHeader::ParseLevelHeader
bool ParseLevelHeader(int _level, int _dim, const std::string &headerData)
vtkAMReXGridLevelHeader::PrintSelfLevelHeader
void PrintSelfLevelHeader(std::ostream &os, vtkIndent indent)
vtkAMReXGridReaderInternal::FileName
std::string FileName
Definition: vtkAMReXGridReaderInternal.h:221
vtkAMReXGridReaderInternal::GetBlockAttribute
void GetBlockAttribute(const char *attribute, int blockIdx, vtkDataSet *pDataSet)
vtkAMReXGridReaderInternal::ReadRealDescriptor
RealDescriptor * ReadRealDescriptor(std::istream &is)
vtkAMReXGridReaderInternal::PrintFormat
void PrintFormat(std::vector< long > &ar)
vtkAMReXGridLevelHeader::levelBoxArraySize
int levelBoxArraySize
Definition: vtkAMReXGridReaderInternal.h:154
RealDescriptor::operator==
bool operator==(const RealDescriptor &rd) const
vtkAMReXGridLevelHeader::level
int level
Definition: vtkAMReXGridReaderInternal.h:148
vtkAMReXGridReaderInternal::GetBlockLevel
int GetBlockLevel(const int blockIdx)
vtkAMReXGridLevelHeader::levelRealNumberOfBytes
int levelRealNumberOfBytes
Definition: vtkAMReXGridReaderInternal.h:165
vtkAMReXGridHeader::versionName
std::string versionName
Definition: vtkAMReXGridReaderInternal.h:91
vtkAMReXGridReaderInternal::headersAreRead
bool headersAreRead
Definition: vtkAMReXGridReaderInternal.h:219
vtkAMReXGridLevelHeader::levelRealOrder
int levelRealOrder
Definition: vtkAMReXGridReaderInternal.h:166
RealDescriptor
Definition: vtkAMReXGridReaderInternal.h:63
RealDescriptor::orderarray
const std::vector< int > & orderarray() const &
vtkAMReXGridLevelHeader::levelBoxArrays
std::vector< std::vector< std::vector< int > > > levelBoxArrays
Definition: vtkAMReXGridReaderInternal.h:156
vtkAMReXGridReaderInternal::GetBlockIndexWithinLevel
int GetBlockIndexWithinLevel(int blockIdx, int level)
vtkAMReXGridHeader::time
double time
Definition: vtkAMReXGridReaderInternal.h:95
vtkAMReXGridReaderInternal::ReadVersion
int ReadVersion(std::istream &is)
vtkAMReXGridReaderInternal::DestroyLevelHeader
void DestroyLevelHeader()
vtkAMReXGridReaderInternal::debugReader
bool debugReader
Definition: vtkAMReXGridReaderInternal.h:220
vtkAMReXGridReaderInternal::Convert
void Convert(void *out, const void *in, long nitems, const RealDescriptor &ord, const RealDescriptor &ird)
vtkAMReXGridLevelHeader
Definition: vtkAMReXGridReaderInternal.h:127