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-2021 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 #include "demandDrivenData.H"
39 
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44  defineTypeNameAndDebug(polyPatch, 0);
45 
47  (
48  debug::debugSwitch("disallowGenericPolyPatch", 0)
49  );
50 
51  defineRunTimeSelectionTable(polyPatch, word);
52  defineRunTimeSelectionTable(polyPatch, dictionary);
53 
54  addToRunTimeSelectionTable(polyPatch, polyPatch, word);
55  addToRunTimeSelectionTable(polyPatch, polyPatch, dictionary);
56 }
57 
58 
59 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
60 
62 {
64 }
65 
66 
68 {
70  clearAddressing();
71 }
72 
73 
75 {
77 }
78 
79 
80 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
81 
83 (
84  const word& name,
85  const label size,
86  const label start,
87  const label index,
88  const polyBoundaryMesh& bm,
89  const word& patchType
90 )
91 :
92  patchIdentifier(name, index),
94  (
95  faceSubList(bm.mesh().faces(), size, start),
96  bm.mesh().points()
97  ),
98  start_(start),
99  boundaryMesh_(bm),
100  faceCellsPtr_(nullptr),
101  mePtr_(nullptr)
102 {
103  if (!patchType.empty() && constraintType(patchType))
104  {
105  inGroups().appendUniq(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_(nullptr),
130  mePtr_(nullptr)
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  dict.get<label>("nFaces"),
150  dict.get<label>("startFace")
151  ),
152  bm.mesh().points()
153  ),
154  start_(dict.get<label>("startFace")),
155  boundaryMesh_(bm),
156  faceCellsPtr_(nullptr),
157  mePtr_(nullptr)
158 {
159  if (!patchType.empty() && constraintType(patchType))
160  {
161  inGroups().appendUniq(patchType);
162  }
163 }
164 
165 
167 (
168  const polyPatch& pp,
169  const polyBoundaryMesh& bm
170 )
171 :
172  patchIdentifier(pp),
174  (
176  (
177  bm.mesh().faces(),
178  pp.size(),
179  pp.start()
180  ),
181  bm.mesh().points()
182  ),
183  start_(pp.start()),
184  boundaryMesh_(bm),
185  faceCellsPtr_(nullptr),
186  mePtr_(nullptr)
187 {}
188 
189 
191 (
192  const polyPatch& pp,
193  const polyBoundaryMesh& bm,
194  const label index,
195  const label newSize,
196  const label newStart
197 )
198 :
199  patchIdentifier(pp, index),
201  (
203  (
204  bm.mesh().faces(),
205  newSize,
206  newStart
207  ),
208  bm.mesh().points()
209  ),
210  start_(newStart),
211  boundaryMesh_(bm),
212  faceCellsPtr_(nullptr),
213  mePtr_(nullptr)
214 {}
215 
216 
218 (
219  const polyPatch& pp,
220  const polyBoundaryMesh& bm,
221  const label index,
222  const labelUList& mapAddressing,
223  const label newStart
224 )
225 :
226  patchIdentifier(pp, index),
228  (
230  (
231  bm.mesh().faces(),
232  mapAddressing.size(),
233  newStart
234  ),
235  bm.mesh().points()
236  ),
237  start_(newStart),
238  boundaryMesh_(bm),
239  faceCellsPtr_(nullptr),
240  mePtr_(nullptr)
241 {}
242 
243 
245 :
247  primitivePatch(p),
248  start_(p.start_),
249  boundaryMesh_(p.boundaryMesh_),
250  faceCellsPtr_(nullptr),
251  mePtr_(nullptr)
252 {}
253 
254 
256 (
257  const polyPatch& p,
258  const labelList& faceCells
259 )
260 :
261  polyPatch(p)
262 {
263  faceCellsPtr_ = new labelList::subList(faceCells, faceCells.size());
264 }
265 
266 
267 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
268 
270 {
271  clearAddressing();
272 }
273 
274 
275 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
276 
278 {
279  return
280  (
283  );
284 }
285 
286 
288 {
289  const auto& cnstrTable = *dictionaryConstructorTablePtr_;
290 
291  wordList cTypes(cnstrTable.size());
292 
293  label i = 0;
294 
295  forAllConstIters(cnstrTable, iter)
296  {
297  if (constraintType(iter.key()))
298  {
299  cTypes[i++] = iter.key();
300  }
301  }
302 
303  cTypes.setSize(i);
304 
305  return cTypes;
306 }
307 
308 
309 Foam::label Foam::polyPatch::offset() const
310 {
311  return start_ - boundaryMesh().start();
312 }
313 
314 
316 {
317  return boundaryMesh_;
318 }
319 
320 
322 {
323  return patchSlice(boundaryMesh().mesh().faceCentres());
324 }
325 
326 
328 {
329  return patchSlice(boundaryMesh().mesh().faceAreas());
330 }
331 
332 
334 {
335  tmp<vectorField> tcc(new vectorField(size()));
336  vectorField& cc = tcc.ref();
337 
338  // get reference to global cell centres
339  const vectorField& gcc = boundaryMesh_.mesh().cellCentres();
340 
341  const labelUList& faceCells = this->faceCells();
342 
343  forAll(faceCells, facei)
344  {
345  cc[facei] = gcc[faceCells[facei]];
346  }
347 
348  return tcc;
349 }
350 
351 
353 {
354  tmp<scalarField> tfraction(new scalarField(size()));
355  scalarField& fraction = tfraction.ref();
356 
357  const vectorField::subField faceAreas = this->faceAreas();
358  const pointField& points = this->points();
359 
360  forAll(*this, facei)
361  {
362  const face& curFace = this->operator[](facei);
363  fraction[facei] =
364  mag(faceAreas[facei])/(curFace.mag(points) + ROOTVSMALL);
365  }
366 
367  return tfraction;
368 }
369 
370 
372 {
373  if (!faceCellsPtr_)
374  {
375  faceCellsPtr_ = new labelList::subList
376  (
377  patchSlice(boundaryMesh().mesh().faceOwner())
378  );
379  }
380 
381  return *faceCellsPtr_;
382 }
383 
384 
386 {
387  if (!mePtr_)
388  {
389  mePtr_ =
390  new labelList
391  (
393  (
394  boundaryMesh().mesh().edges(),
395  boundaryMesh().mesh().pointEdges()
396  )
397  );
398  }
399 
400  return *mePtr_;
401 }
402 
403 
405 {
408  deleteDemandDrivenData(faceCellsPtr_);
409  deleteDemandDrivenData(mePtr_);
410 }
411 
412 
414 {
415  os.writeEntry("type", type());
417  os.writeEntry("nFaces", size());
418  os.writeEntry("startFace", start());
419 }
420 
421 
423 {}
424 
425 
427 (
429  const primitivePatch&,
431  labelList& rotation
432 ) const
433 {
434  // Nothing changed.
435  return false;
436 }
437 
438 
439 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
440 
442 {
443  clearAddressing();
444 
447  start_ = p.start_;
448 }
449 
450 
451 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
452 
454 {
455  p.write(os);
457  return os;
458 }
459 
460 
461 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1069
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::patchIdentifier::operator=
patchIdentifier & operator=(const patchIdentifier &)=default
Copy assignment.
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeTopological.C:94
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
SubField.H
Foam::polyPatch::movePoints
virtual void movePoints(PstreamBuffers &, const pointField &p)
Correct patches after moving points.
Definition: polyPatch.C:61
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:63
polyPatch.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::polyPatch::clearAddressing
virtual void clearAddressing()
Clear addressing.
Definition: polyPatch.C:404
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:112
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:54
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:74
Foam::PrimitivePatch::meshEdges
labelList meshEdges(const edgeList &allEdges, const labelListList &cellEdges, const labelList &faceCells) const
Definition: PrimitivePatchMeshEdges.C:53
Foam::polyPatch::offset
label offset() const
The offset where this patch starts in the boundary face list.
Definition: polyPatch.C:309
Foam::polyPatch::areaFraction
tmp< scalarField > areaFraction() const
Definition: polyPatch.C:352
primitiveMesh.H
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:107
polyMesh.H
Foam::polyPatch::updateMesh
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Definition: polyPatch.C:67
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:296
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, without its own allocation....
Definition: Field.H:64
Foam::deleteDemandDrivenData
void deleteDemandDrivenData(DataPtr &dataPtr)
Definition: demandDrivenData.H:42
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
Foam::patchIdentifier
Identifies a patch by name and index, with optional physical type and group information.
Definition: patchIdentifier.H:55
Foam::polyBoundaryMesh::mesh
const polyMesh & mesh() const noexcept
Return the mesh reference.
Definition: polyBoundaryMesh.H:152
Foam::Field< vector >
Foam::polyPatch::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:315
Foam::polyPatch::operator=
void operator=(const polyPatch &)
Assignment.
Definition: polyPatch.C:441
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::polyPatch::order
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
Definition: polyPatch.C:427
Foam::PrimitivePatch::clearGeom
void clearGeom()
Definition: PrimitivePatchClear.C:35
Foam::polyPatch::constraintTypes
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition: polyPatch.C:287
Foam::polyPatch::constraintType
static bool constraintType(const word &pt)
Return true if the given type is a constraint type.
Definition: polyPatch.C:277
Foam::List::appendUniq
label appendUniq(const T &val)
Append an element if not already in the list.
Definition: ListI.H:232
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::List::subList
SubList< T > subList
Declare type of subList.
Definition: List.H:112
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::polyPatch::write
virtual void write(Ostream &os) const
Write the polyPatch data as a dictionary.
Definition: polyPatch.C:413
os
OBJstream os(runTime.globalPath()/outputName)
Foam::polyPatch::initOrder
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
Definition: polyPatch.C:422
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:371
Foam::PrimitivePatch::clearTopology
void clearTopology()
Definition: PrimitivePatchClear.C:50
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:361
Foam::polyPatch::~polyPatch
virtual ~polyPatch()
Destructor.
Definition: polyPatch.C:269
found
bool found
Definition: TABSMDCalcMethod2.H:32
Foam::polyPatch::faceCellCentres
tmp< vectorField > faceCellCentres() const
Return face cell centres.
Definition: polyPatch.C:333
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:83
Foam::polyMesh::faces
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1094
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
Foam::polyPatch::faceCentres
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:321
Foam::List< word >
Foam::polyPatch::faceAreas
const vectorField::subField faceAreas() const
Return face normals.
Definition: polyPatch.C:327
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
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
polyBoundaryMesh.H
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:295
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:236
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::boundaryMesh
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
Definition: boundaryMesh.H:62
Foam::PrimitivePatch::clearPatchMeshAddr
void clearPatchMeshAddr()
Definition: PrimitivePatchClear.C:73
Foam::patchIdentifier::write
void write(Ostream &os) const
Definition: patchIdentifier.C:96
Foam::primitivePatch
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field.
Definition: primitivePatch.H:51
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
Foam::PrimitivePatch::movePoints
virtual void movePoints(const Field< point_type > &)
Correct patch after moving points.
Definition: PrimitivePatch.C:171
Foam::PrimitivePatch::operator=
void operator=(const PrimitivePatch< FaceList, PointField > &rhs)
Copy assign faces. Leave points alone (could be a reference).
Definition: PrimitivePatch.C:477
Foam::UList::size
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
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:385
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::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:79
Foam::polyPatch::disallowGenericPolyPatch
static int disallowGenericPolyPatch
Debug switch to disallow the use of genericPolyPatch.
Definition: polyPatch.H:130