ensightMeshOptions.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "ensightMesh.H"
29 #include "Switch.H"
30 
31 // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 // DIY flatOutput without a leading size indicator
37 static Ostream& printPatterns(Ostream& os, const wordRes& list)
38 {
40 
41  bool sep = false;
42 
43  for (const wordRe& item : list)
44  {
45  if (sep) os << token::SPACE;
46  sep = true;
47 
48  os << item;
49  }
51 
52  return os;
53 }
54 
55 } // End namespace
56 
57 
58 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
59 
61 :
62  lazy_(false),
63  internal_(true),
64  boundary_(true),
65  cellZones_(true),
66  patchInclude_(),
67  patchExclude_(),
68  cellZoneInclude_(),
69  faceZoneInclude_()
70 {}
71 
72 
73 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
74 
75 bool Foam::ensightMesh::options::lazy() const noexcept
76 {
77  return lazy_;
78 }
79 
80 
82 {
83  return internal_;
84 }
85 
86 
88 {
89  return boundary_;
90 }
91 
92 
94 {
95  return cellZones_;
96 }
97 
98 
100 {
101  return faceZoneInclude_.size();
102 }
103 
104 
106 {
107  internal_ = true;
108  boundary_ = true;
109  cellZones_ = true;
110  patchInclude_.clear();
111  patchExclude_.clear();
112  faceZoneInclude_.clear();
113  cellZoneInclude_.clear();
114 }
115 
116 
117 bool Foam::ensightMesh::options::lazy(bool on) noexcept
118 {
119  bool old(lazy_);
120  lazy_ = on;
121  return old;
122 }
123 
124 
126 {
127  bool old(internal_);
128  internal_ = on;
129  return old;
130 }
131 
132 
134 {
135  bool old(boundary_);
136  boundary_ = on;
137 
138  if (!boundary_)
139  {
140  if (patchInclude_.size())
141  {
142  patchInclude_.clear();
143 
145  << "Deactivating boundary, removed old patch selection"
146  << endl;
147  }
148  }
149 
150  return old;
151 }
152 
153 
155 {
156  bool old(cellZones_);
157  cellZones_ = on;
158 
159  if (!cellZones_ && cellZoneInclude_.size())
160  {
161  cellZoneInclude_.clear();
162 
164  << "Deactivating cellZones, removed old zone selection"
165  << endl;
166  }
167 
168  return old;
169 }
170 
171 
173 (
174  const UList<wordRe>& patterns
175 )
176 {
177  patchInclude_ = wordRes(patterns);
178 
179  if (!boundary_ && patchInclude_.size())
180  {
181  patchInclude_.clear();
182 
184  << "Ignoring patch selection, boundary is disabled"
185  << endl;
186  }
187 }
188 
189 
191 (
192  List<wordRe>&& patterns
193 )
194 {
195  patchInclude_ = wordRes(std::move(patterns));
196 
197  if (!boundary_ && patchInclude_.size())
198  {
199  patchInclude_.clear();
200 
202  << "Ignoring patch selection, boundary is disabled"
203  << endl;
204  }
205 }
206 
207 
209 (
210  const UList<wordRe>& patterns
211 )
212 {
213  patchExclude_ = wordRes(patterns);
214 }
215 
216 
218 (
219  List<wordRe>&& patterns
220 )
221 {
222  patchExclude_ = wordRes(std::move(patterns));
223 }
224 
225 
227 (
228  const UList<wordRe>& patterns
229 )
230 {
231  faceZoneInclude_ = wordRes(patterns);
232 }
233 
234 
236 (
237  List<wordRe>&& patterns
238 )
239 {
240  faceZoneInclude_ = wordRes(std::move(patterns));
241 }
242 
243 
245 (
246  const UList<wordRe>& patterns
247 )
248 {
249  cellZoneInclude_ = wordRes(patterns);
250 
251  if (!cellZones_ && cellZoneInclude_.size())
252  {
253  cellZoneInclude_.clear();
254 
256  << "Ignoring cellZone selection, cellZones are disabled"
257  << endl;
258  }
259 }
260 
261 
263 (
264  List<wordRe>&& patterns
265 )
266 {
267  cellZoneInclude_ = wordRes(std::move(patterns));
268 
269  if (!cellZones_ && cellZoneInclude_.size())
270  {
271  cellZoneInclude_.clear();
272 
274  << "Ignoring cellZone selection, cellZones are disabled"
275  << endl;
276  }
277 }
278 
279 
281 {
282  os << "internal: " << Switch::name(internal_) << nl;
283  os << "cellZones: " << Switch::name(cellZones_) << nl;
284  if (cellZones_)
285  {
286  os.incrIndent();
287  if (!cellZoneInclude_.empty())
288  {
289  os.writeKeyword("include");
290  printPatterns(os, cellZoneInclude_) << nl;
291  }
292  os.decrIndent();
293  }
294 
295  os << "boundary: " << Switch::name(boundary_) << nl;
296  if (boundary_)
297  {
298  os.incrIndent();
299  if (!patchInclude_.empty())
300  {
301  os.writeKeyword("include");
302  printPatterns(os, patchInclude_) << nl;
303  }
304  if (!patchExclude_.empty())
305  {
306  os.writeKeyword("exclude");
307  printPatterns(os, patchExclude_) << nl;
308  }
309  os.decrIndent();
310  }
311 
312  os << "faceZones: " << Switch::name(useFaceZones()) << nl;
313  if (useFaceZones())
314  {
315  os.incrIndent();
316  if (!faceZoneInclude_.empty())
317  {
318  os.writeKeyword("include");
319  printPatterns(os, faceZoneInclude_) << nl;
320  }
321  os.decrIndent();
322  }
323 }
324 
325 
326 // ************************************************************************* //
Foam::ensightMesh::options::patchExclude
const wordRes & patchExclude() const noexcept
Selection of black listed patches. Empty if unspecified.
Definition: ensightMesh.H:291
Foam::ensightMesh::options::useInternalMesh
bool useInternalMesh() const noexcept
Using internal?
Definition: ensightMeshOptions.C:81
Foam::ensightMesh::options::faceZoneSelection
const wordRes & faceZoneSelection() const noexcept
Selection of faceZones. Empty if unspecified.
Definition: ensightMesh.H:297
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::ensightMesh::options::useFaceZones
bool useFaceZones() const noexcept
Using faceZones?
Definition: ensightMeshOptions.C:99
Foam::ensightMesh::options::lazy
bool lazy() const noexcept
Lazy creation? (ie, starts as needsUpdate)
Definition: ensightMeshOptions.C:75
Foam::wordRe
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:80
ensightMesh.H
Foam::ensightMesh::options::useCellZones
bool useCellZones() const noexcept
Using cellZones?
Definition: ensightMeshOptions.C:93
Switch.H
Foam::Switch::name
static const char * name(const bool b) noexcept
A string representation of bool as "false" / "true".
Definition: Switch.C:145
Foam::ensightMesh::options::reset
void reset()
Reset to defaults.
Definition: ensightMeshOptions.C:105
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::ensightMesh::options::patchSelection
const wordRes & patchSelection() const noexcept
Selection of patches. Empty if unspecified.
Definition: ensightMesh.H:285
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::printPatterns
static Ostream & printPatterns(Ostream &os, const wordRes &list)
Definition: ensightMeshOptions.C:37
Foam::List< wordRe >
Foam::ensightMesh::options::cellZoneSelection
const wordRes & cellZoneSelection() const noexcept
Selection of faceZones. Empty if unspecified.
Definition: ensightMesh.H:303
Foam::token::SPACE
Space [isspace].
Definition: token.H:125
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:103
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::token::END_LIST
End list [isseparator].
Definition: token.H:156
Foam::ensightMesh::options::print
void print(Ostream &os) const
Report values.
Definition: ensightMeshOptions.C:280
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::token::BEGIN_LIST
Begin list [isseparator].
Definition: token.H:155
Foam::ensightMesh::options::options
options()
Default construct. Non-lazy with internal/boundary/cellZones.
Definition: ensightMeshOptions.C:60
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:328
Foam::ensightMesh::options::useBoundaryMesh
bool useBoundaryMesh() const noexcept
Using boundary?
Definition: ensightMeshOptions.C:87