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-2018 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  //- Disallow default bitwise copy construct
109  topoSet(const topoSet&);
110 
111 public:
112 
113  //- Runtime type information
114  TypeName("topoSet");
115 
116 
117  // Static
118 
119  //- Name of file set will use.
120  static fileName localPath(const polyMesh& mesh, const word& name);
121 
122 
123  // Declare run-time constructor selection table
124 
125  // For the direct constructor
127  (
128  autoPtr,
129  topoSet,
130  word,
131  (
132  const polyMesh& mesh,
133  const word& name,
134  readOption r,
135  writeOption w
136  ),
137  (mesh, name, r, w)
138  );
139 
140  // For the constructor from size
142  (
143  autoPtr,
144  topoSet,
145  size,
146  (
147  const polyMesh& mesh,
148  const word& name,
149  const label size,
150  writeOption w
151  ),
152  (mesh, name, size, w)
153  );
154 
155  // For the constructor as copy
157  (
158  autoPtr,
159  topoSet,
160  set,
161  (
162  const polyMesh& mesh,
163  const word& name,
164  const topoSet& set,
165  writeOption w
166  ),
167  (mesh, name, set, w)
168  );
169 
170 
171  // Constructors
172 
173 
174  //- Construct from IOobject as explicitly passed type.
175  // Can't use typeName info here since subclasses not yet instantiated
176  topoSet(const IOobject&, const word& wantedType);
177 
178  //- Construct from polyMesh and name. Searches for a polyMesh/sets
179  // directory but not beyond mesh.facesInstance.
180  topoSet
181  (
182  const polyMesh& mesh,
183  const word& wantedType,
184  const word& name,
187  );
188 
189  //- Construct empty from additional size of labelHashSet.
190  // Searches for a polyMesh/sets
191  // directory but not beyond mesh.facesInstance.
192  topoSet
193  (
194  const polyMesh& mesh,
195  const word& name,
196  const label,
198  );
199 
200  //- Construct empty from additional labelHashSet
201  // Searches for a polyMesh/sets
202  // directory but not beyond mesh.facesInstance.
203  topoSet
204  (
205  const polyMesh& mesh,
206  const word& name,
207  const labelHashSet&,
209  );
210 
211  //- Construct empty from IOobject and size.
212  topoSet(const IOobject&, const label size);
213 
214  //- Construct from IOobject and labelHashSet.
215  topoSet(const IOobject&, const labelHashSet&);
216 
217 
218 
219  //- Clone
220  autoPtr<topoSet> clone() const
221  {
223  return autoPtr<topoSet>(nullptr);
224  }
225 
226 
227  // Selectors
228 
229  //- Return a pointer to a toposet read from file
230  static autoPtr<topoSet> New
231  (
232  const word& setType,
233  const polyMesh& mesh,
234  const word& name,
237  );
238 
239  //- Return a pointer to a new toposet of given size
240  static autoPtr<topoSet> New
241  (
242  const word& setType,
243  const polyMesh& mesh,
244  const word& name,
245  const label size,
247  );
248 
249  //- Return a pointer to a new toposet as copy of another toposet
250  static autoPtr<topoSet> New
251  (
252  const word& setType,
253  const polyMesh& mesh,
254  const word& name,
255  const topoSet& set,
257  );
258 
259 
260  //- Destructor
261  virtual ~topoSet();
262 
263 
264  // Member functions
265 
266  //- Invert contents. (insert all members 0..maxLen-1 which were not in
267  // set)
268  virtual void invert(const label maxLen);
269 
270  //- Subset contents. Only elements present in both sets remain.
271  virtual void subset(const topoSet& set);
272 
273  //- Add elements present in set.
274  virtual void addSet(const topoSet& set);
275 
276  //- Delete elements present in set.
277  virtual void deleteSet(const topoSet& set);
278 
279  //- Sync set across coupled patches.
280  virtual void sync(const polyMesh& mesh);
281 
282  //- Write labels columnwise to os. Truncate to maxLen.
283  virtual void writeDebug(Ostream& os, const label maxLen) const;
284 
285  //- Like above but also writes mesh related quantity
286  // (usually coordinate).
287  virtual void writeDebug
288  (
289  Ostream& os,
290  const primitiveMesh&,
291  const label maxLen
292  ) const = 0;
293 
294  //- Write contents.
295  virtual bool writeData(Ostream&) const;
296 
297  //- Update any stored data for new labels. Not implemented.
298  virtual void updateMesh(const mapPolyMesh& morphMap);
299 
300  //- Return max allowable index (+1). Not implemented.
301  virtual label maxSize(const polyMesh& mesh) const = 0;
302 
303 
304 
305  // Member operators
306 
307  //- Copy labelHashSet part only
308  void operator=(const topoSet&);
309 
310 };
311 
312 
313 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
314 
315 } // End namespace Foam
316 
317 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
318 
319 #endif
320 
321 // ************************************************************************* //
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:297
A class for handling file names.
Definition: fileName.H:69
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:219
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.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:65
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
topoSet(const topoSet &)
Disallow default bitwise copy construct.
#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))