VTK  9.6.20260228
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
14
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:
45 vtkMultiProcessController* controller, vtkHyperTreeGrid* inputHTG, vtkHyperTreeGrid* outputHTG);
46
52
59
65
72
78
84
89
90private:
91 // Internal structures used for MPI message exchanges
92 struct SendBuffer
93 {
94 SendBuffer()
95 : count(0)
96 , mask(0)
97 {
98 }
99 vtkIdType count; // len buffer
100 unsigned int mask; // ghost mask
101 std::vector<vtkIdType> indices; // indices for selected cells
102 vtkNew<vtkBitArray> isParent; // decomposition amr tree
103 vtkNew<vtkBitArray> isMasked; // decomposition amr tree
104 };
105
106 struct RecvBuffer
107 {
108 RecvBuffer()
109 : count(0)
110 , offset(0)
111 {
112 }
113 vtkIdType count; // len buffer
114 vtkIdType offset; // offset in field vector
115 std::vector<vtkIdType> indices;
116 };
117
118 typedef std::map<unsigned int, SendBuffer> SendTreeBufferMap;
119 typedef std::map<unsigned int, SendTreeBufferMap> SendProcessBufferMap;
120 typedef std::map<unsigned int, RecvBuffer> RecvTreeBufferMap;
121 typedef std::map<unsigned int, RecvTreeBufferMap> RecvProcessBufferMap;
122
123 enum FlagType
124 {
125 NOT_TREATED, // process has not been dealth with yet
126 INITIALIZE_TREE, // ghost tree has been created, values not filled yet
127 INITIALIZE_FIELD // cell data values have been set
128 };
129
130 // Associate the process id with its ghost tree processing state
131 typedef std::unordered_map<unsigned int, FlagType> FlagMap;
132
133 // Handling receive and send buffer.
134 // The structure is as follows:
135 // SendBuffer[id] or RecvBuffer[id] == process id of neighbor with whom to communicate buffer
136 // SendBuffer[id][jd] or RecvBuffer[id][jd] tells which tree index is being sent.
137 SendProcessBufferMap SendBuffer;
138 RecvProcessBufferMap RecvBuffer;
139
140 FlagMap Flags;
141
142 std::vector<int> HyperTreesMapToProcesses;
143
144public:
145 // Store the values for a single cell data array, composed of two parts
146 // * InternalArray is the cell array internal to this HTG (ShallowCopied)
147 // * GhostCDBuffer is the buffer with values from ghost cells
153 // All cell data attributes composing a vtkCellData, accessed by name.
154 using CellDataAttributes = std::map<std::string, CellDataArray>;
155
156private:
157 vtkMultiProcessController* Controller = nullptr;
158 vtkHyperTreeGrid* InputHTG = nullptr;
159 vtkHyperTreeGrid* OutputHTG = nullptr;
161 CellDataAttributes ImplicitCD;
162 vtkIdType NumberOfVertices = 0;
163 vtkIdType InitialNumberOfVertices = 0;
164};
165
166VTK_ABI_NAMESPACE_END
167#endif
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...
vtkHyperTreeGridGhostCellsGeneratorInternals(vtkMultiProcessController *controller, vtkHyperTreeGrid *inputHTG, vtkHyperTreeGrid *outputHTG)
void InitializeCellData()
Initialize the internal cell data implicit array handler, with the cell arrays as the first entries o...
void FinalizeCellData()
ProcessTrees subroutine creating the output ghost array and adding it to the output HTG.
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.
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.
#define vtkDataArray
int vtkIdType
Definition vtkType.h:363