FreeFOAM The Cross-Platform CFD Toolkit
polyPatch.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 "polyPatch.H"
29 #include <OpenFOAM/polyMesh.H>
30 #include <OpenFOAM/primitiveMesh.H>
31 #include <OpenFOAM/SubField.H>
32 #include <OpenFOAM/entry.H>
33 #include <OpenFOAM/dictionary.H>
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40  defineTypeNameAndDebug(polyPatch, 0);
41 
43  (
44  debug::debugSwitch("disallowGenericPolyPatch", 0)
45  );
46 
47  defineRunTimeSelectionTable(polyPatch, word);
48  defineRunTimeSelectionTable(polyPatch, dictionary);
49 
50  addToRunTimeSelectionTable(polyPatch, polyPatch, word);
51  addToRunTimeSelectionTable(polyPatch, polyPatch, dictionary);
52 }
53 
54 
55 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
56 
58 {
60 }
61 
63 {
64  clearAddressing();
65 }
66 
67 
68 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
69 
71 (
72  const word& name,
73  const label size,
74  const label start,
75  const label index,
76  const polyBoundaryMesh& bm
77 )
78 :
79  patchIdentifier(name, index),
81  (
82  faceSubList(bm.mesh().faces(), size, start),
83  bm.mesh().points()
84  ),
85  start_(start),
86  boundaryMesh_(bm),
87  faceCellsPtr_(NULL),
88  mePtr_(NULL)
89 {}
90 
91 
93 (
94  const word& name,
95  const dictionary& dict,
96  const label index,
97  const polyBoundaryMesh& bm
98 )
99 :
100  patchIdentifier(name, dict, index),
102  (
104  (
105  bm.mesh().faces(),
106  readLabel(dict.lookup("nFaces")),
107  readLabel(dict.lookup("startFace"))
108  ),
109  bm.mesh().points()
110  ),
111  start_(readLabel(dict.lookup("startFace"))),
112  boundaryMesh_(bm),
113  faceCellsPtr_(NULL),
114  mePtr_(NULL)
115 {}
116 
117 
119 (
120  const polyPatch& pp,
121  const polyBoundaryMesh& bm
122 )
123 :
124  patchIdentifier(pp),
126  (
128  (
129  bm.mesh().faces(),
130  pp.size(),
131  pp.start()
132  ),
133  bm.mesh().points()
134  ),
135  start_(pp.start()),
136  boundaryMesh_(bm),
137  faceCellsPtr_(NULL),
138  mePtr_(NULL)
139 {}
140 
141 
143 (
144  const polyPatch& pp,
145  const polyBoundaryMesh& bm,
146  const label index,
147  const label newSize,
148  const label newStart
149 )
150 :
151  patchIdentifier(pp, index),
153  (
155  (
156  bm.mesh().faces(),
157  newSize,
158  newStart
159  ),
160  bm.mesh().points()
161  ),
162  start_(newStart),
163  boundaryMesh_(bm),
164  faceCellsPtr_(NULL),
165  mePtr_(NULL)
166 {}
167 
168 
170 :
171  patchIdentifier(p),
172  primitivePatch(p),
173  start_(p.start_),
174  boundaryMesh_(p.boundaryMesh_),
175  faceCellsPtr_(NULL),
176  mePtr_(NULL)
177 {}
178 
179 
180 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
181 
183 {
184  clearAddressing();
185 }
186 
187 
188 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
189 
191 {
193 }
194 
195 
197 {
198  wordList cTypes(dictionaryConstructorTablePtr_->size());
199 
200  label i = 0;
201 
202  for
203  (
204  dictionaryConstructorTable::iterator cstrIter =
205  dictionaryConstructorTablePtr_->begin();
206  cstrIter != dictionaryConstructorTablePtr_->end();
207  ++cstrIter
208  )
209  {
210  if (constraintType(cstrIter.key()))
211  {
212  cTypes[i++] = cstrIter.key();
213  }
214  }
215 
216  cTypes.setSize(i);
217 
218  return cTypes;
219 }
220 
221 
223 {
224  return boundaryMesh_;
225 }
226 
227 
229 {
230  return patchSlice(boundaryMesh().mesh().faceCentres());
231 }
232 
233 
235 {
236  return patchSlice(boundaryMesh().mesh().faceAreas());
237 }
238 
239 
240 // Return the patch face neighbour cell centres
242 {
243  tmp<vectorField> tcc(new vectorField(size()));
244  vectorField& cc = tcc();
245 
246  // get reference to global cell centres
247  const vectorField& gcc = boundaryMesh_.mesh().cellCentres();
248 
249  const unallocLabelList& faceCells = this->faceCells();
250 
251  forAll (faceCells, facei)
252  {
253  cc[facei] = gcc[faceCells[facei]];
254  }
255 
256  return tcc;
257 }
258 
259 
261 {
262  if (!faceCellsPtr_)
263  {
264  faceCellsPtr_ = new labelList::subList
265  (
266  patchSlice(boundaryMesh().mesh().faceOwner())
267  );
268  }
269 
270  return *faceCellsPtr_;
271 }
272 
273 
275 {
276  if (!mePtr_)
277  {
278  mePtr_ =
279  new labelList
280  (
282  (
283  boundaryMesh().mesh().edges(),
284  boundaryMesh().mesh().pointEdges()
285  )
286  );
287  }
288 
289  return *mePtr_;
290 }
291 
292 
294 {
295  deleteDemandDrivenData(faceCellsPtr_);
296  deleteDemandDrivenData(mePtr_);
297 }
298 
299 
301 {
302  os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
304  os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl;
305  os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl;
306 }
307 
308 
310 {}
311 
312 
314 (
315  const primitivePatch&,
316  labelList& faceMap,
317  labelList& rotation
318 ) const
319 {
320  // Nothing changed.
321  return false;
322 }
323 
324 
325 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
326 
328 {
329  clearAddressing();
330 
331  patchIdentifier::operator=(p);
333  start_ = p.start_;
334 }
335 
336 
337 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
338 
340 {
341  p.write(os);
342  os.check("Ostream& operator<<(Ostream& os, const polyPatch& p");
343  return os;
344 }
345 
346 
347 // ************************ vim: set sw=4 sts=4 et: ************************ //