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-2022 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  A subset of mesh faces organised as a primitive patch.
29 
30  For quick check whether a face belongs to the zone use the lookup
31  mechanism in meshFaceZones, where all the zoned faces are registered
32  with their zone number.
33 
34 SourceFiles
35  faceZone.C
36  faceZoneNew.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef faceZone_H
41 #define faceZone_H
42 
43 #include "zone.H"
44 #include "meshFaceZonesFwd.H"
45 #include "boolList.H"
46 #include "primitiveFacePatch.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 class polyTopoChangeMap;
54 class polyMeshMap;
55 
56 // Forward declaration of friend functions and operators
57 
58 class faceZone;
59 Ostream& operator<<(Ostream&, const faceZone&);
60 
61 
62 /*---------------------------------------------------------------------------*\
63  Class faceZone Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class faceZone
67 :
68  public zone
69 {
70  // Private Data
71 
72  //- The name associated with the zone-labels dictionary entry
73  static const word labelsName_;
74 
75 
76 protected:
77 
78  // Protected data
79 
80  //- Flip map for all faces in the zone. Set to true if the
81  // face needs to be flipped to achieve the correct orientation.
83 
84  //- Reference to zone list
86 
87 
88  // Demand-driven private data
89 
90  //- Primitive patch made out of correctly flipped faces
92 
93  //- Master cell layer
94  mutable labelList* masterCellsPtr_;
95 
96  //- Slave cell layer
97  mutable labelList* slaveCellsPtr_;
98 
99  //- Global edge addressing
100  mutable labelList* mePtr_;
101 
102 
103  // Protected Member Functions
104 
105  //- Build primitive patch
106  void calcFaceZonePatch() const;
107 
108  //- Return map of local face indices
109  const Map<label>& faceLookupMap() const;
110 
111  //- Calculate master and slave face layer
112  void calcCellLayers() const;
113 
114  //- Check addressing
115  void checkAddressing() const;
116 
117 
118 public:
119 
120  // Static Data Members
121 
122  //- The name associated with the zone-labels dictionary entry
123  static const char * const labelsName;
124 
125 
126  //- Runtime type information
127  TypeName("faceZone");
128 
129 
130  // Declare run-time constructor selection tables
131 
133  (
134  autoPtr,
135  faceZone,
136  dictionary,
137  (
138  const word& name,
139  const dictionary& dict,
140  const label index,
141  const meshFaceZones& mz
142  ),
143  (name, dict, index, mz)
144  );
145 
146 
147  // Constructors
148 
149  //- Construct from components
150  faceZone
151  (
152  const word& name,
153  const labelUList& addr,
154  const boolList& fm,
155  const label index,
156  const meshFaceZones& mz
157  );
158 
159  //- Construct from components, moving contents
160  faceZone
161  (
162  const word& name,
163  labelList&& addr,
164  boolList&& fm,
165  const label index,
166  const meshFaceZones&
167  );
168 
169  //- Construct from dictionary
170  faceZone
171  (
172  const word& name,
173  const dictionary&,
174  const label index,
175  const meshFaceZones&
176  );
177 
178  //- Construct given the original zone and resetting the
179  // face list and mesh zones information
180  faceZone
181  (
182  const faceZone&,
183  const labelUList& addr,
184  const boolList& fm,
185  const label index,
186  const meshFaceZones&
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 label index,
197  const meshFaceZones&
198  );
199 
200  //- Disallow default bitwise copy construction
201  faceZone(const faceZone&) = delete;
202 
203 
204  //- Construct and return a clone, resetting the mesh zones
205  virtual autoPtr<faceZone> clone(const meshFaceZones& mz) const
206  {
207  return autoPtr<faceZone>
208  (
209  new faceZone(*this, *this, flipMap(), index(), mz)
210  );
211  }
212 
213  //- Construct and return a clone, resetting the face list
214  // and mesh zones
215  virtual autoPtr<faceZone> clone
216  (
217  const labelUList& addr,
218  const boolList& fm,
219  const label index,
220  const meshFaceZones& mz
221  ) const
222  {
223  return autoPtr<faceZone>
224  (
225  new faceZone(*this, addr, fm, index, mz)
226  );
227  }
228 
229 
230  // Selectors
231 
232  //- Return a pointer to a new face zone
233  // created on freestore from dictionary
234  static autoPtr<faceZone> New
235  (
236  const word& name,
237  const dictionary&,
238  const label index,
239  const meshFaceZones&
240  );
241 
242 
243  //- Destructor
244  virtual ~faceZone();
245 
246 
247  // Member Functions
248 
249  //- Return face flip map
250  const boolList& flipMap() const
251  {
252  return flipMap_;
253  }
254 
255  //- Helper function to re-direct to zone::localID(...)
256  label whichFace(const label globalCellID) const;
257 
258  //- Return reference to primitive patch
259  const primitiveFacePatch& operator()() const;
260 
261  //- Return meshZones reference
262  const meshFaceZones& meshZones() const;
263 
264 
265  // Addressing into mesh
266 
267  //- Return labels of master cells (cells next to the master face
268  // zone in the prescribed direction)
269  const labelList& masterCells() const;
270 
271  //- Return labels of slave cells
272  const labelList& slaveCells() const;
273 
274  //- Return global edge index for local edges
275  const labelList& meshEdges() const;
276 
277 
278  //- Clear addressing
279  virtual void clearAddressing();
280 
281  //- Reset addressing and flip map (clearing demand-driven data)
282  virtual void resetAddressing(const labelUList&, const boolList&);
283 
284  //- Check zone definition. Return true if in error.
285  virtual bool checkDefinition(const bool report = false) const;
286 
287  //- Check whether all procs have faces synchronised. Return
288  // true if in error.
289  virtual bool checkParallelSync(const bool report = false) const;
290 
291  //- Correct patch after moving points
292  virtual void movePoints(const pointField&);
293 
294  //- Update topology using the given map
295  virtual void topoChange(const polyTopoChangeMap&);
296 
297  //- Update from another mesh using the given map
298  virtual void mapMesh(const polyMeshMap&);
299 
300  //- Write
301  virtual void write(Ostream&) const;
302 
303  //- Write dictionary
304  virtual void writeDict(Ostream&) const;
305 
306 
307  // Member Operators
308 
309  //- Assignment to zone, clearing demand-driven data
310  void operator=(const faceZone&);
311 
312  //- Move assignment to zone, clearing demand-driven data
313  void operator=(faceZone&&);
314 
315 
316  // I-O
317 
318  //- Ostream Operator
319  friend Ostream& operator<<(Ostream&, const faceZone&);
320 };
321 
322 
323 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
324 
325 } // End namespace Foam
326 
327 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
328 
329 #endif
330 
331 // ************************************************************************* //
autoPtr< List< label > > clone() const
Clone.
Definition: ListI.H:109
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.
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 keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
A subset of mesh faces organised as a primitive patch.
Definition: faceZone.H:68
virtual bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: faceZone.C:426
const boolList & flipMap() const
Return face flip map.
Definition: faceZone.H:249
const meshFaceZones & meshZones() const
Return meshZones reference.
Definition: faceZone.C:301
friend Ostream & operator<<(Ostream &, const faceZone &)
Ostream Operator.
const meshFaceZones & meshZones_
Reference to zone list.
Definition: faceZone.H:84
virtual void write(Ostream &) const
Write.
Definition: faceZone.C:529
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Definition: faceZone.C:307
void operator=(const faceZone &)
Assignment to zone, clearing demand-driven data.
Definition: faceZone.C:551
boolList flipMap_
Flip map for all faces in the zone. Set to true if the.
Definition: faceZone.H:81
faceZone(const word &name, const labelUList &addr, const boolList &fm, const label index, const meshFaceZones &mz)
Construct from components.
Definition: faceZone.C:188
const labelList & masterCells() const
Return labels of master cells (cells next to the master face.
Definition: faceZone.C:324
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: faceZone.C:390
virtual void resetAddressing(const labelUList &, const boolList &)
Reset addressing and flip map (clearing demand-driven data)
Definition: faceZone.C:379
void calcCellLayers() const
Calculate master and slave face layer.
Definition: faceZone.C:97
void calcFaceZonePatch() const
Build primitive patch.
Definition: faceZone.C:50
void checkAddressing() const
Check addressing.
Definition: faceZone.C:156
const primitiveFacePatch & operator()() const
Return reference to primitive patch.
Definition: faceZone.C:313
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: faceZone.C:420
static const char *const labelsName
The name associated with the zone-labels dictionary entry.
Definition: faceZone.H:122
static autoPtr< faceZone > New(const word &name, const dictionary &, const label index, const meshFaceZones &)
Return a pointer to a new face zone.
Definition: faceZoneNew.C:32
virtual void writeDict(Ostream &) const
Write dictionary.
Definition: faceZone.C:537
declareRunTimeSelectionTable(autoPtr, faceZone, dictionary,(const word &name, const dictionary &dict, const label index, const meshFaceZones &mz),(name, dict, index, mz))
labelList * slaveCellsPtr_
Slave cell layer.
Definition: faceZone.H:96
virtual void clearAddressing()
Clear addressing.
Definition: faceZone.C:365
const Map< label > & faceLookupMap() const
Return map of local face indices.
virtual ~faceZone()
Destructor.
Definition: faceZone.C:293
virtual void movePoints(const pointField &)
Correct patch after moving points.
Definition: faceZone.C:521
primitiveFacePatch * patchPtr_
Primitive patch made out of correctly flipped faces.
Definition: faceZone.H:90
labelList * mePtr_
Global edge addressing.
Definition: faceZone.H:99
virtual bool checkParallelSync(const bool report=false) const
Check whether all procs have faces synchronised. Return.
Definition: faceZone.C:432
labelList * masterCellsPtr_
Master cell layer.
Definition: faceZone.H:93
TypeName("faceZone")
Runtime type information.
const labelList & slaveCells() const
Return labels of slave cells.
Definition: faceZone.C:335
const labelList & meshEdges() const
Return global edge index for local edges.
Definition: faceZone.C:346
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
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
Base class for zones.
Definition: zone.H:60
label index() const
Return the index of this zone in zone list.
Definition: zone.H:158
const word & name() const
Return name.
Definition: zone.H:147
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 &, const ensightPart &)
dictionary dict