ensightCaseOptions.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-2018 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 "ensightCase.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
33 :
34  format_(format),
35  overwrite_(false),
36  nodeValues_(false),
37  separateCloud_(false),
38  width_(0),
39  mask_(),
40  printf_()
41 {
42  width(8); // Fill mask and setup printf-format
43 }
44 
45 
46 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
47 
49 {
50  return format_;
51 }
52 
53 
55 {
56  return mask_;
57 }
58 
59 
61 {
62  // As per word::printf(), but with fixed length
63  char buf[32];
64 
65  ::snprintf(buf, 32, printf_.c_str(), static_cast<int>(i));
66  buf[31] = 0;
67 
68  // No stripping required
69  return word(buf, false);
70 }
71 
72 
74 {
75  return width_;
76 }
77 
78 
80 {
81  // Enforce min/max sanity limits
82  if (n < 1 || n > 31)
83  {
84  return;
85  }
86 
87  // Set mask accordingly
88  mask_.resize(n, '*');
89 
90  // Appropriate printf format
91  printf_ = "%0" + std::to_string(n) + "d";
92 }
93 
94 
96 {
97  return overwrite_;
98 }
99 
100 
102 {
103  overwrite_ = b;
104 }
105 
106 
108 {
109  return nodeValues_;
110 }
111 
112 
114 {
115  nodeValues_ = b;
116 }
117 
118 
120 {
121  return separateCloud_;
122 }
123 
124 
126 {
127  separateCloud_ = b;
128 }
129 
130 
131 // ************************************************************************* //
Foam::ensightCase::options::mask
const word & mask() const
The '*' mask appropriate for sub-directories.
Definition: ensightCaseOptions.C:54
Foam::ensightCase::options::format
IOstream::streamFormat format() const
Ascii/Binary file output.
Definition: ensightCaseOptions.C:48
Foam::ensightCase::options::padded
word padded(const label i) const
Consistent zero-padded integer value.
Definition: ensightCaseOptions.C:60
ensightCase.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::ensightCase::options::width
label width() const
Return current width of mask and padded.
Definition: ensightCaseOptions.C:73
n
label n
Definition: TABSMDCalcMethod2.H:31
format
word format(conversionProperties.get< word >("format"))
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Foam::ensightCase::options::options
options(IOstream::streamFormat format=IOstream::BINARY)
Construct with the specified format (default is binary)
Definition: ensightCaseOptions.C:32
Foam::ensightCase::options::nodeValues
bool nodeValues() const
Force use of values per node instead of per element.
Definition: ensightCaseOptions.C:107
Foam::ensightCase::options::overwrite
bool overwrite() const
Remove existing directory and sub-directories on creation.
Definition: ensightCaseOptions.C:95
Foam::IOstreamOption::streamFormat
streamFormat
Data format (ascii | binary)
Definition: IOstreamOption.H:70
Foam::ensightCase::options::separateCloud
bool separateCloud() const
Write clouds into their own directory instead in "data" directory.
Definition: ensightCaseOptions.C:119