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 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 "labelList.H"
45 #include "typeInfo.H"
46 #include "dictionary.H"
47 #include "Map.H"
48 #include "pointFieldFwd.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward declaration of friend functions and operators
56 
57 class zone;
58 Ostream& operator<<(Ostream& os, const zone& zn);
59 
60 /*---------------------------------------------------------------------------*\
61  Class zone Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class zone
65 :
66  public labelList
67 {
68  // Private Member Functions
69 
70  //- No copy construct
71  zone(const zone&) = delete;
72 
73 
74 protected:
75 
76  // Protected data
77 
78  //- Name of zone
79  word name_;
80 
81  //- Index of zone
82  label index_;
83 
84 
85  // Demand-driven private data
86 
87  //- Map of labels in zone for fast location lookup
88  mutable Map<label>* lookupMapPtr_;
89 
90 
91  // Protected Member Functions
92 
93  //- Construct the look-up map
94  void calcLookupMap() const;
95 
96 
97 public:
98 
99  //- Runtime type information
100  TypeName("zone");
101 
102 
103  // Constructors
104 
105  //- Construct an empty zone
106  zone(const word& name, const label index);
107 
108  //- Copy construct from components
109  zone
110  (
111  const word& name,
112  const labelUList& addr,
113  const label index
114  );
115 
116  //- Move construct from components
117  zone
118  (
119  const word& name,
120  labelList&& addr,
121  const label index
122  );
123 
124  //- Construct from dictionary
125  zone
126  (
127  const word& name,
128  const dictionary& dict,
129  const word& labelsName,
130  const label index
131  );
132 
133  //- Construct given the name of the original zone (name is used)
134  //- and resetting addressing and index.
135  zone
136  (
137  const zone& origZone,
138  const labelUList& addr,
139  const label index
140  );
141 
142  //- Construct given the name of the original zone (name is used)
143  //- and (move) resetting addressing and index.
144  zone
145  (
146  const zone& origZone,
147  labelList&& addr,
148  const label index
149  );
150 
151 
152  //- Destructor
153  virtual ~zone();
154 
155 
156  // Member Functions
157 
158  //- Return name
159  const word& name() const
160  {
161  return name_;
162  }
163 
164  //- Map storing the local index for every global index. Used to find
165  // the index of the item in the zone from the known global index. If
166  // the item is not in the zone, returns -1
167  label localID(const label globalID) const;
168 
169  //- Return the index of this zone in zone list
170  label index() const
171  {
172  return index_;
173  }
174 
175  //- Return a reference to the look-up map
176  const Map<label>& lookupMap() const;
177 
178  //- Clear addressing
179  virtual void clearAddressing();
180 
181  //- Check zone definition. Return true if in error.
182  virtual bool checkDefinition(const bool report = false) const = 0;
183 
184  //- Check zone definition with max size given. Return true if in error.
185  virtual bool checkDefinition
186  (
187  const label maxSize,
188  const bool report = false
189  ) const;
190 
191  //- Correct patch after moving points
192  virtual void movePoints(const pointField& pts)
193  {}
194 
195  //- Write
196  virtual void write(Ostream& os) const;
197 
198  //- Write dictionary
199  virtual void writeDict(Ostream& os) const = 0;
200 
201 
202  // I-O
203 
204  //- Ostream Operator
205  friend Ostream& operator<<(Ostream& os, const zone& zn);
206 };
207 
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 } // End namespace Foam
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 #endif
216 
217 // ************************************************************************* //
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:62
typeInfo.H
Foam::zone::calcLookupMap
void calcLookupMap() const
Construct the look-up map.
Definition: zone.C:55
Foam::zone::TypeName
TypeName("zone")
Runtime type information.
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:178
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:228
Foam::zone::lookupMap
const Map< label > & lookupMap() const
Return a reference to the look-up map.
Definition: zone.C:44
labelList.H
Foam::Field< vector >
pointFieldFwd.H
Foam::zone::~zone
virtual ~zone()
Destructor.
Definition: zone.C:164
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:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::zone::name
const word & name() const
Return name.
Definition: zone.H:158
Foam::zone::movePoints
virtual void movePoints(const pointField &pts)
Correct patch after moving points.
Definition: zone.H:191
Foam::zone::lookupMapPtr_
Map< label > * lookupMapPtr_
Map of labels in zone for fast location lookup.
Definition: zone.H:87
Foam::List< label >
Foam::zone::name_
word name_
Name of zone.
Definition: zone.H:78
Foam::UList< label >
dictionary.H
Foam::zone::localID
label localID(const label globalID) const
Map storing the local index for every global index. Used to find.
Definition: zone.C:172
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::zone::index
label index() const
Return the index of this zone in zone list.
Definition: zone.H:169
Foam::zone::index_
label index_
Index of zone.
Definition: zone.H:81
Foam::zone::checkDefinition
virtual bool checkDefinition(const bool report=false) const =0
Check zone definition. Return true if in error.