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 {
39  os << token::BEGIN_LIST;
40 
41  bool sep = false;
42 
43  for (const wordRe& item : list)
44  {
45  if (sep) os << token::SPACE;
46  os << item;
47 
48  sep = true;
49  }
50  os << token::END_LIST;
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 
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 
118 {
119  lazy_ = beLazy;
120 }
121 
122 
124 {
125  internal_ = on;
126 }
127 
128 
130 {
131  boundary_ = on;
132 
133  if (!boundary_)
134  {
135  if (patchInclude_.size())
136  {
137  patchInclude_.clear();
138 
140  << "Deactivating boundary, removed old patch selection"
141  << endl;
142  }
143  }
144 }
145 
146 
148 {
149  cellZones_ = on;
150 
151  if (!cellZones_ && cellZoneInclude_.size())
152  {
153  cellZoneInclude_.clear();
154 
156  << "Deactivating cellZones, removed old zone selection"
157  << endl;
158  }
159 }
160 
161 
163 (
164  const UList<wordRe>& patterns
165 )
166 {
167  patchInclude_ = wordRes(patterns);
168 
169  if (!boundary_ && patchInclude_.size())
170  {
171  patchInclude_.clear();
172 
174  << "Ignoring patch selection, boundary is disabled"
175  << endl;
176  }
177 }
178 
179 
181 (
182  List<wordRe>&& patterns
183 )
184 {
185  patchInclude_ = wordRes(std::move(patterns));
186 
187  if (!boundary_ && patchInclude_.size())
188  {
189  patchInclude_.clear();
190 
192  << "Ignoring patch selection, boundary is disabled"
193  << endl;
194  }
195 }
196 
197 
199 (
200  const UList<wordRe>& patterns
201 )
202 {
203  patchExclude_ = wordRes(patterns);
204 }
205 
206 
208 (
209  List<wordRe>&& patterns
210 )
211 {
212  patchExclude_ = wordRes(std::move(patterns));
213 }
214 
215 
217 (
218  const UList<wordRe>& patterns
219 )
220 {
221  faceZoneInclude_ = wordRes(patterns);
222 }
223 
224 
226 (
227  List<wordRe>&& patterns
228 )
229 {
230  faceZoneInclude_ = wordRes(std::move(patterns));
231 }
232 
233 
235 (
236  const UList<wordRe>& patterns
237 )
238 {
239  cellZoneInclude_ = wordRes(patterns);
240 
241  if (!cellZones_ && cellZoneInclude_.size())
242  {
243  cellZoneInclude_.clear();
244 
246  << "Ignoring cellZone selection, cellZones are disabled"
247  << endl;
248  }
249 }
250 
251 
253 (
254  List<wordRe>&& patterns
255 )
256 {
257  cellZoneInclude_ = wordRes(std::move(patterns));
258 
259  if (!cellZones_ && cellZoneInclude_.size())
260  {
261  cellZoneInclude_.clear();
262 
264  << "Ignoring cellZone selection, cellZones are disabled"
265  << endl;
266  }
267 }
268 
269 
271 {
272  return patchInclude_;
273 }
274 
275 
277 {
278  return patchExclude_;
279 }
280 
281 
283 {
284  return faceZoneInclude_;
285 }
286 
287 
289 {
290  return cellZoneInclude_;
291 }
292 
293 
295 {
296  os << "internal: " << Switch::name(internal_) << nl;
297  os << "cellZones: " << Switch::name(cellZones_) << nl;
298  if (cellZones_)
299  {
300  os.incrIndent();
301  if (!cellZoneInclude_.empty())
302  {
303  os.writeKeyword("include");
304  printPatterns(os, cellZoneInclude_) << nl;
305  }
306  os.decrIndent();
307  }
308 
309  os << "boundary: " << Switch::name(boundary_) << nl;
310  if (boundary_)
311  {
312  os.incrIndent();
313  if (!patchInclude_.empty())
314  {
315  os.writeKeyword("include");
316  printPatterns(os, patchInclude_) << nl;
317  }
318  if (!patchExclude_.empty())
319  {
320  os.writeKeyword("exclude");
321  printPatterns(os, patchExclude_) << nl;
322  }
323  os.decrIndent();
324  }
325 
326  os << "faceZones: " << Switch::name(useFaceZones()) << nl;
327  if (useFaceZones())
328  {
329  os.incrIndent();
330  if (!faceZoneInclude_.empty())
331  {
332  os.writeKeyword("include");
333  printPatterns(os, faceZoneInclude_) << nl;
334  }
335  os.decrIndent();
336  }
337 }
338 
339 
340 // ************************************************************************* //
Foam::ensightMesh::options::useCellZones
bool useCellZones() const
Using cellZones?
Definition: ensightMeshOptions.C:93
Foam::ensightMesh::options::useBoundaryMesh
bool useBoundaryMesh() const
Using boundary?
Definition: ensightMeshOptions.C:87
Foam::ensightMesh::options::faceZoneSelection
const wordRes & faceZoneSelection() const
Selection of faceZones. Empty if unspecified.
Definition: ensightMeshOptions.C:282
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::wordRe
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:72
Foam::ensightMesh::options::useFaceZones
bool useFaceZones() const
Using faceZones?
Definition: ensightMeshOptions.C:99
ensightMesh.H
Foam::ensightMesh::options::useInternalMesh
bool useInternalMesh() const
Using internal?
Definition: ensightMeshOptions.C:81
Foam::ensightMesh::options::cellZoneSelection
const wordRes & cellZoneSelection() const
Selection of faceZones. Empty if unspecified.
Definition: ensightMeshOptions.C:288
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::Ostream::decrIndent
void decrIndent()
Decrement the indent level.
Definition: Ostream.C:37
Foam::ensightMesh::options::reset
void reset()
Reset to defaults.
Definition: ensightMeshOptions.C:105
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::ensightMesh::options::lazy
bool lazy() const
Lazy creation? (ie, ensightMesh starts as needsUpdate)
Definition: ensightMeshOptions.C:75
Foam::Ostream::writeKeyword
virtual Ostream & writeKeyword(const keyType &kw)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:57
Foam::ensightMesh::options::patchSelection
const wordRes & patchSelection() const
Selection of patches. Empty if unspecified.
Definition: ensightMeshOptions.C:270
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::Ostream::incrIndent
void incrIndent()
Increment the indent level.
Definition: Ostream.H:198
Foam::printPatterns
static Ostream & printPatterns(Ostream &os, const wordRes &list)
Definition: ensightMeshOptions.C:37
Foam::List< wordRe >
Foam::token::SPACE
Space [isspace].
Definition: token.H:117
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:123
Foam::ensightMesh::options::print
void print(Ostream &os) const
Report values.
Definition: ensightMeshOptions.C:294
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:122
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:303
Foam::ensightMesh::options::patchExclude
const wordRes & patchExclude() const
Selection of black listed patches. Empty if unspecified.
Definition: ensightMeshOptions.C:276