vtkPVFoamUpdateInfoFields.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2017 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 InClass
25  vtkPVFoam
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #ifndef vtkPVFoamUpdateInfoFields_H
30 #define vtkPVFoamUpdateInfoFields_H
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 template<template<class> class patchType, class meshType>
35 void Foam::vtkPVFoam::updateInfoFields
36 (
37  vtkDataArraySelection* select
38 )
39 {
40  if (debug)
41  {
42  Info<< "<beg> Foam::vtkPVFoam::updateInfoFields <"
43  << meshType::Mesh::typeName
44  << "> [meshPtr=" << (meshPtr_ ? "set" : "nullptr") << "]"
45  << endl;
46  }
47 
48  stringList enabledEntries;
49  // enable 'p' and 'U' on the first call
50  if (select->GetNumberOfArrays() == 0 && !meshPtr_)
51  {
52  enabledEntries.setSize(2);
53  enabledEntries[0] = "p";
54  enabledEntries[1] = "U";
55  }
56  else
57  {
58  // preserve the enabled selections
59  enabledEntries = getSelectedArrayEntries(select);
60  }
61 
62  select->RemoveAllArrays();
63 
64  // use the db directly since this might be called without a mesh,
65  // but the region must get added back in
66  word regionPrefix;
67  if (meshRegion_ != polyMesh::defaultRegion)
68  {
69  regionPrefix = meshRegion_;
70  }
71 
72  instantList times = dbPtr_().times();
73  forAll(times, timei)
74  {
75  // Search for list of objects for this time and mesh region
76  IOobjectList objects(dbPtr_(), times[timei].name(), regionPrefix);
77 
78  //- Add volume fields to GUI
79  addToSelection<GeometricField<scalar, patchType, meshType>>
80  (
81  select,
82  objects
83  );
84  addToSelection<GeometricField<vector, patchType, meshType>>
85  (
86  select,
87  objects
88  );
89  addToSelection<GeometricField<sphericalTensor, patchType, meshType>>
90  (
91  select,
92  objects
93  );
94  addToSelection<GeometricField<symmTensor, patchType, meshType>>
95  (
96  select,
97  objects
98  );
99  addToSelection<GeometricField<tensor, patchType, meshType>>
100  (
101  select,
102  objects
103  );
104  }
105 
106  // restore the enabled selections
107  setSelectedArrayEntries(select, enabledEntries);
108 
109  if (debug)
110  {
111  Info<< "<end> Foam::vtkPVFoam::updateInfoFields" << endl;
112  }
113 }
114 
115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116 
117 #endif
118 
119 // ************************************************************************* //
List< instant > instantList
List of instants.
Definition: instantList.H:42
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:309
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
List< string > stringList
A List of strings.
Definition: stringList.H:50
void setSize(const label)
Reset size of List.
Definition: List.C:281
messageStream Info