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-2022 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 "polyTopoChangeMap.H"
28 #include "polyMesh.H"
29 #include "Time.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
40 
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"
123  IOobject::MUST_READ,
124  runTime.findInstance
125  (
126  polyMesh::meshSubDir,
127  "faces",
128  IOobject::READ_IF_PRESENT
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"
158  IOobject::NO_READ,
159  runTime.findInstance
160  (
161  polyMesh::meshSubDir,
162  "faces",
163  IOobject::READ_IF_PRESENT
164  )
165  ),
166  polyMesh::meshSubDir/"sets",
167  runTime,
168  IOobject::NO_READ,
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"
193  IOobject::NO_READ,
194  runTime.findInstance
195  (
196  polyMesh::meshSubDir,
197  "faces",
198  IOobject::READ_IF_PRESENT
199  )
200  ),
201  polyMesh::meshSubDir/"sets",
202  runTime,
203  IOobject::NO_READ,
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 
226 {
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 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
readOption
Enumeration defining the read options.
Definition: IOobject.H:117
writeOption
Enumeration defining the write options.
Definition: IOobject.H:126
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A collection of cell labels.
Definition: cellSet.H:51
cellSet(const IOobject &obj)
Construct from IOobject. No checking.
Definition: cellSet.C:48
virtual label maxSize(const polyMesh &mesh) const
Return max index+1.
Definition: cellSet.C:219
virtual ~cellSet()
Destructor.
Definition: cellSet.C:213
virtual void writeDebug(Ostream &os, const primitiveMesh &, const label maxLen) const
Write maxLen items with label and coordinates.
Definition: cellSet.C:232
virtual void topoChange(const polyTopoChangeMap &map)
Update any stored data for new labels.
Definition: cellSet.C:225
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reverseCellMap() const
Reverse cell map.
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:75
label nCells() const
const vectorField & cellCentres() const
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:65
void writeDebug(Ostream &os, const label maxElem, topoSet::const_iterator &iter, label &elemI) const
Write part of contents nicely formatted. Prints labels only.
void check(const label maxLabel)
Check validity of contents.
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:62
Namespace for OpenFOAM.
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
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
defineTypeNameAndDebug(combustionModel, 0)