faceZoneSet.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2018-2024 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::faceZoneSet
29 
30 Description
31  Like faceSet but -reads data from faceZone -updates faceZone when writing.
32 
33 SourceFiles
34  faceZoneSet.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_faceZoneSet_H
39 #define Foam_faceZoneSet_H
40 
41 #include "faceSet.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class faceZoneSet Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class faceZoneSet
53 :
54  public faceSet
55 {
56  // Private Data
57 
58  const polyMesh& mesh_;
59 
60  labelList addressing_;
61 
62  boolList flipMap_;
63 
64 
65  // Private Member Functions
66 
67  void subset
68  (
69  const word& setName,
70  const labelUList& setAddressing,
71  const UList<bool>& setFlipMap
72  );
73 
74  void addSet
75  (
76  const word& setName,
77  const labelUList& setAddressing,
78  const UList<bool>& setFlipMap
79  );
80 
81  void subtractSet
82  (
83  const word& setName,
84  const labelUList& setAddressing,
85  const UList<bool>& setFlipMap
86  );
87 
88 
89 public:
90 
91  //- Runtime type information
92  TypeNameNoDebug("faceZoneSet");
93 
94 
95  // Constructors
96 
97  //- Construct from objectRegistry and name
99  (
100  const polyMesh& mesh,
101  const word& name,
104  );
105 
106  //- Construct empty (no-read) with initial labelHashSet capacity.
108  (
109  const polyMesh& mesh,
110  const word& name,
111  const label initialCapacity,
113  );
114 
115  //- Copy construct (no-read) from existing set
117  (
118  const polyMesh& mesh,
119  const word& name,
120  const topoSet& set,
122  );
123 
124 
125  //- Destructor
126  virtual ~faceZoneSet() = default;
127 
128 
129  // Member Functions
130 
131  const labelList& addressing() const noexcept
132  {
133  return addressing_;
134  }
135 
137  {
138  return addressing_;
139  }
140 
142  const boolList& flipMap() const noexcept
143  {
144  return flipMap_;
145  }
146 
148  {
149  return flipMap_;
150  }
151 
153  //- Sort addressing and make faceSet part consistent with addressing
154  void updateSet();
155 
156  //- Invert contents.
157  // Insert all members [0,maxLen) which were not in set.
158  virtual void invert(const label maxLen);
159 
160  //- Subset contents. Only elements present in both sets remain.
161  virtual void subset(const labelUList& elems);
162 
163  //- Subset contents. Only elements present in both sets remain.
164  virtual void subset(const topoSet& set);
165 
166  //- Add given elements to the set
167  virtual void addSet(const labelUList& elems);
168 
169  //- Add given elements to the set
170  virtual void addSet(const topoSet& set);
171 
172  //- Subtract given elements from the set
173  virtual void subtractSet(const labelUList& elems);
174 
175  //- Subtract given elements from the set
176  virtual void subtractSet(const topoSet& set);
177 
178  //- Sync faceZoneSet across coupled patches.
179  virtual void sync(const polyMesh& mesh);
180 
181  //- Write maxLen items with label and coordinates.
182  virtual void writeDebug
183  (
184  Ostream& os,
185  const primitiveMesh&,
186  const label maxLen
187  ) const;
188 
189  //- Write faceZone using stream options
190  virtual bool writeObject
191  (
192  IOstreamOption streamOpt,
193  const bool writeOnProc
194  ) const;
195 
196  //- Update any stored data for new labels
197  virtual void updateMesh(const mapPolyMesh& morphMap);
198 
199  //- Return max index+1.
200  virtual label maxSize(const polyMesh& mesh) const;
201 };
202 
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 } // End namespace Foam
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 #endif
211 
212 // ************************************************************************* //
writeOption
Enumeration defining write preferences.
A list of face labels.
Definition: faceSet.H:47
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:195
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:75
virtual void invert(const label maxLen)
Invert contents.
Definition: faceZoneSet.C:145
A simple container for options an IOstream can normally have.
Ignore writing from objectRegistry::writeObject()
virtual void updateMesh(const mapPolyMesh &morphMap)
Update any stored data for new labels.
Definition: faceZoneSet.C:566
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
virtual void writeDebug(Ostream &os, const primitiveMesh &, const label maxLen) const
Write maxLen items with label and coordinates.
Definition: faceZoneSet.C:590
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
OBJstream os(runTime.globalPath()/outputName)
const labelList & addressing() const noexcept
Definition: faceZoneSet.H:136
virtual void sync(const polyMesh &mesh)
Sync faceZoneSet across coupled patches.
Definition: faceZoneSet.C:404
faceZoneSet(const polyMesh &mesh, const word &name, IOobjectOption::readOption rOpt=IOobjectOption::MUST_READ, IOobjectOption::writeOption wOpt=IOobjectOption::NO_WRITE)
Construct from objectRegistry and name.
Definition: faceZoneSet.C:82
void updateSet()
Sort addressing and make faceSet part consistent with addressing.
Definition: faceZoneSet.C:45
Like faceSet but -reads data from faceZone -updates faceZone when writing.
Definition: faceZoneSet.H:47
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:59
List< T > subset(const BoolListType &select, const UList< T > &input, const bool invert=false)
Extract elements of the input list when select is true.
TypeNameNoDebug("faceZoneSet")
Runtime type information.
virtual ~faceZoneSet()=default
Destructor.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:75
virtual label maxSize(const polyMesh &mesh) const
Return max index+1.
Definition: faceZoneSet.C:523
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write faceZone using stream options.
Definition: faceZoneSet.C:530
const boolList & flipMap() const noexcept
Definition: faceZoneSet.H:147
Namespace for OpenFOAM.
readOption
Enumeration defining read preferences.