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 -------------------------------------------------------------------------------
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::zone
29 
30 Description
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 
36 SourceFiles
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 
52 namespace Foam
53 {
54 
55 // Forward Declarations
56 class zone;
57 class dictionary;
58 Ostream& operator<<(Ostream& os, const zone& zn);
59 
60 /*---------------------------------------------------------------------------*\
61  Class zone Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class 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 
75 public:
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 // ************************************************************************* //
Foam::zone::writeDict
virtual void writeDict(Ostream &os) const =0
Write dictionary.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
typeInfo.H
Foam::zone::TypeName
TypeName("zone")
Runtime type information.
zoneIdentifier.H
Foam::zone
Base class for mesh zones.
Definition: zone.H:63
Foam::Map< label >
Foam::zone::clearAddressing
virtual void clearAddressing()
Clear addressing.
Definition: zone.C:158
Foam::zone::operator<<
friend Ostream & operator<<(Ostream &os, const zone &zn)
Ostream Operator.
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Map.H
Foam::zone::write
virtual void write(Ostream &os) const
Write.
Definition: zone.C:208
Foam::zone::lookupMap
const Map< label > & lookupMap() const
Demand-driven: the look-up map from global to local id.
Definition: zone.C:131
labelList.H
Foam::Field< vector >
pointFieldFwd.H
Foam::zone::~zone
virtual ~zone()
Destructor.
Definition: zone.C:123
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::zone::movePoints
virtual void movePoints(const pointField &pts)
Correct patch after moving points.
Definition: zone.H:167
Foam::zoneIdentifier::index
label index() const noexcept
The index of this zone in the zone list.
Definition: zoneIdentifier.H:135
Foam::zoneIdentifier::name
const word & name() const noexcept
The zone name.
Definition: zoneIdentifier.H:123
Foam::List< label >
Foam::UList< label >
Foam::zone::localID
label localID(const label globalID) const
Lookup local address in zone for given global index.
Definition: zone.C:152
Foam::zoneIdentifier
Identifies a mesh zone by name and index, with optional physical type and group information.
Definition: zoneIdentifier.H:57
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::zone::zone
zone()
Default construct.
Definition: zone.C:45
Foam::zone::addressing
const labelList & addressing() const noexcept
The addressing used by the zone.
Definition: zone.H:147
Foam::zone::checkDefinition
virtual bool checkDefinition(const bool report=false) const =0
Check zone definition. Return true if in error.