FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/mapPolyMesh.H>
28 #include <OpenFOAM/polyMesh.H>
29 #include <OpenFOAM/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 
48 cellSet::cellSet(const IOobject& obj)
49 :
50  topoSet(obj, typeName)
51 {}
52 
53 
54 cellSet::cellSet
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 
69 cellSet::cellSet
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 
81 cellSet::cellSet
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 
93 cellSet::cellSet
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)
106 cellSet::cellSet
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(polyMesh::meshSubDir, "faces"),
120  polyMesh::meshSubDir/"sets",
121  runTime,
122  r,
123  w
124  ),
125  typeName
126  )
127 {}
128 
129 
130 cellSet::cellSet
131 (
132  const Time& runTime,
133  const word& name,
134  const label size,
135  writeOption w
136 )
137 :
138  topoSet
139  (
140  IOobject
141  (
142  name,
143  runTime.findInstance(polyMesh::meshSubDir, "faces"),
144  polyMesh::meshSubDir/"sets",
145  runTime,
146  NO_READ,
147  w
148  ),
149  size
150  )
151 {}
152 
153 
154 cellSet::cellSet
155 (
156  const Time& runTime,
157  const word& name,
158  const labelHashSet& set,
159  writeOption w
160 )
161 :
162  topoSet
163  (
164  IOobject
165  (
166  name,
167  runTime.findInstance(polyMesh::meshSubDir, "faces"),
168  polyMesh::meshSubDir/"sets",
169  runTime,
170  NO_READ,
171  w
172  ),
173  set
174  )
175 {}
176 
177 
178 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
179 
181 {}
182 
183 
184 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
185 
186 label cellSet::maxSize(const polyMesh& mesh) const
187 {
188  return mesh.nCells();
189 }
190 
191 
192 void cellSet::updateMesh(const mapPolyMesh& morphMap)
193 {
194  updateLabels(morphMap.reverseCellMap());
195 }
196 
197 
199 (
200  Ostream& os,
201  const primitiveMesh& mesh,
202  const label maxLen
203 ) const
204 {
205  topoSet::writeDebug(os, mesh.cellCentres(), maxLen);
206 }
207 
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 } // End namespace Foam
212 
213 // ************************ vim: set sw=4 sts=4 et: ************************ //