ensightPart.H
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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2016-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::ensightPart
29
30Description
31 Base class for ensightCells, ensightFaces, ensightOutputSurfaces.
32
33SourceFiles
34 ensightPart.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef ensightPart_H
39#define ensightPart_H
40
41#include "ensightGeoFile.H"
42#include "labelList.H"
43#include "typeInfo.H"
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
49
50/*---------------------------------------------------------------------------*\
51 Class ensightPart Declaration
52\*---------------------------------------------------------------------------*/
54class ensightPart
55{
56 // Private Data
57
58 //- Part index within a list.
59 // The ensight part number is typically this value +1.
60 label index_;
61
62 //- OpenFOAM identifier (patch index, zone index, etc).
63 // An unused identifier is -1
64 label identifier_;
65
66 //- Part name (or description)
67 string name_;
68
69 //- Linear list of element ids (face/cell)
70 // Sub-sectioning by element type is done by derived classes
71 labelList address_;
72
73
74protected:
75
76 //- Element addressing
77 const labelList& addressing() const noexcept
78 {
79 return address_;
80 }
81
82 //- Element addressing
84 {
85 return address_;
86 }
87
88 //- Clear element addressing
89 void clear()
90 {
91 address_.clear();
92 }
93
94 //- Increase addressing by specified offset value
95 // Eg, change local to global id
96 void incrAddressing(const label off);
97
98 //- Decrease addressing by specified offset value
99 // Eg, change global to local id
100 void decrAddressing(const label off);
101
102
103public:
104
105 //- Declare type-name, virtual type (without debug switch)
106 TypeNameNoDebug("ensightPart");
107
108
109 // Constructors
110
111 //- Default construct. Index=0, identifier = -1
112 ensightPart();
113
114 //- Default construct, with description/partName
115 explicit ensightPart(const string& description);
116
117
118 //- Destructor
119 virtual ~ensightPart() = default;
120
121
122 // Member Functions
123
124 //- The index in a list (0-based)
125 label index() const noexcept
126 {
127 return index_;
128 }
129
130 //- The index in a list (0-based)
131 label& index() noexcept
132 {
133 return index_;
134 }
135
136 //- OpenFOAM identifier (patch, zone, etc), -1 when not in use.
137 label identifier() const noexcept
138 {
139 return identifier_;
140 }
141
142 //- OpenFOAM identifier (patch, zone, etc), -1 when not in use.
143 label& identifier() noexcept
144 {
145 return identifier_;
146 }
147
148 //- Processor-local test for any elements.
149 bool empty() const noexcept
150 {
151 return address_.empty();
152 }
153
154 //- Processor-local size of all elements.
155 label size() const noexcept
156 {
157 return address_.size();
158 }
159
160 //- The part name or description
161 const string& name() const noexcept
162 {
163 return name_;
164 }
165
166 //- Change the part name or description
167 void rename(const string& value)
168 {
169 name_ = value;
170 }
171
172 //- Change the part name or description
173 void rename(string&& value)
174 {
175 name_ = std::move(value);
176 }
177
178
179 // Output
180
181 //- Write information about the object as a dictionary,
182 //- optionally write all element addresses
183 virtual void writeDict(Ostream& os, const bool full=false) const
184 {}
185
186
187 // Member Operators
188
189 //- Processor-local element id from linear-list of addresses.
190 label operator[](const label i) const
191 {
192 return address_[i];
193 }
194};
195
196
197// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198
199// Housekeeping
200
201//- Deprecated(2020-02) - use ensightOutput or member write() methods
202// \deprecated(2020-02) - use ensightOutput or member write() methods
203void operator<<(ensightGeoFile&, const ensightPart&) = delete;
204
205
206// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207
208} // End namespace Foam
209
210// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211
212#endif
213
214// ************************************************************************* //
void clear()
Clear the list, i.e. set size to zero.
Definition: ListI.H:116
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
Definition: UListI.H:427
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Specialized Ensight output with extra geometry file header.
Base class for ensightCells, ensightFaces, ensightOutputSurfaces.
Definition: ensightPart.H:54
void rename(const string &value)
Change the part name or description.
Definition: ensightPart.H:166
void incrAddressing(const label off)
Increase addressing by specified offset value.
Definition: ensightPart.C:41
bool empty() const noexcept
Processor-local test for any elements.
Definition: ensightPart.H:148
virtual ~ensightPart()=default
Destructor.
label operator[](const label i) const
Processor-local element id from linear-list of addresses.
Definition: ensightPart.H:189
labelList & addressing() noexcept
Element addressing.
Definition: ensightPart.H:82
label & index() noexcept
The index in a list (0-based)
Definition: ensightPart.H:130
label index() const noexcept
The index in a list (0-based)
Definition: ensightPart.H:124
void rename(string &&value)
Change the part name or description.
Definition: ensightPart.H:172
const string & name() const noexcept
The part name or description.
Definition: ensightPart.H:160
const labelList & addressing() const noexcept
Element addressing.
Definition: ensightPart.H:76
virtual void writeDict(Ostream &os, const bool full=false) const
Definition: ensightPart.H:182
label size() const noexcept
Processor-local size of all elements.
Definition: ensightPart.H:154
ensightPart()
Default construct. Index=0, identifier = -1.
Definition: ensightPart.C:61
void clear()
Clear element addressing.
Definition: ensightPart.H:88
label identifier() const noexcept
OpenFOAM identifier (patch, zone, etc), -1 when not in use.
Definition: ensightPart.H:136
void decrAddressing(const label off)
Decrease addressing by specified offset value.
Definition: ensightPart.C:50
TypeNameNoDebug("ensightPart")
Declare type-name, virtual type (without debug switch)
label & identifier() noexcept
OpenFOAM identifier (patch, zone, etc), -1 when not in use.
Definition: ensightPart.H:142
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
const direction noexcept
Definition: Scalar.H:223
#define TypeNameNoDebug(TypeNameString)
Declare a ClassNameNoDebug() with extra virtual type info.
Definition: typeInfo.H:68