VTK  9.4.20241108
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
28typedef std::vector<vtkAMRBox> vtkAMRBoxList;
29
30VTK_ABI_NAMESPACE_BEGIN
32class vtkIntArray;
33class vtkDoubleArray;
34class vtkAMRIndexIterator;
35
36class VTKCOMMONDATAMODEL_EXPORT vtkAMRInformation : public vtkObject
37{
38public:
41
42 void PrintSelf(ostream& os, vtkIndent indent) override;
43
44 bool operator==(const vtkAMRInformation& other) const;
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
140 void SetAMRBlockSourceIndex(int index, int sourceId);
142
154
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
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
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
240
241private:
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
282VTK_ABI_NAMESPACE_END
283#endif
Encloses a rectangular region of voxel like cells.
Definition vtkAMRBox.h:68
Meta data that describes the structure of an AMR data set.
const std::vector< int > & GetNumBlocks() const
Returns internal arrays.
void GenerateRefinementRatio()
This method computes the refinement ratio at each level.
bool FindGrid(double q[3], int level, unsigned int &gridId)
find the grid that contains the point q at the specified level
int GetAMRBlockSourceIndex(int index)
Get/Set the SourceIndex of a block.
unsigned int GetNumberOfLevels() const
Return the number of levels.
bool Audit()
Checks whether the meta data is internally consistent.
unsigned int GetNumberOfDataSets(unsigned int level) const
Returns the number of datasets at the given levelx.
static vtkAMRInformation * New()
bool HasSpacing(unsigned int level)
void SetRefinementRatio(unsigned int level, int ratio)
Set the refinement ratio at a level.
int GetIndex(unsigned int level, unsigned int id) const
Returns the single index from a pair of indices.
void SetAMRBlockSourceIndex(int index, int sourceId)
Get/Set the SourceIndex of a block.
double * GetOrigin()
Get the AMR dataset origin The origin is essentially the minimum of all the grids.
bool operator==(const vtkAMRInformation &other) const
void ComputeIndexPair(unsigned int index, unsigned int &level, unsigned int &id)
Returns the an index pair given a single index.
unsigned int * GetParents(unsigned int level, unsigned int index, unsigned int &numParents)
Return a pointer to Parents of a block.
void SetGridDescription(int description)
returns the value of vtkUniformGrid::GridDescription() of any block
void Initialize(int numLevels, const int *blocksPerLevel)
Initialize the meta information numLevels is the number of levels blocksPerLevel[i] is the number of ...
bool HasChildrenInformation()
Return whether parent child information has been generated.
void DeepCopy(vtkAMRInformation *other)
const vtkAMRBox & GetAMRBox(unsigned int level, unsigned int id) const
Methods to set and get the AMR box at a given position.
void PrintParentChildInfo(unsigned int level, unsigned int index)
Prints the parents and children of a requested block (Debug Routine)
bool HasRefinementRatio()
Returns whether refinement ratio has been set (either by calling GenerateRefinementRatio() or by call...
std::vector< std::vector< unsigned int > > & GetChildrenAtLevel(unsigned int i)
unsigned int * GetChildren(unsigned int level, unsigned int index, unsigned int &numChildren)
Return a pointer to Children of a block.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void GetOrigin(double origin[3])
Get the AMR dataset origin The origin is essentially the minimum of all the grids.
void GetBounds(unsigned int level, unsigned int id, double *bb)
Returns the bounding box of a given box.
bool FindCell(double q[3], unsigned int level, unsigned int index, int &cellIdx)
Given a point q, find whether q is bounded by the data set at (level,index).
void GetSpacing(unsigned int level, double spacing[3])
Return the spacing at the given fiven.
const double * GetBounds()
Returns the bounds of the entire domain.
bool FindGrid(double q[3], unsigned int &level, unsigned int &gridId)
Given a point q, find the highest level grid that contains it.
int GetRefinementRatio(unsigned int level) const
Returns the refinement of a given level.
bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox &box) const
return the amr box coarsened to the previous level
unsigned int GetTotalNumberOfBlocks()
Returns total number of datasets.
void GenerateParentChildInformation()
Generate the parent/child relationships - needed to be called before GetParents or GetChildren can be...
void SetOrigin(const double *origin)
Get the AMR dataset origin The origin is essentially the minimum of all the grids.
void SetSpacing(unsigned int level, const double *h)
Set the spacing at a given level.
bool GetOrigin(unsigned int level, unsigned int id, double *origin)
Returns the origin of the grid at (level,id)
void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox &box)
Methods to set and get the AMR box at a given position.
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition vtkIndent.h:108
dynamic, self-adjusting array of int
abstract base class for most VTK objects
Definition vtkObject.h:162
Computes the portion of a dataset which is inside a selection.
Hold a reference to a vtkObjectBase instance.
dynamic, self-adjusting array of unsigned int
std::vector< vtkAMRBox > vtkAMRBoxList