VTK  9.3.1
vtkAMRInformation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
19 #ifndef vtkAMRInformation_h
20 #define vtkAMRInformation_h
21 
22 #include "vtkAMRBox.h" //for storing AMR Boxes
23 #include "vtkCommonDataModelModule.h" // For export macro
24 #include "vtkObject.h"
25 #include "vtkSmartPointer.h" //for ivars
26 #include <vector> //for storing AMR Boxes
27 
28 typedef std::vector<vtkAMRBox> vtkAMRBoxList;
29 
30 VTK_ABI_NAMESPACE_BEGIN
32 class vtkIntArray;
33 class vtkDoubleArray;
34 class vtkAMRIndexIterator;
35 
36 class VTKCOMMONDATAMODEL_EXPORT vtkAMRInformation : public vtkObject
37 {
38 public:
39  static vtkAMRInformation* New();
40  vtkTypeMacro(vtkAMRInformation, vtkObject);
41 
42  void PrintSelf(ostream& os, vtkIndent indent) override;
43 
44  bool operator==(const vtkAMRInformation& other);
45 
51  void Initialize(int numLevels, const int* blocksPerLevel);
52 
54 
57  vtkGetMacro(GridDescription, int);
58  void SetGridDescription(int description);
60 
62 
66  void GetOrigin(double origin[3]);
67  double* GetOrigin();
68  void SetOrigin(const double* origin);
70 
74  unsigned int GetNumberOfLevels() const
75  {
76  return static_cast<unsigned int>(this->NumBlocks.size() - 1);
77  }
78 
82  unsigned int GetNumberOfDataSets(unsigned int level) const;
83 
87  unsigned int GetTotalNumberOfBlocks() { return this->NumBlocks.back(); }
88 
92  int GetIndex(unsigned int level, unsigned int id) const { return this->NumBlocks[level] + id; }
93 
97  void ComputeIndexPair(unsigned int index, unsigned int& level, unsigned int& id);
98 
102  const double* GetBounds();
103 
107  void GetBounds(unsigned int level, unsigned int id, double* bb);
108 
112  bool GetOrigin(unsigned int level, unsigned int id, double* origin);
113 
117  void GetSpacing(unsigned int level, double spacing[3]);
118 
119  bool HasSpacing(unsigned int level);
120 
122 
125  void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox& box);
126  const vtkAMRBox& GetAMRBox(unsigned int level, unsigned int id) const;
128 
132  bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox& box) const;
133 
135 
139  int GetAMRBlockSourceIndex(int index);
140  void SetAMRBlockSourceIndex(int index, int sourceId);
142 
153  void GenerateRefinementRatio();
154 
159  bool HasRefinementRatio();
160 
165  void SetRefinementRatio(unsigned int level, int ratio);
166 
170  int GetRefinementRatio(unsigned int level) const;
171 
175  void SetSpacing(unsigned int level, const double* h);
176 
180  bool HasChildrenInformation();
181 
187  unsigned int* GetParents(unsigned int level, unsigned int index, unsigned int& numParents);
188 
194  unsigned int* GetChildren(unsigned int level, unsigned int index, unsigned int& numChildren);
195 
199  void PrintParentChildInfo(unsigned int level, unsigned int index);
200 
205  void GenerateParentChildInformation();
206 
210  bool Audit();
211 
217  bool FindCell(double q[3], unsigned int level, unsigned int index, int& cellIdx);
218 
222  bool FindGrid(double q[3], int level, unsigned int& gridId);
223 
227  bool FindGrid(double q[3], unsigned int& level, unsigned int& gridId);
228 
232  const std::vector<int>& GetNumBlocks() const { return this->NumBlocks; }
233 
234  std::vector<std::vector<unsigned int>>& GetChildrenAtLevel(unsigned int i)
235  {
236  return this->AllChildren[i];
237  }
238 
239  void DeepCopy(vtkAMRInformation* other);
240 
241 private:
243  ~vtkAMRInformation() override;
244  vtkAMRInformation(const vtkAMRInformation&) = delete;
245  void operator=(const vtkAMRInformation&) = delete;
246 
247  bool HasValidOrigin();
248  bool HasValidBounds();
249  void UpdateBounds(int level, int id);
250  void AllocateBoxes(unsigned int n);
251  void GenerateBlockLevel();
252  void CalculateParentChildRelationShip(unsigned int level,
253  std::vector<std::vector<unsigned int>>& children,
254  std::vector<std::vector<unsigned int>>& parents);
255 
256  //-------------------------------------------------------------------------
257  // Essential information that determines an AMR structure. Must be copied
258  //-------------------------------------------------------------------------
259  int GridDescription; // example: VTK_XYZ_GRID
260  double Origin[3]; // the origin of the whole data set
261  vtkAMRBoxList Boxes; // vtkAMRBoxes, one per data set
262  std::vector<int>
263  NumBlocks; // NumBlocks[i] stores the total number of blocks from level 0 to level i-1
264 
266  SourceIndex; // Typically, this maps to a file block index used by the reader
267  vtkSmartPointer<vtkDoubleArray> Spacing; // The grid spacing for all levels
268  double Bounds[6]; // the bounds of the entire domain
269 
270  //-------------------------------------------------------------------------
271  // Auxiliary information that be computed
272  //-------------------------------------------------------------------------
273  vtkSmartPointer<vtkIntArray> Refinement; // refinement ratio between two adjacent levels
274  vtkSmartPointer<vtkUnsignedIntArray> BlockLevel; // only necessary if need to call
275  // ComputeIndexPair
276 
277  // parent child information
278  std::vector<std::vector<std::vector<unsigned int>>> AllChildren;
279  std::vector<std::vector<std::vector<unsigned int>>> AllParents;
280 };
281 
282 VTK_ABI_NAMESPACE_END
283 #endif
dynamic, self-adjusting array of unsigned int
void GetBounds(T a, double bds[6])
abstract base class for most VTK objects
Definition: vtkObject.h:51
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Encloses a rectangular region of voxel like cells.
Definition: vtkAMRBox.h:28
std::vector< std::vector< unsigned int > > & GetChildrenAtLevel(unsigned int i)
bool VTKCOMMONCORE_EXPORT operator==(const std::string &a, const vtkStringToken &b)
std::vector< vtkAMRBox > vtkAMRBoxList
dynamic, self-adjusting array of double
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:34
Meta data that describes the structure of an AMR data set.
a simple class to control print indentation
Definition: vtkIndent.h:28
unsigned int GetTotalNumberOfBlocks()
Returns total number of datasets.
unsigned int GetNumberOfLevels() const
Return the number of levels.
int GetIndex(unsigned int level, unsigned int id) const
Returns the single index from a pair of indices.
const std::vector< int > & GetNumBlocks() const
Returns internal arrays.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...