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 //-----------------------------------------------------------------------------
15 class VTKPVVTKEXTENSIONSIOSPCTH_EXPORT vtkSpyPlotBlockIterator
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 
96 class VTKPVVTKEXTENSIONSIOSPCTH_EXPORT vtkSpyPlotBlockDistributionBlockIterator
98 {
99 public:
101  ~vtkSpyPlotBlockDistributionBlockIterator() override = default;
102  void Start() override;
103  int GetNumberOfBlocksToProcess() override;
104 
105 protected:
106  void FindFirstBlockOfCurrentOrNextFile() override;
107 };
108 
109 class VTKPVVTKEXTENSIONSIOSPCTH_EXPORT vtkSpyPlotFileDistributionBlockIterator
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
vtkSpyPlotReader
Read SPCTH Spy Plot file format.
Definition: vtkSpyPlotReader.h:63
vtkSpyPlotReaderMap.h
vtkSpyPlotBlockIterator::NumberOfFiles
int NumberOfFiles
Definition: vtkSpyPlotBlockIterator.h:82
vtkSpyPlotReaderMap
Maps strings to vtkSpyPlotUniReaders.
Definition: vtkSpyPlotReaderMap.h:26
vtkSpyPlotBlockIterator::FileIterator
vtkSpyPlotReaderMap::MapOfStringToSPCTH::iterator FileIterator
Definition: vtkSpyPlotBlockIterator.h:89
tagBlock
vtkSpyPlotBlockIterator::UniReader
vtkSpyPlotUniReader * UniReader
Definition: vtkSpyPlotBlockIterator.h:87
vtkSpyPlotFileDistributionBlockIterator::FileEnd
int FileEnd
Definition: vtkSpyPlotBlockIterator.h:123
vtkSpyPlotBlockIterator::GetBlockID
int GetBlockID() const
Definition: vtkSpyPlotBlockIterator.h:166
vtkSpyPlotBlockIterator::NumberOfProcessors
int NumberOfProcessors
Definition: vtkSpyPlotBlockIterator.h:77
vtkSpyPlotBlockIterator::Active
int Active
Definition: vtkSpyPlotBlockIterator.h:84
vtkSpyPlotBlockIterator::GetNumberOfProcessors
int GetNumberOfProcessors() const
Definition: vtkSpyPlotBlockIterator.h:144
vtkSpyPlotBlockIterator::GetBlock
vtkSpyPlotBlock * GetBlock() const
Definition: vtkSpyPlotBlockIterator.h:160
vtkSpyPlotBlockIterator::Parent
vtkSpyPlotReader * Parent
Definition: vtkSpyPlotBlockIterator.h:93
vtkSpyPlotUniReader::GetBlock
vtkSpyPlotBlock * GetBlock(int i)
vtkSpyPlotUniReader.h
vtkSpyPlotBlockIterator::FileIndex
int FileIndex
Definition: vtkSpyPlotBlockIterator.h:90
vtkSpyPlotFileDistributionBlockIterator
Definition: vtkSpyPlotBlockIterator.h:109
vtkSpyPlotBlockIterator::Init
virtual void Init(int numberOfProcessors, int processorId, vtkSpyPlotReader *parent, vtkSpyPlotReaderMap *fileMap, int currentTimeStep)
vtkSpyPlotUniReader
Read SPCTH Spy Plot file format.
Definition: vtkSpyPlotUniReader.h:36
vtkSpyPlotBlockDistributionBlockIterator
Definition: vtkSpyPlotBlockIterator.h:96
vtkSpyPlotBlockIterator::FindFirstBlockOfCurrentOrNextFile
virtual void FindFirstBlockOfCurrentOrNextFile()=0
vtkSpyPlotBlockIterator::GetNumberOfFields
int GetNumberOfFields() const
Definition: vtkSpyPlotBlockIterator.h:172
vtkSpyPlotBlockIterator::GetNumberOfBlocksToProcess
virtual int GetNumberOfBlocksToProcess()=0
vtkSpyPlotBlockIterator::Next
void Next()
Definition: vtkSpyPlotBlockIterator.h:126
vtkSpyPlotBlockIterator::Start
virtual void Start()=0
vtkSpyPlotBlockIterator::ProcessorId
int ProcessorId
Definition: vtkSpyPlotBlockIterator.h:78
vtkSpyPlotBlockIterator::CurrentTimeStep
int CurrentTimeStep
Definition: vtkSpyPlotBlockIterator.h:80
vtkSpyPlotBlock
Represents a SpyPlot Block Grid.
Definition: vtkSpyPlotBlock.h:31
vtkSpyPlotBlockIterator::NumberOfFields
int NumberOfFields
Definition: vtkSpyPlotBlockIterator.h:86
vtkSpyPlotBlockIterator::BlockEnd
int BlockEnd
Definition: vtkSpyPlotBlockIterator.h:92
vtkSpyPlotBlockIterator::GetUniReader
vtkSpyPlotUniReader * GetUniReader() const
Definition: vtkSpyPlotBlockIterator.h:149
vtkSpyPlotBlockIterator::Block
int Block
Definition: vtkSpyPlotBlockIterator.h:85
vtkSpyPlotBlockIterator::GetProcessorId
int GetProcessorId() const
Definition: vtkSpyPlotBlockIterator.h:139
vtkSpyPlotBlockIterator
Definition: vtkSpyPlotBlockIterator.h:15
vtkSpyPlotBlockIterator::IsActive
int IsActive() const
Definition: vtkSpyPlotBlockIterator.h:155
vtkSpyPlotBlockIterator::FileMap
vtkSpyPlotReaderMap * FileMap
Definition: vtkSpyPlotBlockIterator.h:79
vtkSpyPlotFileDistributionBlockIterator::FileStart
int FileStart
Definition: vtkSpyPlotBlockIterator.h:122