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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::ensightPart
29 
30 Description
31  Base class for ensightCells, ensightFaces, ensightOutputSurfaces.
32 
33 SourceFiles
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 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class ensightPart Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 class 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 
74 protected:
75 
76  //- Element addressing
77  const labelList& addressing() const noexcept
78  {
79  return address_;
80  }
81 
82  //- Element addressing
83  labelList& addressing() noexcept
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 
103 public:
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
203 void operator<<(ensightGeoFile&, const ensightPart&) = delete;
204 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 } // End namespace Foam
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 #endif
213 
214 // ************************************************************************* //
Foam::ensightPart::addressing
const labelList & addressing() const noexcept
Element addressing.
Definition: ensightPart.H:76
Foam::ensightPart::decrAddressing
void decrAddressing(const label off)
Decrease addressing by specified offset value.
Definition: ensightPart.C:50
Foam::ensightPart::rename
void rename(const string &value)
Change the part name or description.
Definition: ensightPart.H:166
Foam::ensightPart::index
label index() const noexcept
The index in a list (0-based)
Definition: ensightPart.H:124
typeInfo.H
Foam::ensightPart::TypeNameNoDebug
TypeNameNoDebug("ensightPart")
Declare type-name, virtual type (without debug switch)
Foam::ensightPart::rename
void rename(string &&value)
Change the part name or description.
Definition: ensightPart.H:172
Foam::ensightPart::writeDict
virtual void writeDict(Ostream &os, const bool full=false) const
Definition: ensightPart.H:182
Foam::ensightPart::incrAddressing
void incrAddressing(const label off)
Increase addressing by specified offset value.
Definition: ensightPart.C:41
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::ensightPart::empty
bool empty() const noexcept
Processor-local test for any elements.
Definition: ensightPart.H:148
Foam::ensightPart::addressing
labelList & addressing() noexcept
Element addressing.
Definition: ensightPart.H:82
Foam::ensightPart::identifier
label & identifier() noexcept
OpenFOAM identifier (patch, zone, etc), -1 when not in use.
Definition: ensightPart.H:142
labelList.H
Foam::ensightPart::operator[]
label operator[](const label i) const
Processor-local element id from linear-list of addresses.
Definition: ensightPart.H:189
os
OBJstream os(runTime.globalPath()/outputName)
Foam::ensightPart::name
const string & name() const noexcept
The part name or description.
Definition: ensightPart.H:160
Foam::ensightPart::size
label size() const noexcept
Processor-local size of all elements.
Definition: ensightPart.H:154
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::ensightPart::index
label & index() noexcept
The index in a list (0-based)
Definition: ensightPart.H:130
Foam::ensightPart::~ensightPart
virtual ~ensightPart()=default
Destructor.
ensightGeoFile.H
Foam::List< label >
Foam::ensightPart
Base class for ensightCells, ensightFaces, ensightOutputSurfaces.
Definition: ensightPart.H:53
Foam::List::clear
void clear()
Clear the list, i.e. set size to zero.
Definition: ListI.H:116
Foam::ensightPart::ensightPart
ensightPart()
Default construct. Index=0, identifier = -1.
Definition: ensightPart.C:61
Foam::ensightPart::identifier
label identifier() const noexcept
OpenFOAM identifier (patch, zone, etc), -1 when not in use.
Definition: ensightPart.H:136
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::ensightPart::clear
void clear()
Clear element addressing.
Definition: ensightPart.H:88