vtkPVblockMesh.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::vtkPVblockMesh
26 
27 Description
28  Provides a reader interface for OpenFOAM blockMesh to VTK interaction
29 
30 SourceFiles
31  vtkPVblockMesh.C
32  vtkPVblockMeshConvert.C
33  vtkPVblockMeshUpdate.C
34  vtkPVblockMeshUtils.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef vtkPVblockMesh_H
39 #define vtkPVblockMesh_H
40 
41 // do not include legacy strstream headers
42 #ifndef VTK_EXCLUDE_STRSTREAM_HEADERS
43  #define VTK_EXCLUDE_STRSTREAM_HEADERS
44 #endif
45 
46 #include "className.H"
47 #include "fileName.H"
48 #include "stringList.H"
49 #include "wordList.H"
50 #include "primitivePatch.H"
51 
52 #undef Log
53 
54 // * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * //
55 
56 class vtkDataArraySelection;
57 class vtkDataSet;
58 class vtkPoints;
59 class vtkPVblockMeshReader;
60 class vtkRenderer;
61 class vtkTextActor;
62 class vtkMultiBlockDataSet;
63 class vtkPolyData;
64 class vtkUnstructuredGrid;
65 class vtkIndent;
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 namespace Foam
70 {
71 
72 // OpenFOAM class forward declarations
73 class argList;
74 class Time;
75 class blockMesh;
76 
77 template<class Type> class List;
78 
79 /*---------------------------------------------------------------------------*\
80  Class vtkPVblockMesh Declaration
81 \*---------------------------------------------------------------------------*/
82 
83 class vtkPVblockMesh
84 {
85  // Private classes
86 
87  //- Bookkeeping for GUI checklists and the multi-block organisation
88  class arrayRange
89  {
90  const char *name_;
91  int block_;
92  int start_;
93  int size_;
94 
95  public:
96 
97  arrayRange(const char *name, const int blockNo=0)
98  :
99  name_(name),
100  block_(blockNo),
101  start_(0),
102  size_(0)
103  {}
104 
105  //- Return the block holding these datasets
106  int block() const
107  {
108  return block_;
109  }
110 
111  //- Assign block number, return previous value
112  int block(int blockNo)
113  {
114  int prev = block_;
115  block_ = blockNo;
116  return prev;
117  }
118 
119  //- Return block name
120  const char* name() const
121  {
122  return name_;
123  }
124 
125  //- Return array start index
126  int start() const
127  {
128  return start_;
129  }
130 
131  //- Return array end index
132  int end() const
133  {
134  return start_ + size_;
135  }
136 
137  //- Return sublist size
138  int size() const
139  {
140  return size_;
141  }
142 
143  bool empty() const
144  {
145  return !size_;
146  }
147 
148  //- Reset the size to zero and optionally assign a new start
149  void reset(const int startAt = 0)
150  {
151  start_ = startAt;
152  size_ = 0;
153  }
154 
155  //- Increment the size
156  void operator+=(const int n)
157  {
158  size_ += n;
159  }
160  };
161 
162 
163  // Private Data
164 
165  //- Access to the controlling vtkPVblockMeshReader
166  vtkPVblockMeshReader* reader_;
167 
168  //- OpenFOAM time control
169  autoPtr<Time> dbPtr_;
170 
171  //- OpenFOAM mesh
172  autoPtr<blockMesh> meshPtr_;
173 
174  //- The mesh region
175  word meshRegion_;
176 
177  //- The mesh directory for the region
178  fileName meshDir_;
179 
180  //- Selected geometrical parts
181  boolList blockStatus_;
182 
183  //- Selected curved edges
184  boolList edgeStatus_;
185 
186  //- First instance and size of blockMesh blocks
187  // used to index into blockStatus_
188  arrayRange arrayRangeBlocks_;
189 
190  //- First instance and size of CurvedEdges (only partially used)
191  arrayRange arrayRangeEdges_;
192 
193  //- First instance and size of block corners (only partially used)
194  arrayRange arrayRangeCorners_;
195 
196  //- List of point numbers for rendering to window
197  List<vtkTextActor*> pointNumberTextActorsPtrs_;
198 
199 
200  // Private Member Functions
201 
202  // Convenience method use to convert the readers from VTK 5
203  // multiblock API to the current composite data infrastructure
204  static void AddToBlock
205  (
206  vtkMultiBlockDataSet* output,
207  vtkDataSet* dataset,
208  const arrayRange&,
209  const label datasetNo,
210  const std::string& datasetName
211  );
212 
213  // Convenience method use to convert the readers from VTK 5
214  // multiblock API to the current composite data infrastructure
215  static vtkDataSet* GetDataSetFromBlock
216  (
217  vtkMultiBlockDataSet* output,
218  const arrayRange&,
219  const label datasetNo
220  );
221 
222  // Convenience method use to convert the readers from VTK 5
223  // multiblock API to the current composite data infrastructure
224  static label GetNumberOfDataSets
225  (
226  vtkMultiBlockDataSet* output,
227  const arrayRange&
228  );
229 
230  //- Update boolList from GUI selection
231  static void updateBoolListStatus
232  (
233  boolList&,
234  vtkDataArraySelection*
235  );
236 
237  //- Reset data counters
238  void resetCounters();
239 
240 
241  // Update information helper functions
242 
243  //- Internal block info
244  void updateInfoBlocks(vtkDataArraySelection*);
245 
246  //- Block curved edges info
247  void updateInfoEdges(vtkDataArraySelection*);
248 
249 
250  // Update helper functions
251 
252  //- OpenFOAM mesh
253  void updateFoamMesh();
254 
255 
256  // Mesh conversion functions
257 
258  //- Mesh blocks
259  void convertMeshBlocks(vtkMultiBlockDataSet*, int& blockNo);
260 
261  //- Mesh curved edges
262  void convertMeshEdges(vtkMultiBlockDataSet*, int& blockNo);
263 
264  //- Mesh corners
265  void convertMeshCorners(vtkMultiBlockDataSet*, int& blockNo);
266 
267 
268  // GUI selection helper functions
269 
270  //- Retrieve the current selections
271  static wordHashSet getSelected(vtkDataArraySelection*);
272 
273  //- Retrieve a sub-list of the current selections
274  static wordHashSet getSelected
275  (
276  vtkDataArraySelection*,
277  const arrayRange&
278  );
279 
280  //- Retrieve the current selections
281  static stringList getSelectedArrayEntries
282  (
283  vtkDataArraySelection*,
284  const bool debug = vtkPVblockMesh::debug
285  );
286 
287  //- Retrieve a sub-list of the current selections
288  static stringList getSelectedArrayEntries
289  (
290  vtkDataArraySelection*,
291  const arrayRange&,
292  const bool debug = vtkPVblockMesh::debug
293  );
294 
295  //- Set selection(s)
296  static void setSelectedArrayEntries
297  (
298  vtkDataArraySelection*,
299  const stringList&
300  );
301 
302 
303 public:
304 
305  //- Static data members
306 
307  ClassName("vtkPVblockMesh");
308 
309 
310  // Constructors
311 
312  //- Construct from components
314  (
315  const char* const FileName,
316  vtkPVblockMeshReader* reader
317  );
318 
319  //- Disallow default bitwise copy construction
320  vtkPVblockMesh(const vtkPVblockMesh&) = delete;
321 
322 
323  //- Destructor
324  ~vtkPVblockMesh();
325 
326 
327  // Member Functions
328 
329  //- Update information
330  void updateInfo();
331 
332  //- Update
333  void Update(vtkMultiBlockDataSet* output);
334 
335  //- Clean any storage
336  void CleanUp();
337 
338  //- Add/remove point numbers to/from the view
339  void renderPointNumbers(vtkRenderer*, const bool show);
340 
341 
342  // Access
343 
344  //- Debug information
345  void PrintSelf(ostream&, vtkIndent) const;
346 
347 
348  // Member Operators
349 
350  //- Disallow default bitwise assignment
351  void operator=(const vtkPVblockMesh&) = delete;
352 };
353 
354 
355 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
356 
357 } // End namespace Foam
358 
359 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
360 
361 #endif
362 
363 // ************************************************************************* //
label n
A HashTable with keys but without contents.
Definition: HashSet.H:62
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
Definition: block.H:66
A class for handling file names.
Definition: fileName.H:82
Motion of the mesh specified as a list of pointMeshMovers.
Provides a reader interface for OpenFOAM blockMesh to VTK interaction.
~vtkPVblockMesh()
Destructor.
ClassName("vtkPVblockMesh")
Static data members.
void Update(vtkMultiBlockDataSet *output)
Update.
void PrintSelf(ostream &, vtkIndent) const
Debug information.
void CleanUp()
Clean any storage.
void renderPointNumbers(vtkRenderer *, const bool show)
Add/remove point numbers to/from the view.
vtkPVblockMesh(const char *const FileName, vtkPVblockMeshReader *reader)
Construct from components.
void operator=(const vtkPVblockMesh &)=delete
Disallow default bitwise assignment.
void updateInfo()
Update information.
A class for handling words, derived from string.
Definition: word.H:63
Macro definitions for declaring ClassName(), NamespaceName(), etc.
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
void operator+=(fvMatrix< Type > &fvEqn, const CarrierEqn< Type > &cEqn)
Add to a finite-volume equation.
Definition: CarrierEqn.C:271