zone.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::zone
26 
27 Description
28  Base class for zones
29 
30 SourceFiles
31  zone.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef zone_H
36 #define zone_H
37 
38 #include "labelList.H"
39 #include "typeInfo.H"
40 #include "dictionary.H"
41 #include "Map.H"
42 #include "pointFieldFwd.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward declaration of friend functions and operators
50 
51 class zone;
52 Ostream& operator<<(Ostream&, const zone&);
53 
54 /*---------------------------------------------------------------------------*\
55  Class zone Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class zone
59 :
60  public labelList
61 {
62 
63 protected:
64 
65  // Protected data
66 
67  //- Name of zone
68  word name_;
69 
70  //- Index of zone
71  label index_;
72 
73 
74  // Demand-driven private data
75 
76  //- Map of labels in zone for fast location lookup
77  mutable Map<label>* lookupMapPtr_;
78 
79 
80  // Protected Member Functions
81 
82  //- Construct the look-up map
83  void calcLookupMap() const;
84 
85 
86 public:
87 
88  //- Runtime type information
89  TypeName("zone");
90 
91 
92  // Constructors
93 
94  //- Construct from components
95  zone
96  (
97  const word& name,
98  const labelUList& addr,
99  const label index
100  );
101 
102  //- Construct from components, moving contents
103  zone
104  (
105  const word& name,
106  labelList&& addr,
107  const label index
108  );
109 
110  //- Construct from dictionary
111  zone
112  (
113  const word& name,
114  const dictionary&,
115  const word& labelsName,
116  const label index
117  );
118 
119  //- Construct given the original zone and resetting the
120  // cell list and zone mesh information
121  zone
122  (
123  const zone&,
124  const labelUList& addr,
125  const label index
126  );
127 
128  //- Construct given the original zone, resetting the
129  // cell list and zone mesh information
130  zone
131  (
132  const zone&,
133  labelList&& addr,
134  const label index
135  );
136 
137  //- Disallow default bitwise copy construction
138  zone(const zone&) = delete;
139 
140 
141  //- Destructor
142  virtual ~zone();
143 
144 
145  // Member Functions
146 
147  //- Return name
148  const word& name() const
149  {
150  return name_;
151  }
152 
153  //- Map storing the local index for every global index. Used to find
154  // the index of the item in the zone from the known global index. If
155  // the item is not in the zone, returns -1
156  label localID(const label globalID) const;
157 
158  //- Return the index of this zone in zone list
159  label index() const
160  {
161  return index_;
162  }
163 
164  //- Return a reference to the look-up map
165  const Map<label>& lookupMap() const;
166 
167  //- Clear addressing
168  virtual void clearAddressing();
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  //- Correct patch after moving points
181  virtual void movePoints(const pointField&)
182  {}
183 
184  //- Write
185  virtual void write(Ostream&) const;
186 
187  //- Write dictionary
188  virtual void writeDict(Ostream&) const = 0;
189 
190 
191  // Member Operators
192 
193  //- Assignment operator
194  void operator=(const zone&);
195 
196  //- Move assignment operator
197  void operator=(zone&&);
198 
199  //- Assignment operator to addressing
200  void operator=(const labelUList&);
201 
202  //- Move assignment of addressing
203  void operator=(labelList&&);
204 
205 
206  // I-O
207 
208  //- Ostream Operator
209  friend Ostream& operator<<(Ostream&, const zone&);
210 };
211 
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 } // End namespace Foam
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 #endif
220 
221 // ************************************************************************* //
virtual void clearAddressing()
Clear addressing.
Definition: zone.C:183
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
label localID(const label globalID) const
Map storing the local index for every global index. Used to find.
Definition: zone.C:166
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
zone(const word &name, const labelUList &addr, const label index)
Construct from components.
Definition: zone.C:86
TypeName("zone")
Runtime type information.
label index() const
Return the index of this zone in zone list.
Definition: zone.H:158
void calcLookupMap() const
Construct the look-up map.
Definition: zone.C:52
virtual ~zone()
Destructor.
Definition: zone.C:158
Base class for zones.
Definition: zone.H:57
A class for handling words, derived from string.
Definition: word.H:59
word name_
Name of zone.
Definition: zone.H:67
label index_
Index of zone.
Definition: zone.H:70
virtual bool checkDefinition(const bool report=false) const =0
Check zone definition. Return true if in error.
const word & name() const
Return name.
Definition: zone.H:147
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
virtual void movePoints(const pointField &)
Correct patch after moving points.
Definition: zone.H:180
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
friend Ostream & operator<<(Ostream &, const zone &)
Ostream Operator.
const Map< label > & lookupMap() const
Return a reference to the look-up map.
Definition: zone.C:41
Ostream & operator<<(Ostream &, const ensightPart &)
virtual void write(Ostream &) const
Write.
Definition: zone.C:233
virtual void writeDict(Ostream &) const =0
Write dictionary.
void operator=(const zone &)
Assignment operator.
Definition: zone.C:242
Namespace for OpenFOAM.
Map< label > * lookupMapPtr_
Map of labels in zone for fast location lookup.
Definition: zone.H:76