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) 2011-2014 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 "polyPatch.H"
28 #include "polyBoundaryMesh.H"
29 #include "polyMesh.H"
30 #include "primitiveMesh.H"
31 #include "SubField.H"
32 #include "entry.H"
33 #include "dictionary.H"
34 #include "pointPatchField.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 {
65  clearAddressing();
66 }
67 
68 
70 {
72 }
73 
74 
75 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
76 
78 (
79  const word& name,
80  const label size,
81  const label start,
82  const label index,
83  const polyBoundaryMesh& bm,
84  const word& patchType
85 )
86 :
87  patchIdentifier(name, index),
89  (
90  faceSubList(bm.mesh().faces(), size, start),
91  bm.mesh().points()
92  ),
93  start_(start),
94  boundaryMesh_(bm),
95  faceCellsPtr_(NULL),
96  mePtr_(NULL)
97 {
98  if
99  (
100  patchType != word::null
101  && constraintType(patchType)
102  && findIndex(inGroups(), patchType) == -1
103  )
104  {
105  inGroups().append(patchType);
106  }
107 }
108 
109 
111 (
112  const word& name,
113  const label size,
114  const label start,
115  const label index,
116  const polyBoundaryMesh& bm,
117  const word& physicalType,
118  const wordList& inGroups
119 )
120 :
121  patchIdentifier(name, index, physicalType, inGroups),
123  (
124  faceSubList(bm.mesh().faces(), size, start),
125  bm.mesh().points()
126  ),
127  start_(start),
128  boundaryMesh_(bm),
129  faceCellsPtr_(NULL),
130  mePtr_(NULL)
131 {}
132 
133 
135 (
136  const word& name,
137  const dictionary& dict,
138  const label index,
139  const polyBoundaryMesh& bm,
140  const word& patchType
141 )
142 :
143  patchIdentifier(name, dict, index),
145  (
147  (
148  bm.mesh().faces(),
149  readLabel(dict.lookup("nFaces")),
150  readLabel(dict.lookup("startFace"))
151  ),
152  bm.mesh().points()
153  ),
154  start_(readLabel(dict.lookup("startFace"))),
155  boundaryMesh_(bm),
156  faceCellsPtr_(NULL),
157  mePtr_(NULL)
158 {
159  if
160  (
161  patchType != word::null
162  && constraintType(patchType)
163  && findIndex(inGroups(), patchType) == -1
164  )
165  {
166  inGroups().append(patchType);
167  }
168 }
169 
170 
172 (
173  const polyPatch& pp,
174  const polyBoundaryMesh& bm
175 )
176 :
177  patchIdentifier(pp),
179  (
181  (
182  bm.mesh().faces(),
183  pp.size(),
184  pp.start()
185  ),
186  bm.mesh().points()
187  ),
188  start_(pp.start()),
189  boundaryMesh_(bm),
190  faceCellsPtr_(NULL),
191  mePtr_(NULL)
192 {}
193 
194 
196 (
197  const polyPatch& pp,
198  const polyBoundaryMesh& bm,
199  const label index,
200  const label newSize,
201  const label newStart
202 )
203 :
204  patchIdentifier(pp, index),
206  (
208  (
209  bm.mesh().faces(),
210  newSize,
211  newStart
212  ),
213  bm.mesh().points()
214  ),
215  start_(newStart),
216  boundaryMesh_(bm),
217  faceCellsPtr_(NULL),
218  mePtr_(NULL)
219 {}
220 
221 
223 (
224  const polyPatch& pp,
225  const polyBoundaryMesh& bm,
226  const label index,
227  const labelUList& mapAddressing,
228  const label newStart
229 )
230 :
231  patchIdentifier(pp, index),
233  (
235  (
236  bm.mesh().faces(),
237  mapAddressing.size(),
238  newStart
239  ),
240  bm.mesh().points()
241  ),
242  start_(newStart),
243  boundaryMesh_(bm),
244  faceCellsPtr_(NULL),
245  mePtr_(NULL)
246 {}
247 
248 
250 :
252  primitivePatch(p),
253  start_(p.start_),
254  boundaryMesh_(p.boundaryMesh_),
255  faceCellsPtr_(NULL),
256  mePtr_(NULL)
257 {}
258 
259 
260 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
261 
263 {
264  clearAddressing();
265 }
266 
267 
268 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
269 
271 {
273 }
274 
275 
277 {
278  wordList cTypes(dictionaryConstructorTablePtr_->size());
279 
280  label i = 0;
281 
282  for
283  (
284  dictionaryConstructorTable::iterator cstrIter =
285  dictionaryConstructorTablePtr_->begin();
286  cstrIter != dictionaryConstructorTablePtr_->end();
287  ++cstrIter
288  )
289  {
290  if (constraintType(cstrIter.key()))
291  {
292  cTypes[i++] = cstrIter.key();
293  }
294  }
295 
296  cTypes.setSize(i);
297 
298  return cTypes;
299 }
300 
301 
303 {
304  return boundaryMesh_;
305 }
306 
307 
309 {
310  return patchSlice(boundaryMesh().mesh().faceCentres());
311 }
312 
313 
315 {
316  return patchSlice(boundaryMesh().mesh().faceAreas());
317 }
318 
319 
320 // Return the patch face neighbour cell centres
322 {
323  tmp<vectorField> tcc(new vectorField(size()));
324  vectorField& cc = tcc();
325 
326  // get reference to global cell centres
327  const vectorField& gcc = boundaryMesh_.mesh().cellCentres();
328 
329  const labelUList& faceCells = this->faceCells();
330 
331  forAll(faceCells, facei)
332  {
333  cc[facei] = gcc[faceCells[facei]];
334  }
335 
336  return tcc;
337 }
338 
339 
341 {
342  if (!faceCellsPtr_)
343  {
344  faceCellsPtr_ = new labelList::subList
345  (
346  patchSlice(boundaryMesh().mesh().faceOwner())
347  );
348  }
349 
350  return *faceCellsPtr_;
351 }
352 
353 
355 {
356  if (!mePtr_)
357  {
358  mePtr_ =
359  new labelList
360  (
362  (
363  boundaryMesh().mesh().edges(),
364  boundaryMesh().mesh().pointEdges()
365  )
366  );
367  }
368 
369  return *mePtr_;
370 }
371 
372 
374 {
377  deleteDemandDrivenData(faceCellsPtr_);
378  deleteDemandDrivenData(mePtr_);
379 }
380 
381 
383 {
384  os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
386  os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl;
387  os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl;
388 }
389 
390 
392 {}
393 
394 
396 (
398  const primitivePatch&,
400  labelList& rotation
401 ) const
402 {
403  // Nothing changed.
404  return false;
405 }
406 
407 
408 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
409 
411 {
412  clearAddressing();
413 
414  patchIdentifier::operator=(p);
416  start_ = p.start_;
417 }
418 
419 
420 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
421 
423 {
424  p.write(os);
425  os.check("Ostream& operator<<(Ostream& os, const polyPatch& p");
426  return os;
427 }
428 
429 
430 // ************************************************************************* //
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:979
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeFast.C:90
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
SubField.H
Foam::labelList
List< label > labelList
A List of labels.
Definition: labelList.H:56
Foam::polyPatch::movePoints
virtual void movePoints(PstreamBuffers &, const pointField &p)
Correct patches after moving points.
Definition: polyPatch.C:57
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
polyPatch.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::findIndex
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
Foam::polyPatch::clearAddressing
virtual void clearAddressing()
Clear addressing.
Definition: polyPatch.C:373
pointPatchField.H
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:53
Foam::PstreamBuffers
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Definition: PstreamBuffers.H:85
Foam::polyPatch::clearGeom
virtual void clearGeom()
Clear geometry.
Definition: polyPatch.C:69
Foam::polyPatch::write
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Definition: polyPatch.C:382
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::PrimitivePatch::meshEdges
labelList meshEdges(const edgeList &allEdges, const labelListList &cellEdges, const labelList &faceCells) const
Return labels of patch edges in the global edge list using.
Definition: PrimitivePatchMeshEdges.C:41
Foam::primitivePatch
PrimitivePatch< face, SubList, const pointField & > primitivePatch
Foam::primitivePatch.
Definition: primitivePatch.H:45
polyMesh.H
Foam::polyPatch::updateMesh
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Definition: polyPatch.C:62
Foam::pointPatchField
Abstract base class for point-mesh patch fields.
Definition: pointMVCWeight.H:58
entry.H
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:49
Foam::SubField
Pre-declare related SubField type.
Definition: Field.H:61
Foam::deleteDemandDrivenData
void deleteDemandDrivenData(DataPtr &dataPtr)
Definition: demandDrivenData.H:40
Foam::patchIdentifier
Identifies patch by name, patch index and physical type.
Definition: patchIdentifier.H:57
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::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::polyPatch::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:302
Foam::List::append
void append(const T &)
Append an element at the end of the list.
Foam::polyPatch::operator=
void operator=(const polyPatch &)
Assignment.
Definition: polyPatch.C:410
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::polyPatch::order
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
Definition: polyPatch.C:396
Foam::PrimitivePatch::movePoints
virtual void movePoints(const Field< PointType > &)
Correct patch after moving points.
Definition: PrimitivePatchTemplate.C:187
Foam::polyBoundaryMesh::mesh
const polyMesh & mesh() const
Return the mesh reference.
Definition: polyBoundaryMesh.H:140
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
Foam::PrimitivePatch::clearGeom
void clearGeom()
Definition: PrimitivePatchClear.C:40
Foam::polyPatch::constraintTypes
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition: polyPatch.C:276
Foam::polyPatch::constraintType
static bool constraintType(const word &pt)
Return true if the given type is a constraint type.
Definition: polyPatch.C:270
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::List::subList
SubList< T > subList
Declare type of subList.
Definition: List.H:153
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::polyPatch::initOrder
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
Definition: polyPatch.C:391
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::polyPatch::faceCells
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:340
Foam::PrimitivePatch::clearTopology
void clearTopology()
Definition: PrimitivePatchClear.C:65
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:312
Foam::polyPatch::~polyPatch
virtual ~polyPatch()
Destructor.
Definition: polyPatch.C:262
Foam::debug::debugSwitch
int debugSwitch(const char *name, const int defaultValue=0)
Lookup debug switch or add default value.
Definition: debug.C:164
Foam::faceSubList
SubList< face > faceSubList
Definition: faceListFwd.H:44
Foam::polyPatch::faceCellCentres
tmp< vectorField > faceCellCentres() const
Return face cell centres.
Definition: polyPatch.C:321
Foam::List::setSize
void setSize(const label)
Reset size of List.
Foam::polyPatch::polyPatch
polyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType)
Construct from components.
Definition: polyPatch.C:78
Foam::polyMesh::faces
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1004
Foam::polyPatch::faceCentres
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:308
Foam::PrimitivePatch::operator=
void operator=(const PrimitivePatch< Face, FaceList, PointField, PointType > &)
Assignment.
Definition: PrimitivePatchTemplate.C:563
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::polyPatch::faceAreas
const vectorField::subField faceAreas() const
Return face normals.
Definition: polyPatch.C:314
Foam::Ostream::writeKeyword
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
dictionary.H
Foam::word::null
static const word null
An empty word.
Definition: word.H:77
polyBoundaryMesh.H
Foam::readLabel
label readLabel(Istream &is)
Definition: label.H:64
Foam::boundaryMesh
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
Definition: boundaryMesh.H:59
Foam::PrimitivePatch::clearPatchMeshAddr
void clearPatchMeshAddr()
Definition: PrimitivePatchClear.C:107
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::UList::size
label size() const
Return the number of elements in the UList.
Definition: UListI.H:299
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::polyPatch::meshEdges
const labelList & meshEdges() const
Return global edge index for local edges.
Definition: polyPatch.C:354
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::patchIdentifier::write
void write(Ostream &) const
Write patchIdentifier as a dictionary.
Definition: patchIdentifier.C:89
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatchTemplate.H:88
Foam::polyPatch::disallowGenericPolyPatch
static int disallowGenericPolyPatch
Debug switch to disallow the use of genericPolyPatch.
Definition: polyPatch.H:131