VTK  9.3.20240907
vtkHyperTreeGridGhostCellsGeneratorInternals.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
3
15#ifndef vtkHyperTreeGridGhostCellsGeneratorInternals_h
16#define vtkHyperTreeGridGhostCellsGeneratorInternals_h
17
18#include "vtkAbstractArray.h"
19#include "vtkBitArray.h"
20#include "vtkDataArray.h"
21#include "vtkHyperTree.h"
22#include "vtkHyperTreeGrid.h"
27#include "vtkSmartPointer.h"
28
29#include <map>
30#include <unordered_map>
31#include <vector>
32
33VTK_ABI_NAMESPACE_BEGIN
34
36{
37
38public:
46 vtkMultiProcessController* controller, vtkHyperTreeGrid* inputHTG, vtkHyperTreeGrid* outputHTG);
47
53
60
66
73
79
85
90
91private:
92 // Internal structures used for MPI message exchanges
93 struct SendBuffer
94 {
95 SendBuffer()
96 : count(0)
97 , mask(0)
98 {
99 }
100 vtkIdType count; // len buffer
101 unsigned int mask; // ghost mask
102 std::vector<vtkIdType> indices; // indices for selected cells
103 vtkNew<vtkBitArray> isParent; // decomposition amr tree
104 vtkNew<vtkBitArray> isMasked; // decomposition amr tree
105 };
106
107 struct RecvBuffer
108 {
109 RecvBuffer()
110 : count(0)
111 , offset(0)
112 {
113 }
114 vtkIdType count; // len buffer
115 vtkIdType offset; // offset in field vector
116 std::vector<vtkIdType> indices;
117 };
118
119 typedef std::map<unsigned int, SendBuffer> SendTreeBufferMap;
120 typedef std::map<unsigned int, SendTreeBufferMap> SendProcessBufferMap;
121 typedef std::map<unsigned int, RecvBuffer> RecvTreeBufferMap;
122 typedef std::map<unsigned int, RecvTreeBufferMap> RecvProcessBufferMap;
123
124 enum FlagType
125 {
126 NOT_TREATED, // process has not been dealth with yet
127 INITIALIZE_TREE, // ghost tree has been created, values not filled yet
128 INITIALIZE_FIELD // cell data values have been set
129 };
130
131 // Associate the process id with its ghost tree processing state
132 typedef std::unordered_map<unsigned int, FlagType> FlagMap;
133
134 // Handling receive and send buffer.
135 // The structure is as follows:
136 // SendBuffer[id] or RecvBuffer[id] == process id of neighbor with whom to communicate buffer
137 // SendBuffer[id][jd] or RecvBuffer[id][jd] tells which tree index is being sent.
138 SendProcessBufferMap SendBuffer;
139 RecvProcessBufferMap RecvBuffer;
140
141 FlagMap Flags;
142
143 std::vector<int> HyperTreesMapToProcesses;
144
145public:
146 // Store the values for a single cell data array, composed of two parts
147 // * InternalArray is the cell array internal to this HTG (ShallowCopied)
148 // * GhostCDBuffer is the buffer with values from ghost cells
150 {
153 };
154 // All cell data attributes composing a vtkCellData, accessed by name.
155 using CellDataAttributes = std::map<std::string, CellDataArray>;
156
157private:
159 vtkMultiProcessController* Controller = nullptr;
160 vtkHyperTreeGrid* InputHTG = nullptr;
161 vtkHyperTreeGrid* OutputHTG = nullptr;
163 CellDataAttributes ImplicitCD;
164 vtkIdType NumberOfVertices = 0;
165 vtkIdType InitialNumberOfVertices = 0;
166};
167
168VTK_ABI_NAMESPACE_END
169#endif
abstract superclass for arrays of numeric data
Internal class for vtkHyperTreeGridGhostCellsGenerator.
int ExchangeSizes()
Exchange the number of ghost cells to be sent between ranks.
void DetermineNeighbors()
Compute the index of neighboring trees and record those that belong to other processes and should be ...
void BroadcastTreeLocations()
Subroutine performing an MPI AllReduce operation, filling the vector HyperTreesMapToProcesses where H...
void InitializeCellData()
Initilize the internal cell data implicit array handler, with the cell arrays as the first entries of...
void FinalizeCellData()
ProcessTrees subroutine creating the output ghost array and adding it to the output HTG.
vtkHyperTreeGridGhostCellsGeneratorInternals(vtkHyperTreeGridGhostCellsGenerator *self, vtkMultiProcessController *controller, vtkHyperTreeGrid *inputHTG, vtkHyperTreeGrid *outputHTG)
int ExchangeCellData()
Exchange cell data information with the other process to fill in values for ghost cells.
int ExchangeTreeDecomposition()
Routine to send and receive tree decomposition, and mask values if present for each tree.
Generated ghost cells (HyperTree's distributed).
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
Multiprocessing communication superclass.
Allocate and hold a VTK object.
Definition vtkNew.h:167
Hold a reference to a vtkObjectBase instance.
@ offset
Definition vtkX3D.h:438
int vtkIdType
Definition vtkType.h:315