All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cellSet.C
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 \*---------------------------------------------------------------------------*/
25 
26 #include "cellSet.H"
27 #include "mapPolyMesh.H"
28 #include "polyMesh.H"
29 #include "Time.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
39 defineTypeNameAndDebug(cellSet, 0);
40 
41 addToRunTimeSelectionTable(topoSet, cellSet, word);
42 addToRunTimeSelectionTable(topoSet, cellSet, size);
43 addToRunTimeSelectionTable(topoSet, cellSet, set);
44 
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
49 :
50  topoSet(obj, typeName)
51 {}
52 
53 
55 (
56  const polyMesh& mesh,
57  const word& name,
58  readOption r,
59  writeOption w
60 )
61 :
62  topoSet(mesh, typeName, name, r, w)
63 {
64  // Make sure set within valid range
65  check(mesh.nCells());
66 }
67 
68 
70 (
71  const polyMesh& mesh,
72  const word& name,
73  const label size,
74  writeOption w
75 )
76 :
77  topoSet(mesh, name, size, w)
78 {}
79 
80 
82 (
83  const polyMesh& mesh,
84  const word& name,
85  const topoSet& set,
86  writeOption w
87 )
88 :
89  topoSet(mesh, name, set, w)
90 {}
91 
92 
94 (
95  const polyMesh& mesh,
96  const word& name,
97  const labelHashSet& set,
98  writeOption w
99 )
100 :
101  topoSet(mesh, name, set, w)
102 {}
103 
104 
105 // Database constructors (for when no mesh available)
107 (
108  const Time& runTime,
109  const word& name,
110  readOption r,
111  writeOption w
112 )
113 :
114  topoSet
115  (
116  IOobject
117  (
118  name,
119  runTime.findInstance
120  (
121  polyMesh::meshSubDir/"sets", // polyMesh::meshSubDir,
122  word::null, //"faces"
124  runTime.findInstance
125  (
127  "faces",
129  )
130  ),
131  polyMesh::meshSubDir/"sets",
132  runTime,
133  r,
134  w
135  ),
136  typeName
137  )
138 {}
139 
140 
142 (
143  const Time& runTime,
144  const word& name,
145  const label size,
146  writeOption w
147 )
148 :
149  topoSet
150  (
151  IOobject
152  (
153  name,
154  runTime.findInstance
155  (
156  polyMesh::meshSubDir/"sets", // polyMesh::meshSubDir,
157  word::null, //"faces"
159  runTime.findInstance
160  (
162  "faces",
164  )
165  ),
166  polyMesh::meshSubDir/"sets",
167  runTime,
169  w
170  ),
171  size
172  )
173 {}
174 
175 
177 (
178  const Time& runTime,
179  const word& name,
180  const labelHashSet& set,
181  writeOption w
182 )
183 :
184  topoSet
185  (
186  IOobject
187  (
188  name,
189  runTime.findInstance
190  (
191  polyMesh::meshSubDir/"sets", // polyMesh::meshSubDir,
192  word::null, //"faces"
194  runTime.findInstance
195  (
197  "faces",
199  )
200  ),
201  polyMesh::meshSubDir/"sets",
202  runTime,
204  w
205  ),
206  set
207  )
208 {}
209 
210 
211 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
212 
214 {}
215 
216 
217 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
218 
219 label cellSet::maxSize(const polyMesh& mesh) const
220 {
221  return mesh.nCells();
222 }
223 
224 
225 void cellSet::updateMesh(const mapPolyMesh& morphMap)
226 {
227  updateLabels(morphMap.reverseCellMap());
228 }
229 
230 
232 (
233  Ostream& os,
234  const primitiveMesh& mesh,
235  const label maxLen
236 ) const
237 {
238  topoSet::writeDebug(os, mesh.cellCentres(), maxLen);
239 }
240 
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 } // End namespace Foam
245 
246 // ************************************************************************* //
bool set(const label &key)
Same as insert (cannot overwrite nil content)
Definition: HashSet.H:121
writeOption
Enumeration defining the write options.
Definition: IOobject.H:119
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
cellSet(const IOobject &obj)
Construct from IOobject. No checking.
Definition: cellSet.C:48
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:74
virtual void writeDebug(Ostream &os, const primitiveMesh &, const label maxLen) const
Write maxLen items with label and coordinates.
Definition: cellSet.C:232
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:312
label nCells() const
virtual void updateMesh(const mapPolyMesh &morphMap)
Update any stored data for new labels.
Definition: cellSet.C:225
word findInstance(const fileName &dir, const word &name=word::null, const IOobject::readOption rOpt=IOobject::MUST_READ, const word &stopInstance=word::null) const
Return the location of "dir" containing the file "name".
Definition: Time.C:659
readOption
Enumeration defining the read options.
Definition: IOobject.H:110
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
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
Macros for easy insertion into run-time selection tables.
void updateLabels(const labelList &map)
Update map from map. Used to update cell/face labels.
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.
static const word null
An empty word.
Definition: word.H:77
const vectorField & cellCentres() const
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
const labelList & reverseCellMap() const
Reverse cell map.
Definition: mapPolyMesh.H:521
defineTypeNameAndDebug(combustionModel, 0)
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
virtual label maxSize(const polyMesh &mesh) const
Return max index+1.
Definition: cellSet.C:219
topoSet(const IOobject &, const word &wantedType)
Construct from IOobject as explicitly passed type.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
virtual ~cellSet()
Destructor.
Definition: cellSet.C:213
Namespace for OpenFOAM.