VTK  9.7.1
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 
33 VTK_ABI_NAMESPACE_BEGIN
34 
36 {
37 
38 public:
46  vtkMultiProcessController* controller, vtkHyperTreeGrid* inputHTG, vtkHyperTreeGrid* outputHTG);
47 
52  void InitializeCellData();
53 
60 
65  void DetermineNeighbors();
66 
72  int ExchangeSizes();
73 
79 
84  int ExchangeCellData();
85 
89  void FinalizeCellData();
90 
91 private:
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 
145 public:
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 
157 private:
158  vtkHyperTreeGridGhostCellsGenerator* Self = nullptr;
159  vtkMultiProcessController* Controller = nullptr;
160  vtkHyperTreeGrid* InputHTG = nullptr;
161  vtkHyperTreeGrid* OutputHTG = nullptr;
162  vtkSmartPointer<vtkBitArray> OutputMask;
163  CellDataAttributes ImplicitCD;
164  vtkIdType NumberOfVertices = 0;
165  vtkIdType InitialNumberOfVertices = 0;
166 };
167 
168 VTK_ABI_NAMESPACE_END
169 #endif
int ExchangeCellData()
Exchange cell data information with the other process to fill in values for ghost cells...
int ExchangeSizes()
Exchange the number of ghost cells to be sent between ranks.
vtkHyperTreeGridGhostCellsGeneratorInternals(vtkHyperTreeGridGhostCellsGenerator *self, vtkMultiProcessController *controller, vtkHyperTreeGrid *inputHTG, vtkHyperTreeGrid *outputHTG)
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
void DetermineNeighbors()
Compute the index of neighboring trees and record those that belong to other processes and should be ...
int vtkIdType
Definition: vtkType.h:363
void FinalizeCellData()
ProcessTrees subroutine creating the output ghost array and adding it to the output HTG...
Generate ghost cells for distributed vtkHyperTreeGrids.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
int ExchangeTreeDecomposition()
Routine to send and receive tree decomposition, and mask values if present for each tree...
Internal class for vtkHyperTreeGridGhostCellsGenerator.
void BroadcastTreeLocations()
Subroutine performing an MPI AllReduce operation, filling the vector HyperTreesMapToProcesses where H...
void InitializeCellData()
Initialize the internal cell data implicit array handler, with the cell arrays as the first entries o...
Multiprocessing communication superclass.