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-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::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  //- Master cell layer
87  mutable labelList* masterCellsPtr_;
88 
89  //- Slave cell layer
90  mutable labelList* slaveCellsPtr_;
91 
92  //- Global edge addressing
93  mutable labelList* mePtr_;
94 
95 
96  // Private Member Functions
97 
98  //- Build primitive patch
99  void calcFaceZonePatch() const;
100 
101  //- Return map of local face indices
102  const Map<label>& faceLookupMap() const;
103 
104  //- Calculate master and slave face layer
105  void calcCellLayers() const;
106 
107  //- Check addressing
108  void checkAddressing() const;
109 
110  //- Reset the indices and flipMap from the given map
111  void reset(const Map<bool>& indices);
112 
113  //- Reset the indices from the given set
114  void reset(const labelHashSet& indices);
115 
116 
117 public:
118 
119  // Static Data Members
120 
121  //- The name associated with the zone-labels dictionary entry
122  static const char* const labelsName;
123 
124  //- Runtime type information
125  ClassName("faceZone");
126 
127 
128  // Constructors
129 
130  //- Construct from components
131  faceZone
132  (
133  const word& name,
134  const labelUList& addr,
135  const boolList& fm,
136  const faceZoneList& mz,
137  const bool moveUpdate = false,
138  const bool topoUpdate = false
139  );
140 
141  //- Construct from components without flipMap
142  faceZone
143  (
144  const word& name,
145  const labelUList& addr,
146  const faceZoneList& mz,
147  const bool moveUpdate = false,
148  const bool topoUpdate = false
149  );
150 
151  //- Construct from components, moving contents
152  faceZone
153  (
154  const word& name,
155  labelList&& addr,
156  boolList&& fm,
157  const faceZoneList&,
158  const bool moveUpdate = false,
159  const bool topoUpdate = false
160  );
161 
162  //- Construct from components without flipMap, moving contents
163  faceZone
164  (
165  const word& name,
166  labelList&& addr,
167  const faceZoneList&,
168  const bool moveUpdate = false,
169  const bool topoUpdate = false
170  );
171 
172  //- Construct from dictionary
173  faceZone
174  (
175  const word& name,
176  const dictionary&,
177  const faceZoneList&
178  );
179 
180  //- Construct given the original zone and resetting the
181  // face list and mesh zones information
182  faceZone
183  (
184  const faceZone&,
185  const word& name,
186  const labelUList& addr,
187  const boolList& fm,
188  const faceZoneList&
189  );
190 
191  //- Construct given the original zone and resetting the
192  // face list and mesh zones information without flipMap
193  faceZone
194  (
195  const faceZone&,
196  const word& name,
197  const labelUList& addr,
198  const faceZoneList&
199  );
200 
201  //- Construct given the original zone, resetting the
202  // face list and mesh zones information
203  faceZone
204  (
205  const faceZone&,
206  labelList&& addr,
207  boolList&& fm,
208  const faceZoneList&
209  );
210 
211  //- Construct given the original zone, resetting the
212  // face list and mesh zones information without flipMap
213  faceZone
214  (
215  const faceZone&,
216  labelList&& addr,
217  const faceZoneList&
218  );
219 
220  //- Disallow default bitwise copy construction
221  faceZone(const faceZone&) = delete;
222 
223  //- Construct and return a clone
224  autoPtr<faceZone> clone() const;
225 
226  //- Construct and return a clone with a new name
227  autoPtr<faceZone> clone(const word& name) const;
228 
229  //- Construct and return a clone, resetting the mesh zones
230  autoPtr<faceZone> clone(const faceZoneList& mz) const;
231 
232  //- Construct and return a clone, resetting the face list
233  // and mesh zones
235  (
236  const labelUList& addr,
237  const boolList& fm,
238  const faceZoneList& mz
239  ) const;
240 
241  //- Construct and return a clone, resetting the face list
242  // and mesh zones
244  (
245  const labelUList& addr,
246  const faceZoneList& mz
247  ) const;
248 
249 
250  //- Destructor
251  ~faceZone();
252 
253 
254  // Member Functions
255 
256  //- Return true if the faceZone is oriented, i.e. the flipMap is set
257  bool oriented() const
258  {
259  return oriented_;
260  }
261 
262  //- Return face flip map
263  const boolList& flipMap() const
264  {
265  if (!oriented_)
266  {
268  << "flipMap requested for the unoriented faceZone "
269  << name()
270  << exit(FatalError);
271  }
272 
273  return flipMap_;
274  }
275 
276  //- Return reference to primitive patch
277  const primitiveFacePatch& patch() const;
278 
279 
280  // Addressing into mesh
281 
282  //- Return labels of master cells (cells next to the master face
283  // zone in the prescribed direction)
284  const labelList& masterCells() const;
285 
286  //- Return labels of slave cells
287  const labelList& slaveCells() const;
288 
289  //- Return global edge index for local edges
290  const labelList& meshEdges() const;
291 
292 
293  //- Clear addressing
294  void clearAddressing();
295 
296  //- Reset addressing and flip map (clearing demand-driven data)
297  void resetAddressing(const labelUList&, const boolList&);
298 
299  //- Reset addressing (clearing demand-driven data)
300  void resetAddressing(const labelUList&);
301 
302  //- Check zone definition. Return true if in error.
303  bool checkDefinition(const bool report = false) const;
304 
305  //- Check whether all procs have faces synchronised. Return
306  // true if in error.
307  bool checkParallelSync(const bool report = false) const;
308 
309  //- Insert given indices and corresponding face flips into zone
310  void insert(const Map<bool>& newIndices);
311 
312  //- Insert given indices into zone
313  void insert(const labelHashSet& newIndices);
314 
315  //- Swap two faceZones
316  void swap(faceZone&);
317 
318  //- Correct patch after moving points
319  void movePoints(const pointField&);
320 
321  //- Update zone using the given map
322  void topoChange(const polyTopoChangeMap&);
323 
324  //- Write dictionary
325  void writeDict(Ostream&) const;
326 
327 
328  // Member Operators
329 
330  //- Assignment to zone, clearing demand-driven data
331  void operator=(const faceZone&);
332 
333  //- Move assignment to zone, clearing demand-driven data
334  void operator=(faceZone&&);
335 
336  //- Assignment operator to indices
337  void operator=(const labelUList&);
338 
339  //- Move assignment of indices
340  void operator=(labelList&&);
341 };
342 
343 
344 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
345 
346 } // End namespace Foam
347 
348 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349 
350 #endif
351 
352 // ************************************************************************* //
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:583
const boolList & flipMap() const
Return face flip map.
Definition: faceZone.H:262
void swap(faceZone &)
Swap two faceZones.
Definition: faceZone.C:733
void operator=(const faceZone &)
Assignment to zone, clearing demand-driven data.
Definition: faceZone.C:818
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:218
const primitiveFacePatch & patch() const
Return reference to primitive patch.
Definition: faceZone.C:493
bool oriented() const
Return true if the faceZone is oriented, i.e. the flipMap is set.
Definition: faceZone.H:256
autoPtr< faceZone > clone() const
Construct and return a clone.
Definition: faceZone.C:398
const labelList & masterCells() const
Return labels of master cells (cells next to the master face.
Definition: faceZone.C:504
void topoChange(const polyTopoChangeMap &)
Update zone using the given map.
Definition: faceZone.C:741
void resetAddressing(const labelUList &, const boolList &)
Reset addressing and flip map (clearing demand-driven data)
Definition: faceZone.C:559
ClassName("faceZone")
Runtime type information.
static const char *const labelsName
The name associated with the zone-labels dictionary entry.
Definition: faceZone.H:121
void writeDict(Ostream &) const
Write dictionary.
Definition: faceZone.C:804
void insert(const Map< bool > &newIndices)
Insert given indices and corresponding face flips into zone.
Definition: faceZone.C:701
void clearAddressing()
Clear addressing.
Definition: faceZone.C:545
~faceZone()
Destructor.
Definition: faceZone.C:485
void movePoints(const pointField &)
Correct patch after moving points.
Definition: faceZone.C:795
bool checkParallelSync(const bool report=false) const
Check whether all procs have faces synchronised. Return.
Definition: faceZone.C:593
const labelList & slaveCells() const
Return labels of slave cells.
Definition: faceZone.C:515
const labelList & meshEdges() const
Return global edge index for local edges.
Definition: faceZone.C:526
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for handling words, derived from string.
Definition: word.H:62
#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