faceZone.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-2026 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::faceZone
26 
27 Description
28  Named list of face indices representing a sub-set of the mesh faces
29 
30  with optional flipMap to provide orientation relative to the orientation
31  of the corresponding mesh faces
32 
33  Used by mesh-manipulation tools, field initialisation and for sources and
34  functionObjects that apply to sub-sets of the faces.
35 
36 See also
37  faceZoneList
38  Zone
39  zoneGenerator
40 
41 SourceFiles
42  faceZone.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef faceZone_H
47 #define faceZone_H
48 
49 #include "Zone.H"
50 #include "boolList.H"
51 #include "primitiveFacePatch.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 class faceZoneList;
59 
60 /*---------------------------------------------------------------------------*\
61  Class faceZone Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class faceZone
65 :
66  public Zone<faceZone, faceZoneList>
67 {
68  // Private Data
69 
70  //- The name associated with the zone-labels dictionary entry
71  static const word labelsName_;
72 
73  //- faceZone is oriented if the flipMap has been set
74  bool oriented_;
75 
76  //- Flip map for all faces in the zone. Set to true if the
77  // face needs to be flipped to achieve the correct orientation.
78  boolList flipMap_;
79 
80 
81  // Demand-driven private data
82 
83  //- Primitive patch made out of correctly flipped faces
84  mutable primitiveFacePatch* patchPtr_;
85 
86  //- Global edge addressing
87  mutable labelList* mePtr_;
88 
89 
90  // Private Member Functions
91 
92  //- Build primitive patch
93  void calcFaceZonePatch() const;
94 
95  //- Check addressing
96  void checkAddressing() const;
97 
98  //- Reset the indices and flipMap from the given map
99  void reset(const Map<bool>& indices);
100 
101  //- Reset the indices from the given set
102  void reset(const labelHashSet& indices);
103 
104 
105 public:
106 
107  // Static Data Members
108 
109  //- The name associated with the zone-labels dictionary entry
110  static const char* const labelsName;
111 
112  //- Runtime type information
113  ClassName("faceZone");
114 
115 
116  // Constructors
117 
118  //- Construct from components
119  faceZone
120  (
121  const word& name,
122  const labelUList& addr,
123  const boolList& fm,
124  const faceZoneList& mz,
125  const bool moveUpdate = false,
126  const bool topoUpdate = false
127  );
128 
129  //- Construct from components without flipMap
130  faceZone
131  (
132  const word& name,
133  const labelUList& addr,
134  const faceZoneList& mz,
135  const bool moveUpdate = false,
136  const bool topoUpdate = false
137  );
138 
139  //- Construct from components, moving contents
140  faceZone
141  (
142  const word& name,
143  labelList&& addr,
144  boolList&& fm,
145  const faceZoneList&,
146  const bool moveUpdate = false,
147  const bool topoUpdate = false
148  );
149 
150  //- Construct from components without flipMap, moving contents
151  faceZone
152  (
153  const word& name,
154  labelList&& addr,
155  const faceZoneList&,
156  const bool moveUpdate = false,
157  const bool topoUpdate = false
158  );
159 
160  //- Construct from dictionary
161  faceZone
162  (
163  const word& name,
164  const dictionary&,
165  const faceZoneList&
166  );
167 
168  //- Construct given the original zone and resetting the
169  // face list and mesh zones information
170  faceZone
171  (
172  const faceZone&,
173  const word& name,
174  const labelUList& addr,
175  const boolList& fm,
176  const faceZoneList&
177  );
178 
179  //- Construct given the original zone and resetting the
180  // face list and mesh zones information without flipMap
181  faceZone
182  (
183  const faceZone&,
184  const word& name,
185  const labelUList& addr,
186  const faceZoneList&
187  );
188 
189  //- Construct given the original zone, resetting the
190  // face list and mesh zones information
191  faceZone
192  (
193  const faceZone&,
194  labelList&& addr,
195  boolList&& fm,
196  const faceZoneList&
197  );
198 
199  //- Construct given the original zone, resetting the
200  // face list and mesh zones information without flipMap
201  faceZone
202  (
203  const faceZone&,
204  labelList&& addr,
205  const faceZoneList&
206  );
207 
208  //- Disallow default bitwise copy construction
209  faceZone(const faceZone&) = delete;
210 
211  //- Construct and return a clone
212  autoPtr<faceZone> clone() const;
213 
214  //- Construct and return a clone with a new name
215  autoPtr<faceZone> clone(const word& name) const;
216 
217  //- Construct and return a clone, resetting the mesh zones
218  autoPtr<faceZone> clone(const faceZoneList& mz) const;
219 
220  //- Construct and return a clone, resetting the face list
221  // and mesh zones
223  (
224  const labelUList& addr,
225  const boolList& fm,
226  const faceZoneList& mz
227  ) const;
228 
229  //- Construct and return a clone, resetting the face list
230  // and mesh zones
232  (
233  const labelUList& addr,
234  const faceZoneList& mz
235  ) const;
236 
237 
238  //- Destructor
239  ~faceZone();
240 
241 
242  // Member Functions
243 
244  //- Return true if the faceZone is oriented, i.e. the flipMap is set
245  bool oriented() const
246  {
247  return oriented_;
248  }
249 
250  //- Return face flip map
251  const boolList& flipMap() const
252  {
253  if (!oriented_)
254  {
256  << "flipMap requested for the unoriented faceZone "
257  << name()
258  << exit(FatalError);
259  }
260 
261  return flipMap_;
262  }
263 
264  //- Return reference to primitive patch
265  const primitiveFacePatch& patch() const;
266 
267  //- Return global edge index for local edges
268  const labelList& meshEdges() const;
269 
270  //- Clear addressing
271  void clearAddressing();
272 
273  //- Reset addressing and flip map (clearing demand-driven data)
274  void resetAddressing(const labelUList&, const boolList&);
275 
276  //- Reset addressing (clearing demand-driven data)
277  void resetAddressing(const labelUList&);
278 
279  //- Check zone definition. Return true if in error.
280  bool checkDefinition(const bool report = false) const;
281 
282  //- Check whether all procs have faces synchronised. Return
283  // true if in error.
284  bool checkParallelSync(const bool report = false) const;
285 
286  //- Insert given indices and corresponding face flips into zone
287  void insert(const Map<bool>& newIndices);
288 
289  //- Insert given indices into zone
290  void insert(const labelHashSet& newIndices);
291 
292  //- Swap two faceZones
293  void swap(faceZone&);
294 
295  //- Correct patch after moving points
296  void movePoints(const pointField&);
297 
298  //- Update zone using the given map
299  void topoChange(const polyTopoChangeMap&);
300 
301  //- Write dictionary
302  void writeDict(Ostream&) const;
303 
304 
305  // Member Operators
306 
307  //- Assignment to zone, clearing demand-driven data
308  void operator=(const faceZone&);
309 
310  //- Move assignment to zone, clearing demand-driven data
311  void operator=(faceZone&&);
312 
313  //- Assignment operator to indices
314  void operator=(const labelUList&);
315 
316  //- Move assignment of indices
317  void operator=(labelList&&);
318 };
319 
320 
321 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
322 
323 } // End namespace Foam
324 
325 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
326 
327 #endif
328 
329 // ************************************************************************* //
A HashTable to objects of type <T> with a label key.
Definition: Map.H:52
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of faces which address into the list of points.
Base class for zones.
Definition: Zone.H:68
bool topoUpdate() const
Flag indicating the zone is updated by the generator.
Definition: Zone.H:194
const word & name() const
Return name.
Definition: Zone.H:171
bool moveUpdate() const
Flag indicating the zone is updated by the generator.
Definition: Zone.H:187
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Named list of face indices representing a sub-set of the mesh faces.
Definition: faceZone.H:66
bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: faceZone.C:482
const boolList & flipMap() const
Return face flip map.
Definition: faceZone.H:250
void swap(faceZone &)
Swap two faceZones.
Definition: faceZone.C:632
void operator=(const faceZone &)
Assignment to zone, clearing demand-driven data.
Definition: faceZone.C:720
faceZone(const word &name, const labelUList &addr, const boolList &fm, const faceZoneList &mz, const bool moveUpdate=false, const bool topoUpdate=false)
Construct from components.
Definition: faceZone.C:161
const primitiveFacePatch & patch() const
Return reference to primitive patch.
Definition: faceZone.C:418
bool oriented() const
Return true if the faceZone is oriented, i.e. the flipMap is set.
Definition: faceZone.H:244
autoPtr< faceZone > clone() const
Construct and return a clone.
Definition: faceZone.C:323
void topoChange(const polyTopoChangeMap &)
Update zone using the given map.
Definition: faceZone.C:640
void resetAddressing(const labelUList &, const boolList &)
Reset addressing and flip map (clearing demand-driven data)
Definition: faceZone.C:458
ClassName("faceZone")
Runtime type information.
static const char *const labelsName
The name associated with the zone-labels dictionary entry.
Definition: faceZone.H:109
void writeDict(Ostream &) const
Write dictionary.
Definition: faceZone.C:706
void insert(const Map< bool > &newIndices)
Insert given indices and corresponding face flips into zone.
Definition: faceZone.C:600
void clearAddressing()
Clear addressing.
Definition: faceZone.C:448
~faceZone()
Destructor.
Definition: faceZone.C:410
void movePoints(const pointField &)
Correct patch after moving points.
Definition: faceZone.C:697
bool checkParallelSync(const bool report=false) const
Check whether all procs have faces synchronised. Return.
Definition: faceZone.C:492
const labelList & meshEdges() const
Return global edge index for local edges.
Definition: faceZone.C:429
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for handling words, derived from string.
Definition: word.H:63
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError