vtkPV3FoamUpdateInfoFields.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-2016 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  vtkPV3Foam
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #ifndef vtkPV3FoamUpdateInfoFields_H
30 #define vtkPV3FoamUpdateInfoFields_H
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 template<template<class> class patchType, class meshType>
35 void Foam::vtkPV3Foam::updateInfoFields
36 (
37  vtkDataArraySelection* select
38 )
39 {
40  if (debug)
41  {
42  Info<< "<beg> Foam::vtkPV3Foam::updateInfoFields <"
43  << meshType::Mesh::typeName
44  << "> [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]"
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  // Search for list of objects for this time and mesh region
73  IOobjectList objects(dbPtr_(), dbPtr_().timeName(), regionPrefix);
74 
75  //- Add volume fields to GUI
76  addToSelection<GeometricField<scalar, patchType, meshType>>
77  (
78  select,
79  objects
80  );
81  addToSelection<GeometricField<vector, patchType, meshType>>
82  (
83  select,
84  objects
85  );
86  addToSelection<GeometricField<sphericalTensor, patchType, meshType>>
87  (
88  select,
89  objects
90  );
91  addToSelection<GeometricField<symmTensor, patchType, meshType>>
92  (
93  select,
94  objects
95  );
96  addToSelection<GeometricField<tensor, patchType, meshType>>
97  (
98  select,
99  objects
100  );
101 
102  // restore the enabled selections
103  setSelectedArrayEntries(select, enabledEntries);
104 
105  if (debug)
106  {
107  Info<< "<end> Foam::vtkPV3Foam::updateInfoFields" << endl;
108  }
109 }
110 
111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112 
113 #endif
114 
115 // ************************************************************************* //
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:306
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
word timeName
Definition: getTimeIndex.H:3
List< string > stringList
A List of strings.
Definition: stringList.H:50
void setSize(const label)
Reset size of List.
Definition: List.C:295
messageStream Info