Loading...
Searching...
No Matches
zone.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) 2017-2025 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::zone
29
30Description
31 Base class for mesh zones.
32
33 A zone is a list of labels (eg, cells, faces, points) with
34 a name and associated with an index within another list.
35
36SourceFiles
37 zone.C
38
39\*---------------------------------------------------------------------------*/
40
41#ifndef Foam_zone_H
42#define Foam_zone_H
43
44#include "zoneIdentifier.H"
45#include "labelList.H"
46#include "typeInfo.H"
47#include "Map.H"
48#include "pointFieldFwd.H"
49
50// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51
52namespace Foam
53{
54
55// Forward Declarations
56class zone;
57class dictionary;
58Ostream& operator<<(Ostream& os, const zone& zn);
60/*---------------------------------------------------------------------------*\
61 Class zone Declaration
62\*---------------------------------------------------------------------------*/
63
64class zone
65:
66 public zoneIdentifier,
67 public labelList
68{
69 // Private Data
70
71 //- Demand-driven: map of labels in zone for fast location lookup
72 mutable std::unique_ptr<Map<label>> lookupMapPtr_;
73
74
75public:
76
77 //- Runtime type information
78 TypeNameNoDebug("zone");
79
80
81 // Constructors
82
83 //- Default construct: empty zone with name="", index=0
84 zone();
85
86 //- Construct an empty zone with specified name and index
87 zone(const word& name, const label index);
88
89 //- Copy construct from components
90 zone
91 (
92 const word& name,
93 const labelUList& addr,
94 const label index
95 );
96
97 //- Move construct from components
98 zone
99 (
100 const word& name,
101 labelList&& addr,
102 const label index
103 );
104
105 //- Construct from dictionary
106 zone
107 (
108 const word& name,
109 const dictionary& dict,
111 const word& labelsName,
112 const label index
113 );
114
115 //- Copy construct with new index
116 zone
117 (
118 const zone& originalZone,
120 const label index
121 );
122
123 //- Construct given the name of the original zone (name is used)
124 //- with new addressing and index
125 zone
126 (
127 const zone& originalZone,
128 const labelUList& addr,
130 const label index
131 );
132
133 //- Construct given the name of the original zone (name is used)
134 //- and (move) resetting addressing and index
135 zone
136 (
137 const zone& originalZone,
138 labelList&& addr,
140 const label index
141 );
142
143
144 //- Destructor
145 virtual ~zone() = default;
146
147
148 // Member Functions
149
150 //- Demand-driven: the look-up map from global to local id
151 const Map<label>& lookupMap() const;
152
153 //- Lookup local address in zone for given global index.
154 // \return the local address, or -1 if the item is not in the zone
155 label localID(const label globalID) const;
156
157 //- The addressing used by the zone
158 const labelList& addressing() const noexcept
159 {
160 return static_cast<const labelList&>(*this);
161 }
163 //- Clear addressing
164 //- (remove lookup maps and other auxiliary information)
165 virtual void clearAddressing();
166
167 //- Clear primitive addressing
168 virtual void clearPrimitives();
169
170 //- Check zone definition. Return true if in error.
171 virtual bool checkDefinition(const bool report = false) const = 0;
172
173 //- Check zone definition with max size given. Return true if in error.
174 virtual bool checkDefinition
175 (
176 const label maxSize,
177 const bool report = false
178 ) const;
179
180
181 // Mesh Changes
183 //- Corrections after moving points
184 virtual void movePoints(const pointField&)
185 {}
186
187
188 // I-O
189
190 //- Write (dictionary entries)
191 virtual void write(Ostream& os) const;
192
193 //- Ostream Operator
194 friend Ostream& operator<<(Ostream& os, const zone& zn);
195};
196
197
198// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199
200} // End namespace Foam
202// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203
204#endif
205
206// ************************************************************************* //
A HashTable to objects of type <T> with a label key.
Definition Map.H:54
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for handling words, derived from Foam::string.
Definition word.H:66
zoneIdentifier(const zoneIdentifier &)=default
Copy construct.
label index() const noexcept
The index of this zone in the zone list.
const word & name() const noexcept
The zone name.
Base class for mesh zones.
Definition zone.H:63
const Map< label > & lookupMap() const
Demand-driven: the look-up map from global to local id.
Definition zone.C:129
friend Ostream & operator<<(Ostream &os, const zone &zn)
Ostream Operator.
virtual void movePoints(const pointField &)
Corrections after moving points.
Definition zone.H:218
virtual bool checkDefinition(const bool report=false) const =0
Check zone definition. Return true if in error.
TypeNameNoDebug("zone")
Runtime type information.
virtual void clearPrimitives()
Clear primitive addressing.
Definition zone.C:168
virtual ~zone()=default
Destructor.
label localID(const label globalID) const
Lookup local address in zone for given global index.
Definition zone.C:149
zone()
Default construct: empty zone with name="", index=0.
Definition zone.C:37
const labelList & addressing() const noexcept
The addressing used by the zone.
Definition zone.H:182
virtual void clearAddressing()
Clear addressing (remove lookup maps and other auxiliary information).
Definition zone.C:162
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
const direction noexcept
Definition scalarImpl.H:265
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
Definition UList.H:75
runTime write()
dictionary dict
Basic run-time type information using word as the type's name. Used to enhance the standard RTTI to c...
#define TypeNameNoDebug(TypeNameString)
Declare a ClassNameNoDebug() with extra virtual type info.
Definition typeInfo.H:61