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-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::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 zone_H
42#define 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);
59
60/*---------------------------------------------------------------------------*\
61 Class zone Declaration
62\*---------------------------------------------------------------------------*/
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 Map<label>* lookupMapPtr_;
73
74
75public:
76
77 //- Runtime type information
78 TypeName("zone");
79
80
81 // Constructors
82
83 //- Default construct
84 zone();
85
86 //- Construct an empty zone
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,
110 const word& labelsName,
111 const label index
112 );
113
114 //- Construct given the name of the original zone (name is used)
115 //- and resetting addressing and index.
116 zone
117 (
118 const zone& origZone,
119 const labelUList& addr,
120 const label index
121 );
122
123 //- Construct given the name of the original zone (name is used)
124 //- and (move) resetting addressing and index.
125 zone
126 (
127 const zone& origZone,
128 labelList&& addr,
129 const label index
130 );
131
132
133 //- Destructor
134 virtual ~zone();
135
136
137 // Member Functions
138
139 //- Demand-driven: the look-up map from global to local id
140 const Map<label>& lookupMap() const;
141
142 //- Lookup local address in zone for given global index.
143 // \return the local address, or -1 if the item is not in the zone
144 label localID(const label globalID) const;
145
146
147 //- The addressing used by the zone
148 const labelList& addressing() const noexcept
149 {
150 return static_cast<const labelList&>(*this);
151 }
152
153 //- Clear addressing
154 virtual void clearAddressing();
155
156
157 //- Check zone definition. Return true if in error.
158 virtual bool checkDefinition(const bool report = false) const = 0;
159
160 //- Check zone definition with max size given. Return true if in error.
161 virtual bool checkDefinition
162 (
163 const label maxSize,
164 const bool report = false
165 ) const;
166
167 //- Correct patch after moving points
168 virtual void movePoints(const pointField& pts)
169 {}
170
171 //- Write
172 virtual void write(Ostream& os) const;
173
174 //- Write dictionary
175 virtual void writeDict(Ostream& os) const = 0;
176
177
178 // I-O
179
180 //- Ostream Operator
181 friend Ostream& operator<<(Ostream& os, const zone& zn);
182};
183
184
185// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186
187} // End namespace Foam
188
189// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190
191#endif
192
193// ************************************************************************* //
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling words, derived from Foam::string.
Definition: word.H:68
Identifies a mesh zone by name and index, with optional physical type and group information.
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:67
const Map< label > & lookupMap() const
Demand-driven: the look-up map from global to local id.
Definition: zone.C:133
virtual ~zone()
Destructor.
Definition: zone.C:125
virtual void writeDict(Ostream &os) const =0
Write dictionary.
friend Ostream & operator<<(Ostream &os, const zone &zn)
Ostream Operator.
virtual bool checkDefinition(const bool report=false) const =0
Check zone definition. Return true if in error.
label localID(const label globalID) const
Lookup local address in zone for given global index.
Definition: zone.C:154
virtual void movePoints(const pointField &pts)
Correct patch after moving points.
Definition: zone.H:167
zone()
Default construct.
Definition: zone.C:45
const labelList & addressing() const noexcept
The addressing used by the zone.
Definition: zone.H:147
virtual void clearAddressing()
Clear addressing.
Definition: zone.C:160
TypeName("zone")
Runtime type information.
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
runTime write()
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73