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-------------------------------------------------------------------------------
10License
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
33namespace Foam
34{
35
36// DIY flatOutput without a leading size indicator
37static 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
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 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// ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
virtual Ostream & writeKeyword(const keyType &kw)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:57
void decrIndent()
Decrement the indent level.
Definition: Ostream.C:37
void incrIndent() noexcept
Increment the indent level.
Definition: Ostream.H:205
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
bool useBoundaryMesh() const noexcept
Using boundary?
const wordRes & faceZoneSelection() const noexcept
Selection of faceZones. Empty if unspecified.
Definition: ensightMesh.H:308
bool useInternalMesh() const noexcept
Using internal?
bool useFaceZones() const noexcept
Using faceZones?
const wordRes & patchSelection() const noexcept
Selection of patches. Empty if unspecified.
Definition: ensightMesh.H:296
bool lazy() const noexcept
Lazy creation? (ie, starts as needsUpdate)
const wordRes & patchExclude() const noexcept
Selection of black listed patches. Empty if unspecified.
Definition: ensightMesh.H:302
void reset()
Reset to defaults.
options()
Default construct. Non-lazy with internal/boundary/cellZones.
bool useCellZones() const noexcept
Using cellZones?
const wordRes & cellZoneSelection() const noexcept
Selection of faceZones. Empty if unspecified.
Definition: ensightMesh.H:314
scalar print()
Print to screen.
@ BEGIN_LIST
Begin list [isseparator].
Definition: token.H:155
@ END_LIST
End list [isseparator].
Definition: token.H:156
@ SPACE
Space [isspace].
Definition: token.H:125
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:83
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
OBJstream os(runTime.globalPath()/outputName)
#define WarningInFunction
Report a warning using Foam::Warning.
Namespace for OpenFOAM.
static Ostream & printPatterns(Ostream &os, const wordRes &list)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
const direction noexcept
Definition: Scalar.H:223
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53