topoSet.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-2019 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::topoSet
26 
27 Description
28  General set of labels of mesh quantity (points, cells, faces).
29 
30  Contains various 'notImplemented' functions, but I do not want to make
31  this class abstract since it is quite handy to work on topoSets.
32 
33 SourceFiles
34  topoSet.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef topoSet_H
39 #define topoSet_H
40 
41 #include "HashSet.H"
42 #include "regIOobject.H"
43 #include "labelList.H"
44 #include "typeInfo.H"
45 #include "autoPtr.H"
46 #include "pointField.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 
54 class mapPolyMesh;
55 class polyMesh;
56 class primitiveMesh;
57 
58 /*---------------------------------------------------------------------------*\
59  Class topoSet Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class topoSet
63 :
64  public regIOobject,
65  public labelHashSet
66 {
67 
68 protected:
69 
70  // Protected Member Functions
71 
72  //- Update map from map. Used to update cell/face labels
73  // after morphing
74  void updateLabels(const labelList& map);
75 
76  //- Check validity of contents.
77  void check(const label maxLabel);
78 
79  //- Write part of contents nicely formatted. Prints labels only.
80  void writeDebug
81  (
82  Ostream& os,
83  const label maxElem,
85  label& elemI
86  ) const;
87 
88  //- Write part of contents nicely formatted. Prints label
89  // and corresponding coordinate.
90  void writeDebug
91  (
92  Ostream& os,
93  const pointField& coords,
94  const label maxElem,
96  label& elemI
97  ) const;
98 
99  //- Write labels and coordinates columnwise to os. Truncate to maxLen.
100  void writeDebug
101  (
102  Ostream& os,
103  const pointField& coords,
104  const label maxLen
105  ) const;
106 
107 
108 public:
109 
110  //- Runtime type information
111  TypeName("topoSet");
112 
113 
114  // Static
115 
116  //- Name of file set will use.
117  static fileName localPath(const polyMesh& mesh, const word& name);
118 
119 
120  // Declare run-time constructor selection table
121 
122  // For the direct constructor
124  (
125  autoPtr,
126  topoSet,
127  word,
128  (
129  const polyMesh& mesh,
130  const word& name,
131  readOption r,
132  writeOption w
133  ),
134  (mesh, name, r, w)
135  );
136 
137  // For the constructor from size
139  (
140  autoPtr,
141  topoSet,
142  size,
143  (
144  const polyMesh& mesh,
145  const word& name,
146  const label size,
147  writeOption w
148  ),
149  (mesh, name, size, w)
150  );
151 
152  // For the constructor as copy
154  (
155  autoPtr,
156  topoSet,
157  set,
158  (
159  const polyMesh& mesh,
160  const word& name,
161  const topoSet& set,
162  writeOption w
163  ),
164  (mesh, name, set, w)
165  );
166 
167 
168  // Constructors
169 
170 
171  //- Construct from IOobject as explicitly passed type.
172  // Can't use typeName info here since subclasses not yet instantiated
173  topoSet(const IOobject&, const word& wantedType);
174 
175  //- Construct from polyMesh and name. Searches for a polyMesh/sets
176  // directory but not beyond mesh.facesInstance.
177  topoSet
178  (
179  const polyMesh& mesh,
180  const word& wantedType,
181  const word& name,
184  );
185 
186  //- Construct empty from additional size of labelHashSet.
187  // Searches for a polyMesh/sets
188  // directory but not beyond mesh.facesInstance.
189  topoSet
190  (
191  const polyMesh& mesh,
192  const word& name,
193  const label,
195  );
196 
197  //- Construct empty from additional labelHashSet
198  // Searches for a polyMesh/sets
199  // directory but not beyond mesh.facesInstance.
200  topoSet
201  (
202  const polyMesh& mesh,
203  const word& name,
204  const labelHashSet&,
206  );
207 
208  //- Construct empty from IOobject and size.
209  topoSet(const IOobject&, const label size);
210 
211  //- Construct from IOobject and labelHashSet.
212  topoSet(const IOobject&, const labelHashSet&);
213 
214  //- Disallow default bitwise copy construction
215  topoSet(const topoSet&) = delete;
216 
217 
218  //- Clone
219  autoPtr<topoSet> clone() const
220  {
222  return autoPtr<topoSet>(nullptr);
223  }
224 
225 
226  // Selectors
227 
228  //- Return a pointer to a toposet read from file
229  static autoPtr<topoSet> New
230  (
231  const word& setType,
232  const polyMesh& mesh,
233  const word& name,
236  );
237 
238  //- Return a pointer to a new toposet of given size
239  static autoPtr<topoSet> New
240  (
241  const word& setType,
242  const polyMesh& mesh,
243  const word& name,
244  const label size,
246  );
247 
248  //- Return a pointer to a new toposet as copy of another toposet
249  static autoPtr<topoSet> New
250  (
251  const word& setType,
252  const polyMesh& mesh,
253  const word& name,
254  const topoSet& set,
256  );
257 
258 
259  //- Destructor
260  virtual ~topoSet();
261 
262 
263  // Member Functions
264 
265  //- Invert contents. (insert all members 0..maxLen-1 which were not in
266  // set)
267  virtual void invert(const label maxLen);
268 
269  //- Subset contents. Only elements present in both sets remain.
270  virtual void subset(const topoSet& set);
271 
272  //- Add elements present in set.
273  virtual void addSet(const topoSet& set);
274 
275  //- Delete elements present in set.
276  virtual void deleteSet(const topoSet& set);
277 
278  //- Sync set across coupled patches.
279  virtual void sync(const polyMesh& mesh);
280 
281  //- Write labels columnwise to os. Truncate to maxLen.
282  virtual void writeDebug(Ostream& os, const label maxLen) const;
283 
284  //- Like above but also writes mesh related quantity
285  // (usually coordinate).
286  virtual void writeDebug
287  (
288  Ostream& os,
289  const primitiveMesh&,
290  const label maxLen
291  ) const = 0;
292 
293  //- Write contents.
294  virtual bool writeData(Ostream&) const;
295 
296  //- Update any stored data for new labels. Not implemented.
297  virtual void updateMesh(const mapPolyMesh& morphMap);
298 
299  //- Return max allowable index (+1). Not implemented.
300  virtual label maxSize(const polyMesh& mesh) const = 0;
301 
302 
303 
304  // Member Operators
305 
306  //- Copy labelHashSet part only
307  void operator=(const topoSet&);
308 
309 };
310 
311 
312 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
313 
314 } // End namespace Foam
315 
316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
317 
318 #endif
319 
320 // ************************************************************************* //
virtual void sync(const polyMesh &mesh)
Sync set across coupled patches.
virtual label maxSize(const polyMesh &mesh) const =0
Return max allowable index (+1). Not implemented.
virtual void updateMesh(const mapPolyMesh &morphMap)
Update any stored data for new labels. Not implemented.
virtual void invert(const label maxLen)
Invert contents. (insert all members 0..maxLen-1 which were not in.
void operator=(const topoSet &)
Copy labelHashSet part only.
writeOption
Enumeration defining the write options.
Definition: IOobject.H:116
static autoPtr< topoSet > New(const word &setType, const polyMesh &mesh, const word &name, readOption r=MUST_READ, writeOption w=NO_WRITE)
Return a pointer to a toposet read from file.
HashTable< nil, label, Hash< label > >::const_iterator const_iterator
Definition: HashSet.H:67
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
const word & name() const
Return name.
Definition: IOobject.H:295
A class for handling file names.
Definition: fileName.H:79
virtual ~topoSet()
Destructor.
static fileName localPath(const polyMesh &mesh, const word &name)
Name of file set will use.
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:74
readOption
Enumeration defining the read options.
Definition: IOobject.H:107
virtual bool writeData(Ostream &) const
Write contents.
void check(const label maxLabel)
Check validity of contents.
label size() const
Return number of elements in table.
Definition: HashTableI.H:65
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
void updateLabels(const labelList &map)
Update map from map. Used to update cell/face labels.
dynamicFvMesh & mesh
autoPtr< topoSet > clone() const
Clone.
Definition: topoSet.H:218
A class for handling words, derived from string.
Definition: word.H:59
void writeDebug(Ostream &os, const label maxElem, topoSet::const_iterator &iter, label &elemI) const
Write part of contents nicely formatted. Prints labels only.
virtual void addSet(const topoSet &set)
Add elements present in set.
TypeName("topoSet")
Runtime type information.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
virtual void subset(const topoSet &set)
Subset contents. Only elements present in both sets remain.
topoSet(const IOobject &, const word &wantedType)
Construct from IOobject as explicitly passed type.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
virtual void deleteSet(const topoSet &set)
Delete elements present in set.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
Namespace for OpenFOAM.
declareRunTimeSelectionTable(autoPtr, topoSet, word,(const polyMesh &mesh, const word &name, readOption r, writeOption w),(mesh, name, r, w))