vtkPVFoamUpdateInfoFields.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-2018 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  // Use the db directly since this might be called without a mesh,
49  // but the region must get added back in
50  word regionPrefix;
51  if (meshRegion_ != polyMesh::defaultRegion)
52  {
53  regionPrefix = meshRegion_;
54  }
55 
56  const instantList times = dbPtr_().times();
57 
58  stringList enabledEntries;
59 
60  if (select->GetNumberOfArrays() == 0 && !meshPtr_)
61  {
62  const wordReList defaultFieldRes
63  (
64  configDict_.lookupOrDefault
65  (
66  "defaultFields",
67  wordReList(wordList{"p", "U"})
68  )
69  );
70 
71  wordHashSet objectNameSet;
72  forAll(times, timei)
73  {
74  // Search for list of objects for this time and mesh region
75  IOobjectList objects(dbPtr_(), times[timei].name(), regionPrefix);
76 
77  forAllConstIter(IOobjectList, objects, iter)
78  {
79  objectNameSet.insert(iter.key());
80  }
81  }
82 
83  const wordList objectNames(objectNameSet.toc());
84  const labelList defaultFields
85  (
86  findStrings(defaultFieldRes, objectNames)
87  );
88 
89  enabledEntries.setSize(defaultFields.size());
90  forAll(defaultFields, i)
91  {
92  enabledEntries[i] = objectNames[defaultFields[i]];
93  }
94  }
95  else
96  {
97  // Preserve the enabled selections
98  enabledEntries = getSelectedArrayEntries(select);
99  }
100 
101  select->RemoveAllArrays();
102 
103  forAll(times, timei)
104  {
105  // Search for list of objects for this time and mesh region
106  IOobjectList objects(dbPtr_(), times[timei].name(), regionPrefix);
107 
108  //- Add volume fields to GUI
109  addToSelection<GeometricField<scalar, patchType, meshType>>
110  (
111  select,
112  objects
113  );
114  addToSelection<GeometricField<vector, patchType, meshType>>
115  (
116  select,
117  objects
118  );
119  addToSelection<GeometricField<sphericalTensor, patchType, meshType>>
120  (
121  select,
122  objects
123  );
124  addToSelection<GeometricField<symmTensor, patchType, meshType>>
125  (
126  select,
127  objects
128  );
129  addToSelection<GeometricField<tensor, patchType, meshType>>
130  (
131  select,
132  objects
133  );
134  }
135 
136  // Restore the enabled selections
137  setSelectedArrayEntries(select, enabledEntries);
138 
139  if (debug)
140  {
141  Info<< "<end> Foam::vtkPVFoam::updateInfoFields" << endl;
142  }
143 }
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 
147 #endif
148 
149 // ************************************************************************* //
List< instant > instantList
List of instants.
Definition: instantList.H:42
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:309
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
bool findStrings(const wordReListMatcher &matcher, const std::string &str)
Return true if string matches one of the regular expressions.
Definition: stringListOps.H:52
List< label > labelList
A List of labels.
Definition: labelList.H:56
HashSet wordHashSet
A HashSet with word keys.
Definition: HashSet.H:205
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
objects
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
List< word > wordList
A List of words.
Definition: fileName.H:54
List< string > stringList
A List of strings.
Definition: stringList.H:50
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
messageStream Info
List< wordRe > wordReList
A List of wordRe (word or regular expression)
Definition: wordReList.H:50