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