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-2024 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 faceZoneList, where all the zoned faces are registered
32  with their zone number.
33 
34 SourceFiles
35  faceZone.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef faceZone_H
40 #define faceZone_H
41 
42 #include "Zone.H"
43 #include "boolList.H"
44 #include "primitiveFacePatch.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 class faceZoneList;
52 
53 /*---------------------------------------------------------------------------*\
54  Class faceZone Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 class faceZone
58 :
59  public Zone<faceZone, faceZoneList>
60 {
61  // Private Data
62 
63  //- The name associated with the zone-labels dictionary entry
64  static const word labelsName_;
65 
66 
67 protected:
68 
69  // Protected data
70 
71  //- Flip map for all faces in the zone. Set to true if the
72  // face needs to be flipped to achieve the correct orientation.
74 
75 
76  // Demand-driven private data
77 
78  //- Primitive patch made out of correctly flipped faces
80 
81  //- Master cell layer
82  mutable labelList* masterCellsPtr_;
83 
84  //- Slave cell layer
85  mutable labelList* slaveCellsPtr_;
86 
87  //- Global edge addressing
88  mutable labelList* mePtr_;
89 
90 
91  // Protected Member Functions
92 
93  //- Build primitive patch
94  void calcFaceZonePatch() const;
95 
96  //- Return map of local face indices
97  const Map<label>& faceLookupMap() const;
98 
99  //- Calculate master and slave face layer
100  void calcCellLayers() const;
101 
102  //- Check addressing
103  void checkAddressing() const;
104 
105  //- Reset the indices and flipMap from the given map
106  void reset(const Map<bool>& indices);
107 
108 
109 public:
110 
111  typedef faceZoneList ZonesType;
112 
113  // Static Data Members
114 
115  //- The name associated with the zone-labels dictionary entry
116  static const char* const labelsName;
117 
118  //- Runtime type information
119  TypeName("faceZone");
120 
121 
122  // Constructors
123 
124  //- Construct from components
125  faceZone
126  (
127  const word& name,
128  const labelUList& addr,
129  const boolList& fm,
130  const faceZoneList& mz
131  );
132 
133  //- Construct from components, moving contents
134  faceZone
135  (
136  const word& name,
137  labelList&& addr,
138  boolList&& fm,
139  const faceZoneList&
140  );
141 
142  //- Construct from dictionary
143  faceZone
144  (
145  const word& name,
146  const dictionary&,
147  const faceZoneList&
148  );
149 
150  //- Construct given the original zone and resetting the
151  // face list and mesh zones information
152  faceZone
153  (
154  const faceZone&,
155  const labelUList& addr,
156  const boolList& fm,
157  const faceZoneList&
158  );
159 
160  //- Construct given the original zone, resetting the
161  // face list and mesh zones information
162  faceZone
163  (
164  const faceZone&,
165  labelList&& addr,
166  boolList&& fm,
167  const faceZoneList&
168  );
169 
170  //- Disallow default bitwise copy construction
171  faceZone(const faceZone&) = delete;
172 
173  //- Construct and return a clone, resetting the mesh zones
174  virtual autoPtr<faceZone> clone(const faceZoneList& mz) const
175  {
176  return autoPtr<faceZone>
177  (
178  new faceZone(*this, *this, flipMap(), mz)
179  );
180  }
181 
182  //- Construct and return a clone, resetting the face list
183  // and mesh zones
184  virtual autoPtr<faceZone> clone
185  (
186  const labelUList& addr,
187  const boolList& fm,
188  const faceZoneList& mz
189  ) const
190  {
191  return autoPtr<faceZone>
192  (
193  new faceZone(*this, addr, fm, mz)
194  );
195  }
196 
197 
198  //- Destructor
199  virtual ~faceZone();
200 
201 
202  // Member Functions
203 
204  //- Return face flip map
205  const boolList& flipMap() const
206  {
207  return flipMap_;
208  }
209 
210  //- Return the mesh face centres
211  const pointField& meshCentres() const;
212 
213  //- Return reference to primitive patch
214  const primitiveFacePatch& patch() const;
215 
216 
217  // Addressing into mesh
218 
219  //- Return labels of master cells (cells next to the master face
220  // zone in the prescribed direction)
221  const labelList& masterCells() const;
222 
223  //- Return labels of slave cells
224  const labelList& slaveCells() const;
225 
226  //- Return global edge index for local edges
227  const labelList& meshEdges() const;
228 
229 
230  //- Clear addressing
231  virtual void clearAddressing();
232 
233  //- Reset addressing and flip map (clearing demand-driven data)
234  virtual void resetAddressing(const labelUList&, const boolList&);
235 
236  //- Check zone definition. Return true if in error.
237  bool checkDefinition(const bool report = false) const;
238 
239  //- Check whether all procs have faces synchronised. Return
240  // true if in error.
241  bool checkParallelSync(const bool report = false) const;
242 
243  //- Insert given indices and corresponding face flips into zone
244  void insert(const Map<bool>& newIndices);
245 
246  //- Swap two faceZones
247  void swap(faceZone&);
248 
249  //- Correct patch after moving points
250  virtual void movePoints(const pointField&);
251 
252  //- Update zone using the given map
253  virtual void topoChange(const polyTopoChangeMap&);
254 
255  //- Write dictionary
256  virtual void writeDict(Ostream&) const;
257 
258 
259  // Member Operators
260 
261  //- Assignment to zone, clearing demand-driven data
262  void operator=(const faceZone&);
263 
264  //- Move assignment to zone, clearing demand-driven data
265  void operator=(faceZone&&);
266 };
267 
268 
269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
270 
271 } // End namespace Foam
272 
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 
275 #endif
276 
277 // ************************************************************************* //
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.
Base class for zones.
Definition: Zone.H:67
const word & name() const
Return name.
Definition: Zone.H:184
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:162
A subset of mesh faces organised as a primitive patch.
Definition: faceZone.H:59
bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: faceZone.C:392
const boolList & flipMap() const
Return face flip map.
Definition: faceZone.H:204
void swap(faceZone &)
Swap two faceZones.
Definition: faceZone.C:497
const pointField & meshCentres() const
Return the mesh face centres.
Definition: faceZone.C:309
void operator=(const faceZone &)
Assignment to zone, clearing demand-driven data.
Definition: faceZone.C:568
boolList flipMap_
Flip map for all faces in the zone. Set to true if the.
Definition: faceZone.H:72
const primitiveFacePatch & patch() const
Return reference to primitive patch.
Definition: faceZone.C:315
const labelList & masterCells() const
Return labels of master cells (cells next to the master face.
Definition: faceZone.C:326
virtual void topoChange(const polyTopoChangeMap &)
Update zone using the given map.
Definition: faceZone.C:504
virtual void resetAddressing(const labelUList &, const boolList &)
Reset addressing and flip map (clearing demand-driven data)
Definition: faceZone.C:381
void calcCellLayers() const
Calculate master and slave face layer.
Definition: faceZone.C:96
void calcFaceZonePatch() const
Build primitive patch.
Definition: faceZone.C:49
void checkAddressing() const
Check addressing.
Definition: faceZone.C:155
faceZone(const word &name, const labelUList &addr, const boolList &fm, const faceZoneList &mz)
Construct from components.
Definition: faceZone.C:206
void reset(const Map< bool > &indices)
Reset the indices and flipMap from the given map.
Definition: faceZone.C:184
static const char *const labelsName
The name associated with the zone-labels dictionary entry.
Definition: faceZone.H:115
virtual void writeDict(Ostream &) const
Write dictionary.
Definition: faceZone.C:554
labelList * slaveCellsPtr_
Slave cell layer.
Definition: faceZone.H:84
void insert(const Map< bool > &newIndices)
Insert given indices and corresponding face flips into zone.
Definition: faceZone.C:489
virtual void clearAddressing()
Clear addressing.
Definition: faceZone.C:367
const Map< label > & faceLookupMap() const
Return map of local face indices.
virtual ~faceZone()
Destructor.
Definition: faceZone.C:301
virtual void movePoints(const pointField &)
Correct patch after moving points.
Definition: faceZone.C:545
primitiveFacePatch * patchPtr_
Primitive patch made out of correctly flipped faces.
Definition: faceZone.H:78
labelList * mePtr_
Global edge addressing.
Definition: faceZone.H:87
bool checkParallelSync(const bool report=false) const
Check whether all procs have faces synchronised. Return.
Definition: faceZone.C:402
faceZoneList ZonesType
Definition: faceZone.H:110
labelList * masterCellsPtr_
Master cell layer.
Definition: faceZone.H:81
TypeName("faceZone")
Runtime type information.
const labelList & slaveCells() const
Return labels of slave cells.
Definition: faceZone.C:337
const labelList & meshEdges() const
Return global edge index for local edges.
Definition: faceZone.C:348
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
Namespace for OpenFOAM.