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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "polyPatch.H"
31 #include "polyBoundaryMesh.H"
32 #include "polyMesh.H"
33 #include "primitiveMesh.H"
34 #include "SubField.H"
35 #include "entry.H"
36 #include "dictionary.H"
37 #include "pointPatchField.H"
38 
39 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 
41 namespace Foam
42 {
43  defineTypeNameAndDebug(polyPatch, 0);
44 
46  (
47  debug::debugSwitch("disallowGenericPolyPatch", 0)
48  );
49 
50  defineRunTimeSelectionTable(polyPatch, word);
51  defineRunTimeSelectionTable(polyPatch, dictionary);
52 
53  addToRunTimeSelectionTable(polyPatch, polyPatch, word);
54  addToRunTimeSelectionTable(polyPatch, polyPatch, dictionary);
55 }
56 
57 
58 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
59 
61 {
63 }
64 
66 {
68  clearAddressing();
69 }
70 
71 
73 {
75 }
76 
77 
78 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
79 
81 (
82  const word& name,
83  const label size,
84  const label start,
85  const label index,
86  const polyBoundaryMesh& bm,
87  const word& patchType
88 )
89 :
90  patchIdentifier(name, index),
92  (
93  faceSubList(bm.mesh().faces(), size, start),
94  bm.mesh().points()
95  ),
96  start_(start),
97  boundaryMesh_(bm),
98  faceCellsPtr_(nullptr),
99  mePtr_(nullptr)
100 {
101  if
102  (
103  patchType != word::null
104  && constraintType(patchType)
105  && !inGroups().found(patchType)
106  )
107  {
108  inGroups().append(patchType);
109  }
110 }
111 
112 
114 (
115  const word& name,
116  const label size,
117  const label start,
118  const label index,
119  const polyBoundaryMesh& bm,
120  const word& physicalType,
121  const wordList& inGroups
122 )
123 :
124  patchIdentifier(name, index, physicalType, inGroups),
126  (
127  faceSubList(bm.mesh().faces(), size, start),
128  bm.mesh().points()
129  ),
130  start_(start),
131  boundaryMesh_(bm),
132  faceCellsPtr_(nullptr),
133  mePtr_(nullptr)
134 {}
135 
136 
138 (
139  const word& name,
140  const dictionary& dict,
141  const label index,
142  const polyBoundaryMesh& bm,
143  const word& patchType
144 )
145 :
146  patchIdentifier(name, dict, index),
148  (
150  (
151  bm.mesh().faces(),
152  dict.get<label>("nFaces"),
153  dict.get<label>("startFace")
154  ),
155  bm.mesh().points()
156  ),
157  start_(dict.get<label>("startFace")),
158  boundaryMesh_(bm),
159  faceCellsPtr_(nullptr),
160  mePtr_(nullptr)
161 {
162  if
163  (
164  patchType != word::null
165  && constraintType(patchType)
166  && !inGroups().found(patchType)
167  )
168  {
169  inGroups().append(patchType);
170  }
171 }
172 
173 
175 (
176  const polyPatch& pp,
177  const polyBoundaryMesh& bm
178 )
179 :
180  patchIdentifier(pp),
182  (
184  (
185  bm.mesh().faces(),
186  pp.size(),
187  pp.start()
188  ),
189  bm.mesh().points()
190  ),
191  start_(pp.start()),
192  boundaryMesh_(bm),
193  faceCellsPtr_(nullptr),
194  mePtr_(nullptr)
195 {}
196 
197 
199 (
200  const polyPatch& pp,
201  const polyBoundaryMesh& bm,
202  const label index,
203  const label newSize,
204  const label newStart
205 )
206 :
207  patchIdentifier(pp, index),
209  (
211  (
212  bm.mesh().faces(),
213  newSize,
214  newStart
215  ),
216  bm.mesh().points()
217  ),
218  start_(newStart),
219  boundaryMesh_(bm),
220  faceCellsPtr_(nullptr),
221  mePtr_(nullptr)
222 {}
223 
224 
226 (
227  const polyPatch& pp,
228  const polyBoundaryMesh& bm,
229  const label index,
230  const labelUList& mapAddressing,
231  const label newStart
232 )
233 :
234  patchIdentifier(pp, index),
236  (
238  (
239  bm.mesh().faces(),
240  mapAddressing.size(),
241  newStart
242  ),
243  bm.mesh().points()
244  ),
245  start_(newStart),
246  boundaryMesh_(bm),
247  faceCellsPtr_(nullptr),
248  mePtr_(nullptr)
249 {}
250 
251 
253 :
255  primitivePatch(p),
256  start_(p.start_),
257  boundaryMesh_(p.boundaryMesh_),
258  faceCellsPtr_(nullptr),
259  mePtr_(nullptr)
260 {}
261 
262 
263 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
264 
266 {
267  clearAddressing();
268 }
269 
270 
271 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
272 
274 {
276 }
277 
278 
280 {
281  wordList cTypes(dictionaryConstructorTablePtr_->size());
282 
283  label i = 0;
284 
285  forAllConstIters(*dictionaryConstructorTablePtr_, cstrIter)
286  {
287  if (constraintType(cstrIter.key()))
288  {
289  cTypes[i++] = cstrIter.key();
290  }
291  }
292 
293  cTypes.setSize(i);
294 
295  return cTypes;
296 }
297 
298 
300 {
301  return start_ - boundaryMesh().start();
302 }
303 
304 
306 {
307  return boundaryMesh_;
308 }
309 
310 
312 {
313  return patchSlice(boundaryMesh().mesh().faceCentres());
314 }
315 
316 
318 {
319  return patchSlice(boundaryMesh().mesh().faceAreas());
320 }
321 
322 
324 {
325  tmp<vectorField> tcc(new vectorField(size()));
326  vectorField& cc = tcc.ref();
327 
328  // get reference to global cell centres
329  const vectorField& gcc = boundaryMesh_.mesh().cellCentres();
330 
331  const labelUList& faceCells = this->faceCells();
332 
333  forAll(faceCells, facei)
334  {
335  cc[facei] = gcc[faceCells[facei]];
336  }
337 
338  return tcc;
339 }
340 
341 
343 {
344  tmp<scalarField> tfraction(new scalarField(size()));
345  scalarField& fraction = tfraction.ref();
346 
347  const vectorField::subField faceAreas = this->faceAreas();
348  const pointField& points = this->points();
349 
350  forAll(*this, facei)
351  {
352  const face& curFace = this->operator[](facei);
353  fraction[facei] =
354  mag(faceAreas[facei])/(curFace.mag(points) + ROOTVSMALL);
355  }
356 
357  return tfraction;
358 }
359 
360 
362 {
363  if (!faceCellsPtr_)
364  {
365  faceCellsPtr_ = new labelList::subList
366  (
367  patchSlice(boundaryMesh().mesh().faceOwner())
368  );
369  }
370 
371  return *faceCellsPtr_;
372 }
373 
374 
376 {
377  if (!mePtr_)
378  {
379  mePtr_ =
380  new labelList
381  (
383  (
384  boundaryMesh().mesh().edges(),
385  boundaryMesh().mesh().pointEdges()
386  )
387  );
388  }
389 
390  return *mePtr_;
391 }
392 
393 
395 {
398  deleteDemandDrivenData(faceCellsPtr_);
399  deleteDemandDrivenData(mePtr_);
400 }
401 
402 
404 {
405  os.writeEntry("type", type());
407  os.writeEntry("nFaces", size());
408  os.writeEntry("startFace", start());
409 }
410 
411 
413 {}
414 
415 
417 (
419  const primitivePatch&,
421  labelList& rotation
422 ) const
423 {
424  // Nothing changed.
425  return false;
426 }
427 
428 
429 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
430 
432 {
433  clearAddressing();
434 
435  patchIdentifier::operator=(p);
437  start_ = p.start_;
438 }
439 
440 
441 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
442 
444 {
445  p.write(os);
446  os.check(FUNCTION_NAME);
447  return os;
448 }
449 
450 
451 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:74
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1038
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::faceSubList
SubList< face > faceSubList
A SubList of faces.
Definition: faceListFwd.H:48
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeFast.C:94
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
SubField.H
Foam::polyPatch::movePoints
virtual void movePoints(PstreamBuffers &, const pointField &p)
Correct patches after moving points.
Definition: polyPatch.C:60
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:62
polyPatch.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::polyPatch::clearAddressing
virtual void clearAddressing()
Clear addressing.
Definition: polyPatch.C:394
Foam::debug::debugSwitch
int debugSwitch(const char *name, const int deflt=0)
Lookup debug switch or add default value.
Definition: debug.C:225
pointPatchField.H
Foam::face::mag
scalar mag(const UList< point > &p) const
Magnitude of face area.
Definition: faceI.H:119
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:88
Foam::polyPatch::clearGeom
virtual void clearGeom()
Clear geometry.
Definition: polyPatch.C:72
Foam::polyPatch::write
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Definition: polyPatch.C:403
Foam::PrimitivePatch::meshEdges
labelList meshEdges(const edgeList &allEdges, const labelListList &cellEdges, const labelList &faceCells) const
Definition: PrimitivePatchMeshEdges.C:43
Foam::polyPatch::offset
label offset() const
The offset where this patch starts in the boundary face list.
Definition: polyPatch.C:299
Foam::polyPatch::areaFraction
tmp< scalarField > areaFraction() const
Definition: polyPatch.C:342
Foam::List::append
void append(const T &val)
Append an element at the end of the list.
Definition: ListI.H:182
primitiveMesh.H
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:81
polyMesh.H
Foam::polyPatch::updateMesh
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Definition: polyPatch.C:65
Foam::pointPatchField
Abstract base class for point-mesh patch fields.
Definition: pointMVCWeight.H:60
entry.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::SubField
SubField is a Field obtained as a section of another Field.
Definition: Field.H:64
Foam::deleteDemandDrivenData
void deleteDemandDrivenData(DataPtr &dataPtr)
Definition: demandDrivenData.H:42
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:258
Foam::patchIdentifier
Identifies a 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:62
Foam::Field< vector >
Foam::polyPatch::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:305
Foam::polyPatch::operator=
void operator=(const polyPatch &)
Assignment.
Definition: polyPatch.C:431
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::polyPatch::order
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
Definition: polyPatch.C:417
Foam::PrimitivePatch::movePoints
virtual void movePoints(const Field< PointType > &)
Correct patch after moving points.
Definition: PrimitivePatch.C:213
Foam::polyBoundaryMesh::mesh
const polyMesh & mesh() const
Return the mesh reference.
Definition: polyBoundaryMesh.H:144
Foam::PrimitivePatch::clearGeom
void clearGeom()
Definition: PrimitivePatchClear.C:43
Foam::polyPatch::constraintTypes
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition: polyPatch.C:279
Foam::polyPatch::constraintType
static bool constraintType(const word &pt)
Return true if the given type is a constraint type.
Definition: polyPatch.C:273
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::List< label >::subList
SubList< label > subList
Declare type of subList.
Definition: List.H:117
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:51
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::polyPatch::initOrder
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
Definition: polyPatch.C:412
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::polyPatch::faceCells
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:361
Foam::PrimitivePatch::clearTopology
void clearTopology()
Definition: PrimitivePatchClear.C:68
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:311
Foam::polyPatch::~polyPatch
virtual ~polyPatch()
Destructor.
Definition: polyPatch.C:265
found
bool found
Definition: TABSMDCalcMethod2.H:32
Foam::polyPatch::faceCellCentres
tmp< vectorField > faceCellCentres() const
Return face cell centres.
Definition: polyPatch.C:323
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:81
Foam::polyMesh::faces
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1063
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
Foam::polyPatch::faceCentres
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:311
Foam::PrimitivePatch::operator=
void operator=(const PrimitivePatch< Face, FaceList, PointField, PointType > &)
Assignment.
Definition: PrimitivePatch.C:620
Foam::List< word >
Foam::polyPatch::faceAreas
const vectorField::subField faceAreas() const
Return face normals.
Definition: polyPatch.C:317
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::start
label ListType::const_reference const label start
Definition: ListOps.H:408
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::UList< label >
points
const pointField & points
Definition: gmvOutputHeader.H:1
dictionary.H
Foam::word::null
static const word null
An empty word.
Definition: word.H:77
polyBoundaryMesh.H
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:261
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:219
Foam::UList::size
void size(const label n) noexcept
Override size to be inconsistent with allocated storage.
Definition: UListI.H:360
Foam::boundaryMesh
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
Definition: boundaryMesh.H:61
Foam::PrimitivePatch::clearPatchMeshAddr
void clearPatchMeshAddr()
Definition: PrimitivePatchClear.C:108
Foam::patchIdentifier::write
void write(Ostream &os) const
Write patchIdentifier as a dictionary.
Definition: patchIdentifier.C:85
Foam::primitivePatch
PrimitivePatch< face, SubList, const pointField & > primitivePatch
Addressing for a faceList slice.
Definition: primitivePatch.H:47
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:74
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::polyPatch::meshEdges
const labelList & meshEdges() const
Return global edge index for local edges.
Definition: polyPatch.C:375
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::faceCells
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:56
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &)
Definition: boundaryPatch.C:102
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:90
Foam::polyPatch::disallowGenericPolyPatch
static int disallowGenericPolyPatch
Debug switch to disallow the use of genericPolyPatch.
Definition: polyPatch.H:131