cellSet.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011 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,
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,
75 )
76 :
77  topoSet(mesh, name, size, w)
78 {}
79 
80 
82 (
83  const polyMesh& mesh,
84  const word& name,
85  const topoSet& set,
87 )
88 :
89  topoSet(mesh, name, set, w)
90 {}
91 
92 
94 (
95  const polyMesh& mesh,
96  const word& name,
97  const labelHashSet& set,
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 
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 // ************************************************************************* //
Foam::topoSet::writeDebug
void writeDebug(Ostream &os, const label maxElem, topoSet::const_iterator &iter, label &elemI) const
Write part of contents nicely formatted. Prints labels only.
Definition: topoSet.C:201
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::cellSet::~cellSet
virtual ~cellSet()
Destructor.
Definition: cellSet.C:213
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
w
volScalarField w(IOobject("w", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE), mesh, dimensionedScalar("w", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0))
Foam::cellSet::cellSet
cellSet(const cellSet &)
Disallow default bitwise copy construct.
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
mapPolyMesh.H
Foam::polyMesh::meshSubDir
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:309
Foam::cellSet::maxSize
virtual label maxSize(const polyMesh &mesh) const
Return max index+1.
Definition: cellSet.C:219
Foam::IOobject::MUST_READ
@ MUST_READ
Definition: IOobject.H:108
Foam::cellSet::writeDebug
virtual void writeDebug(Ostream &os, const primitiveMesh &, const label maxLen) const
Write maxLen items with label and coordinates.
Definition: cellSet.C:232
polyMesh.H
Foam::HashSet< label, Hash< label > >
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::primitiveMesh::nCells
label nCells() const
Definition: primitiveMeshI.H:64
Foam::label
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
Foam::IOobject::NO_READ
@ NO_READ
Definition: IOobject.H:111
Foam::IOobject::writeOption
writeOption
Enumeration defining the write options.
Definition: IOobject.H:115
Foam::topoSet
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::Time::findInstance
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: findInstance.C:38
Foam::mapPolyMesh::reverseCellMap
const labelList & reverseCellMap() const
Reverse cell map.
Definition: mapPolyMesh.H:528
Foam::primitiveMesh::cellCentres
const vectorField & cellCentres() const
Definition: primitiveMeshCellCentresAndVols.C:211
Foam::topoSet::updateLabels
void updateLabels(const labelList &map)
Update map from map. Used to update cell/face labels.
Definition: topoSet.C:137
Foam::cellSet::updateMesh
virtual void updateMesh(const mapPolyMesh &morphMap)
Update any stored data for new labels.
Definition: cellSet.C:225
Foam::word::null
static const word null
An empty word.
Definition: word.H:77
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::IOobject::readOption
readOption
Enumeration defining the read options.
Definition: IOobject.H:106
cellSet.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::IOobject::READ_IF_PRESENT
@ READ_IF_PRESENT
Definition: IOobject.H:110
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::primitiveMesh
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:79