vtkSpyPlotBlockIterator.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
3 #ifndef vtkSpyPlotBlockIterator_h
4 #define vtkSpyPlotBlockIterator_h
5 
6 #include "vtkPVVTKExtensionsIOSPCTHModule.h" //needed for exports
7 #include "vtkSpyPlotReaderMap.h" // for vtkSpyPlotReaderMap iterator
8 #include "vtkSpyPlotUniReader.h" // for vtkSpyPlotUniReader
9 
10 #include <cassert> // for assert
11 
12 class vtkSpyPlotReader;
13 
14 //-----------------------------------------------------------------------------
16 {
17 public:
18  // Description:
19  // Initialize the iterator with information about processors,
20  // files and timestep.
21  virtual void Init(int numberOfProcessors, int processorId, vtkSpyPlotReader* parent,
22  vtkSpyPlotReaderMap* fileMap, int currentTimeStep);
23 
24  // Description:
25  // Go to first block if any.
26  virtual void Start() = 0;
27 
28  // Description:
29  // Returns the total number of blocks to be processed by this Processor.
30  // Can be called only after Init().
31  virtual int GetNumberOfBlocksToProcess() = 0;
32 
33  // Description:
34  // Are there still blocks to iterate over?
35  int IsActive() const;
36 
37  // Description:
38  // Go to the next block if any
39  // \pre is_active: IsActive()
40  void Next();
41 
42  // Description:
43  // Return the block at current position.
44  // \pre is_active: IsActive()
45  vtkSpyPlotBlock* GetBlock() const;
46 
47  // Description:
48  // Return the blockID at current position.
49  // \pre is_active: IsActive()
50  int GetBlockID() const;
51 
52  // Description:
53  // Return the number of fields at current position.
54  // \pre is_active: IsActive()
55  int GetNumberOfFields() const;
56 
57  // Description:
58  // Return the SPCTH API handle at current position.
59  // \pre is_active: IsActive()
60  vtkSpyPlotUniReader* GetUniReader() const;
61 
62  // Description:
63  // Return the number of processors being used
64  int GetNumberOfProcessors() const;
65 
66  // Description:
67  // Return the id of this processor
68  int GetProcessorId() const;
69 
70  virtual ~vtkSpyPlotBlockIterator() = default;
71 
72 protected:
74 
75  virtual void FindFirstBlockOfCurrentOrNextFile() = 0;
76 
81 
83 
84  int Active;
85  int Block;
88 
89  vtkSpyPlotReaderMap::MapOfStringToSPCTH::iterator FileIterator;
90  int FileIndex;
91 
92  int BlockEnd;
94 };
95 
98 {
99 public:
101  ~vtkSpyPlotBlockDistributionBlockIterator() override = default;
102  void Start() override;
103  int GetNumberOfBlocksToProcess() override;
104 
105 protected:
106  void FindFirstBlockOfCurrentOrNextFile() override;
107 };
108 
110  : public vtkSpyPlotBlockIterator
111 {
112 public:
114  ~vtkSpyPlotFileDistributionBlockIterator() override = default;
115  void Init(int numberOfProcessors, int processorId, vtkSpyPlotReader* parent,
116  vtkSpyPlotReaderMap* fileMap, int currentTimeStep) override;
117  void Start() override;
118  int GetNumberOfBlocksToProcess() override;
119 
120 protected:
121  void FindFirstBlockOfCurrentOrNextFile() override;
123  int FileEnd;
124 };
125 
127 {
128  assert("pre: is_active" && IsActive());
129 
130  ++this->Block;
131  if (this->Block > this->BlockEnd)
132  {
133  ++this->FileIterator;
134  ++this->FileIndex;
136  }
137 }
138 
140 {
141  return this->ProcessorId;
142 }
143 
145 {
146  return this->NumberOfProcessors;
147 }
148 
150 {
151  assert("pre: is_active" && IsActive());
152  return this->UniReader;
153 }
154 
156 {
157  return this->Active;
158 }
159 
161 {
162  assert("pre: is_active" && IsActive());
163  return this->UniReader->GetBlock(Block);
164 }
165 
167 {
168  assert("pre: is_active" && IsActive());
169  return Block;
170 }
171 
173 {
174  assert("pre: is_active" && IsActive());
175  return this->NumberOfFields;
176 }
177 
178 #endif
179 
180 // VTK-HeaderTest-Exclude: vtkSpyPlotBlockIterator.h
Maps strings to vtkSpyPlotUniReaders.
vtkSpyPlotUniReader * UniReader
vtkSpyPlotReaderMap * FileMap
vtkSpyPlotReaderMap::MapOfStringToSPCTH::iterator FileIterator
vtkSpyPlotBlock * GetBlock() const
virtual void Init(int numberOfProcessors, int processorId, vtkSpyPlotReader *parent, vtkSpyPlotReaderMap *fileMap, int currentTimeStep)
Read SPCTH Spy Plot file format.
vtkSpyPlotUniReader * GetUniReader() const
virtual void FindFirstBlockOfCurrentOrNextFile()=0
virtual void Start()=0
#define VTKPVVTKEXTENSIONSIOSPCTH_EXPORT
Represents a SpyPlot Block Grid.
virtual int GetNumberOfBlocksToProcess()=0
Read SPCTH Spy Plot file format.