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-2025 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 "className.H"
39 #include "labelList.H"
40 #include "dictionary.H"
41 #include "HashSet.H"
42 #include "Map.H"
43 #include "pointFieldFwd.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of friend functions and operators
51 
52 class polyTopoChangeMap;
53 class polyMeshMap;
54 class polyDistributionMap;
55 
56 template<class ZoneType, class ZonesType> class Zone;
57 
58 template<class ZoneType, class ZonesType>
60 
61 /*---------------------------------------------------------------------------*\
62  Class Zone Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 template<class ZoneType, class ZonesType>
66 class Zone
67 :
68  public labelList
69 {
70 
71 protected:
72 
73  // Protected data
74 
75  //- Name of zone
76  word name_;
77 
78  //- Reference to zone list
79  const ZonesType& zones_;
80 
81  //- Flag indicating the zone is updated by the generator
82  // following mesh motion
83  bool moveUpdate_;
84 
85  //- Flag indicating the zone is updated by the generator
86  // following topology change
87  bool topoUpdate_;
88 
89 
90  // Demand-driven private data
91 
92  //- Map of labels in zone for fast location lookup
93  mutable Map<label>* lookupMapPtr_;
94 
95 
96  // Protected Member Functions
97 
98  //- Select the
99  template<class Type>
100  void select(const Type& zone);
101 
102  //- Construct the look-up map
103  void calcLookupMap() const;
104 
105  //- Update the addressing using the maps provided
106  void topoChange(const labelList& map, const labelList& reverseMap);
107 
108 
109 public:
110 
111  // Constructors
112 
113  //- Construct from components
114  Zone
115  (
116  const word& name,
117  const labelUList& indices,
118  const ZonesType& zones,
119  const bool moveUpdate = false,
120  const bool topoUpdate = false
121  );
122 
123  //- Construct from components, moving contents
124  Zone
125  (
126  const word& name,
127  labelList&& indices,
128  const ZonesType& zones,
129  const bool moveUpdate = false,
130  const bool topoUpdate = false
131  );
132 
133  //- Construct from dictionary
134  Zone
135  (
136  const word& name,
137  const dictionary&,
138  const ZonesType& zones
139  );
140 
141  //- Construct given the original zone and resetting the
142  // cell list and mesh zones information
143  Zone
144  (
145  const Zone&,
146  const word& name,
147  const labelUList& indices,
148  const ZonesType& zones
149  );
150 
151  //- Construct given the original zone, resetting the
152  // cell list and mesh zones information
153  Zone
154  (
155  const Zone&,
156  const word& name,
157  labelList&& indices,
158  const ZonesType& zones
159  );
160 
161  //- Disallow default bitwise copy construction
162  Zone(const Zone&) = delete;
163 
164 
165  //- Destructor
166  ~Zone();
167 
168 
169  // Member Functions
170 
171  //- Return name
172  const word& name() const
173  {
174  return name_;
175  }
176 
177  //- Return name as the keyword
178  const word& keyword() const
179  {
180  return name_;
181  }
182 
183  //- Return ZonesType reference
184  const ZonesType& zones() const;
185 
186  //- Flag indicating the zone is updated by the generator
187  // following mesh motion
188  bool moveUpdate() const
189  {
190  return moveUpdate_;
191  }
192 
193  //- Flag indicating the zone is updated by the generator
194  // following mesh topology change
195  bool topoUpdate() const
196  {
197  return topoUpdate_;
198  }
199 
200  //- Map storing the local index for every global index. Used to find
201  // the index of the item in the zone from the known global index. If
202  // the item is not in the zone, returns -1
203  label localIndex(const label globalIndex) const;
204 
205  //- Return a reference to the look-up map
206  const Map<label>& lookupMap() const;
207 
208  //- Clear addressing
209  void clearAddressing();
210 
211  //- Check zone definition with max size given. Return true if in error.
212  bool checkDefinition
213  (
214  const label maxSize,
215  const bool report = false
216  ) const;
217 
218  //- Insert given indices into zone
219  void insert(const labelHashSet& newIndices);
220 
221  //- Swap two zones
222  void swap(Zone&);
223 
224  //- Correct patch after moving points
225  void movePoints(const pointField&)
226  {}
227 
228  //- Update from another mesh using the given map
229  void mapMesh(const polyMeshMap&);
230 
231  //- Redistribute or update using the given distribution map
232  void distribute(const polyDistributionMap&);
233 
234 
235  // Member Operators
236 
237  //- Assignment operator
238  void operator=(const Zone&);
239 
240  //- Move assignment operator
241  void operator=(Zone&&);
242 
243  //- Assignment operator to indices
244  void operator=(const labelUList&);
245 
246  //- Move assignment of indices
247  void operator=(labelList&&);
248 
249 
250  // I-O
251 
252  //- Ostream Operator
253  friend Ostream& operator<< <ZoneType, ZonesType>
254  (
255  Ostream&,
257  );
258 };
259 
260 
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 } // End namespace Foam
264 
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 
267 #ifdef NoRepository
268  #include "Zone.C"
269 #endif
270 
271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 
273 #endif
274 
275 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Base class for zones.
Definition: Zone.H:68
const Map< label > & lookupMap() const
Return a reference to the look-up map.
Definition: Zone.C:241
void swap(Zone &)
Swap two zones.
Definition: Zone.C:319
void topoChange(const labelList &map, const labelList &reverseMap)
Update the addressing using the maps provided.
Definition: Zone.C:79
bool checkDefinition(const label maxSize, const bool report=false) const
Check zone definition with max size given. Return true if in error.
Definition: Zone.C:261
word name_
Name of zone.
Definition: Zone.H:75
void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: Zone.C:334
label localIndex(const label globalIndex) const
Map storing the local index for every global index. Used to find.
Definition: Zone.C:221
const word & keyword() const
Return name as the keyword.
Definition: Zone.H:177
void calcLookupMap() const
Construct the look-up map.
Definition: Zone.C:56
Map< label > * lookupMapPtr_
Map of labels in zone for fast location lookup.
Definition: Zone.H:92
void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: Zone.C:327
bool topoUpdate_
Flag indicating the zone is updated by the generator.
Definition: Zone.H:86
~Zone()
Destructor.
Definition: Zone.C:204
bool topoUpdate() const
Flag indicating the zone is updated by the generator.
Definition: Zone.H:194
void insert(const labelHashSet &newIndices)
Insert given indices into zone.
Definition: Zone.C:309
void clearAddressing()
Clear addressing.
Definition: Zone.C:253
Zone(const word &name, const labelUList &indices, const ZonesType &zones, const bool moveUpdate=false, const bool topoUpdate=false)
Construct from components.
Definition: Zone.C:112
void movePoints(const pointField &)
Correct patch after moving points.
Definition: Zone.H:224
void select(const Type &zone)
Select the.
Definition: Zone.C:35
const word & name() const
Return name.
Definition: Zone.H:171
bool moveUpdate_
Flag indicating the zone is updated by the generator.
Definition: Zone.H:82
void operator=(const Zone &)
Assignment operator.
Definition: Zone.C:343
bool moveUpdate() const
Flag indicating the zone is updated by the generator.
Definition: Zone.H:187
const ZonesType & zones_
Reference to zone list.
Definition: Zone.H:78
const ZonesType & zones() const
Return ZonesType reference.
Definition: Zone.C:213
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:64
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
A class for handling words, derived from string.
Definition: word.H:62
Macro definitions for declaring ClassName(), NamespaceName(), etc.
Namespace for OpenFOAM.
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
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)