VTK  9.7.20260711
vtkOverlappingAMRMetaData.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
23
24#ifndef vtkOverlappingAMRMetaData_h
25#define vtkOverlappingAMRMetaData_h
26
27#include "vtkAMRBox.h" //for storing AMR Boxes
28#include "vtkAMRMetaData.h"
29#include "vtkBoundingBox.h" //for storing AMR Bounding boxes
30#include "vtkCommonDataModelModule.h" // For export macro
31#include "vtkSmartPointer.h" //for ivars
32
33VTK_ABI_NAMESPACE_BEGIN
34class vtkIntArray;
35class vtkDoubleArray;
36class VTKCOMMONDATAMODEL_EXPORT vtkOverlappingAMRMetaData : public vtkAMRMetaData
37{
38public:
41
42 void PrintSelf(ostream& os, vtkIndent indent) override;
43 bool operator==(const vtkOverlappingAMRMetaData& other) const;
44 bool operator!=(const vtkOverlappingAMRMetaData& other) const { return !(*this == other); }
45
50 void Initialize(const std::vector<unsigned int>& blocksPerLevel) override;
51
53
57 void GetOrigin(double origin[3]);
58 [[nodiscard]] double* GetOrigin();
59 void SetOrigin(const double* origin);
61
65 [[nodiscard]] const double* GetBounds();
66
72 void GetBounds(unsigned int level, unsigned int id, double* bb);
73
79 void SetBounds(unsigned int level, unsigned int id, double* bb);
80
86 bool GetOrigin(unsigned int level, unsigned int id, double* origin);
87
92 void GetSpacing(unsigned int level, double spacing[3]);
93
97 [[nodiscard]] bool HasSpacing(unsigned int level) const;
98
102 [[nodiscard]] bool HasSpacing() const;
103
107 [[nodiscard]] bool HasBlockBounds(unsigned int index) const;
108
112 [[nodiscard]] bool HasBlockBounds() const;
113
115
118 void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox& box);
119 [[nodiscard]] const vtkAMRBox& GetAMRBox(unsigned int level, unsigned int id) const;
120 bool GetAMRBox(unsigned int level, unsigned int id, vtkAMRBox& box) const;
122
128 bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox& box);
129
131
135 [[nodiscard]] int GetAMRBlockSourceIndex(int index);
136 void SetAMRBlockSourceIndex(int index, int sourceId);
138
151
157 [[nodiscard]] bool HasRefinementRatio() const;
158
163 void SetRefinementRatio(unsigned int level, int ratio);
164
170 [[nodiscard]] int GetRefinementRatio(unsigned int level) const;
171
175 void SetSpacing(unsigned int level, const double* h);
176
180 [[nodiscard]] bool HasChildrenInformation() const;
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
209
213 [[nodiscard]] bool CheckValidity();
214
221 bool FindCell(double q[3], unsigned int level, unsigned int index, int& cellIdx);
222
227 bool FindGrid(double q[3], int level, unsigned int& gridId);
228
233 bool FindGrids(double q[3], unsigned int level, std::vector<unsigned int>& gridIds);
234
240 bool FindGrid(double q[3], unsigned int& level, unsigned int& gridId);
241
246 [[nodiscard]] std::vector<std::vector<unsigned int>>& GetChildrenAtLevel(unsigned int i)
247 {
248 return this->AllChildren[i];
249 }
250
252
255 [[nodiscard]] vtkGetMacro(GridType, unsigned int);
256 vtkSetMacro(GridType, unsigned int);
258
263 void DeepCopy(vtkAMRMetaData* other) override;
264
265protected:
268
269private:
271 void operator=(const vtkOverlappingAMRMetaData&) = delete;
272
273 bool HasValidOrigin() const;
274 bool HasValidBounds() const;
275 void UpdateBounds(int level, int id);
276 void AllocateBoxes(unsigned int n);
277 void AllocateBlockBounds(unsigned int n);
278 void CalculateParentChildRelationShip(unsigned int level,
279 std::vector<std::vector<unsigned int>>& children,
280 std::vector<std::vector<unsigned int>>& parents);
281
282 //-------------------------------------------------------------------------
283 // Essential information that determines an AMR structure. Must be copied
284 //-------------------------------------------------------------------------
285 unsigned int GridType = VTK_DATA_SET;
286
287 // the origin of the whole data set
288 double Origin[3] = { VTK_DOUBLE_MAX, VTK_DOUBLE_MAX, VTK_DOUBLE_MAX };
289
290 // vtkAMRBoxes, one per block
291 std::vector<vtkAMRBox> Boxes;
292
293 // BoundingBoxes, one per block if used
294 std::vector<vtkBoundingBox> BlockBounds;
295
296 // Typically, this maps to a file block index used by the reader
298
299 // The grid spacing for all levels
301
302 // the bounds of the entire domain
305
306 //-------------------------------------------------------------------------
307 // Auxiliary information that be computed
308 //-------------------------------------------------------------------------
309
310 // refinement ratio between two adjacent levels
311 vtkNew<vtkIntArray> Refinement;
312
313 // parent child information
314 std::vector<std::vector<std::vector<unsigned int>>> AllChildren;
315 std::vector<std::vector<std::vector<unsigned int>>> AllParents;
316};
317
318VTK_ABI_NAMESPACE_END
319#endif
Encloses a rectangular region of voxel like cells.
Definition vtkAMRBox.h:69
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition vtkIndent.h:108
dynamic, self-adjusting array of int
Allocate and hold a VTK object.
Definition vtkNew.h:168
void SetAMRBlockSourceIndex(int index, int sourceId)
Get/Set the SourceIndex of a block.
const double * GetBounds()
Returns the bounds of the entire domain as a 6 sized array.
int GetRefinementRatio(unsigned int level) const
Returns the refinement of a given level.
bool HasChildrenInformation() const
Return whether parent child information has been generated.
void SetAMRBox(unsigned int level, unsigned int id, const vtkAMRBox &box)
Methods to set and get the AMR box at a given position.
bool HasRefinementRatio() const
Returns whether refinement ratio has been set (either by calling GenerateRefinementRatio() or by call...
bool HasSpacing() const
Return if all levels have spacing.
bool CheckValidity()
Checks whether the meta data is internally consistent.
void SetSpacing(unsigned int level, const double *h)
Set the spacing at a given level.
bool FindGrid(double q[3], int level, unsigned int &gridId)
Find a grid that contains the point q at the specified level Return true if found,...
unsigned int * GetParents(unsigned int level, unsigned int index, unsigned int &numParents)
Generate parent/children information if needed then return a pointer to Parents of a block.
void PrintParentChildInfo(unsigned int level, unsigned int index)
Generate if needed and prints the parents and children of a requested block (Debug Routine)
void Initialize(const std::vector< unsigned int > &blocksPerLevel) override
Initialize the meta information blocksPerLevels is the number of blocks for each level.
void GetOrigin(double origin[3])
Get the AMR block origin as a 3 sized array The origin is essentially the minimum of all the grids.
unsigned int * GetChildren(unsigned int level, unsigned int index, unsigned int &numChildren)
Generate parent/children information if needed then return a pointer to Children of a block.
void SetRefinementRatio(unsigned int level, int ratio)
Set the refinement ratio at a level.
double * GetOrigin()
Get the AMR block origin as a 3 sized array The origin is essentially the minimum of all the grids.
bool HasBlockBounds(unsigned int index) const
Return true if a specific block bounds have been set.
bool FindGrid(double q[3], unsigned int &level, unsigned int &gridId)
Given a point q, find the highest level grid that contains it.
bool FindGrids(double q[3], unsigned int level, std::vector< unsigned int > &gridIds)
Clear gridIds and find all gridIds that contains the point q at the specified level Return true if fo...
static vtkOverlappingAMRMetaData * New()
bool HasBlockBounds() const
Return true if block bounds have been set on all blocks.
bool operator==(const vtkOverlappingAMRMetaData &other) const
bool operator!=(const vtkOverlappingAMRMetaData &other) const
bool GetCoarsenedAMRBox(unsigned int level, unsigned int id, vtkAMRBox &box)
Fill the provided box coarsened to the previous level Requite spacing/refinement ratio.
void GetSpacing(unsigned int level, double spacing[3])
Return the spacing at the given level Should only be called if HasSpacing() is true.
void DeepCopy(vtkAMRMetaData *other) override
Check it is an vtkOverlappingAMRMetaData and copy internal fields from other into this.
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 PrintSelf(ostream &os, vtkIndent indent) override
Print members.
void GetBounds(unsigned int level, unsigned int id, double *bb)
Returns the bounding box of a given box Rely on the BlockBounds if available or compute them on the f...
bool HasSpacing(unsigned int level) const
Return if a specific level has spacing.
void GenerateParentChildInformation()
Generate the parent/child relationships - needed to be called before GetParents or GetChildren can be...
const vtkAMRBox & GetAMRBox(unsigned int level, unsigned int id) const
Methods to set and get the AMR box at a given position.
~vtkOverlappingAMRMetaData() override
std::vector< std::vector< unsigned int > > & GetChildrenAtLevel(unsigned int i)
Get children at a specific level HasChildrenInformation is NOT checked by this method.
bool GenerateRefinementRatio()
This method computes the refinement ratio at each level.
bool GetOrigin(unsigned int level, unsigned int id, double *origin)
Recover the origin of the grid at (level,id).
bool GetAMRBox(unsigned int level, unsigned int id, vtkAMRBox &box) const
Methods to set and get the AMR box at a given position.
int GetAMRBlockSourceIndex(int index)
Get/Set the SourceIndex of a block.
void SetBounds(unsigned int level, unsigned int id, double *bb)
Set the Bounds of a specific AMR block This is usually called when using vtkRectilinearGrid in an Ove...
void SetOrigin(const double *origin)
Get the AMR block origin as a 3 sized array The origin is essentially the minimum of all the grids.
Computes the portion of a dataset which is inside a selection.
Hold a reference to a vtkObjectBase instance.
#define VTK_DOUBLE_MIN
Definition vtkType.h:201
#define VTK_DOUBLE_MAX
Definition vtkType.h:202
@ VTK_DATA_SET
Definition vtkType.h:117