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-2020 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
104  (
105  patchType != word::null
106  && constraintType(patchType)
107  && !inGroups().found(patchType)
108  )
109  {
110  inGroups().append(patchType);
111  }
112 }
113 
114 
116 (
117  const word& name,
118  const label size,
119  const label start,
120  const label index,
121  const polyBoundaryMesh& bm,
122  const word& physicalType,
123  const wordList& inGroups
124 )
125 :
126  patchIdentifier(name, index, physicalType, inGroups),
128  (
129  faceSubList(bm.mesh().faces(), size, start),
130  bm.mesh().points()
131  ),
132  start_(start),
133  boundaryMesh_(bm),
134  faceCellsPtr_(nullptr),
135  mePtr_(nullptr)
136 {}
137 
138 
140 (
141  const word& name,
142  const dictionary& dict,
143  const label index,
144  const polyBoundaryMesh& bm,
145  const word& patchType
146 )
147 :
148  patchIdentifier(name, dict, index),
150  (
152  (
153  bm.mesh().faces(),
154  dict.get<label>("nFaces"),
155  dict.get<label>("startFace")
156  ),
157  bm.mesh().points()
158  ),
159  start_(dict.get<label>("startFace")),
160  boundaryMesh_(bm),
161  faceCellsPtr_(nullptr),
162  mePtr_(nullptr)
163 {
164  if
165  (
166  patchType != word::null
167  && constraintType(patchType)
168  && !inGroups().found(patchType)
169  )
170  {
171  inGroups().append(patchType);
172  }
173 }
174 
175 
177 (
178  const polyPatch& pp,
179  const polyBoundaryMesh& bm
180 )
181 :
182  patchIdentifier(pp),
184  (
186  (
187  bm.mesh().faces(),
188  pp.size(),
189  pp.start()
190  ),
191  bm.mesh().points()
192  ),
193  start_(pp.start()),
194  boundaryMesh_(bm),
195  faceCellsPtr_(nullptr),
196  mePtr_(nullptr)
197 {}
198 
199 
201 (
202  const polyPatch& pp,
203  const polyBoundaryMesh& bm,
204  const label index,
205  const label newSize,
206  const label newStart
207 )
208 :
209  patchIdentifier(pp, index),
211  (
213  (
214  bm.mesh().faces(),
215  newSize,
216  newStart
217  ),
218  bm.mesh().points()
219  ),
220  start_(newStart),
221  boundaryMesh_(bm),
222  faceCellsPtr_(nullptr),
223  mePtr_(nullptr)
224 {}
225 
226 
228 (
229  const polyPatch& pp,
230  const polyBoundaryMesh& bm,
231  const label index,
232  const labelUList& mapAddressing,
233  const label newStart
234 )
235 :
236  patchIdentifier(pp, index),
238  (
240  (
241  bm.mesh().faces(),
242  mapAddressing.size(),
243  newStart
244  ),
245  bm.mesh().points()
246  ),
247  start_(newStart),
248  boundaryMesh_(bm),
249  faceCellsPtr_(nullptr),
250  mePtr_(nullptr)
251 {}
252 
253 
255 :
257  primitivePatch(p),
258  start_(p.start_),
259  boundaryMesh_(p.boundaryMesh_),
260  faceCellsPtr_(nullptr),
261  mePtr_(nullptr)
262 {}
263 
264 
265 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
266 
268 {
269  clearAddressing();
270 }
271 
272 
273 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
274 
276 {
278 }
279 
280 
282 {
283  wordList cTypes(dictionaryConstructorTablePtr_->size());
284 
285  label i = 0;
286 
287  forAllConstIters(*dictionaryConstructorTablePtr_, cstrIter)
288  {
289  if (constraintType(cstrIter.key()))
290  {
291  cTypes[i++] = cstrIter.key();
292  }
293  }
294 
295  cTypes.setSize(i);
296 
297  return cTypes;
298 }
299 
300 
301 Foam::label Foam::polyPatch::offset() const
302 {
303  return start_ - boundaryMesh().start();
304 }
305 
306 
308 {
309  return boundaryMesh_;
310 }
311 
312 
314 {
315  return patchSlice(boundaryMesh().mesh().faceCentres());
316 }
317 
318 
320 {
321  return patchSlice(boundaryMesh().mesh().faceAreas());
322 }
323 
324 
326 {
327  tmp<vectorField> tcc(new vectorField(size()));
328  vectorField& cc = tcc.ref();
329 
330  // get reference to global cell centres
331  const vectorField& gcc = boundaryMesh_.mesh().cellCentres();
332 
333  const labelUList& faceCells = this->faceCells();
334 
335  forAll(faceCells, facei)
336  {
337  cc[facei] = gcc[faceCells[facei]];
338  }
339 
340  return tcc;
341 }
342 
343 
345 {
346  tmp<scalarField> tfraction(new scalarField(size()));
347  scalarField& fraction = tfraction.ref();
348 
349  const vectorField::subField faceAreas = this->faceAreas();
350  const pointField& points = this->points();
351 
352  forAll(*this, facei)
353  {
354  const face& curFace = this->operator[](facei);
355  fraction[facei] =
356  mag(faceAreas[facei])/(curFace.mag(points) + ROOTVSMALL);
357  }
358 
359  return tfraction;
360 }
361 
362 
364 {
365  if (!faceCellsPtr_)
366  {
367  faceCellsPtr_ = new labelList::subList
368  (
369  patchSlice(boundaryMesh().mesh().faceOwner())
370  );
371  }
372 
373  return *faceCellsPtr_;
374 }
375 
376 
378 {
379  if (!mePtr_)
380  {
381  mePtr_ =
382  new labelList
383  (
385  (
386  boundaryMesh().mesh().edges(),
387  boundaryMesh().mesh().pointEdges()
388  )
389  );
390  }
391 
392  return *mePtr_;
393 }
394 
395 
397 {
400  deleteDemandDrivenData(faceCellsPtr_);
401  deleteDemandDrivenData(mePtr_);
402 }
403 
404 
406 {
407  os.writeEntry("type", type());
409  os.writeEntry("nFaces", size());
410  os.writeEntry("startFace", start());
411 }
412 
413 
415 {}
416 
417 
419 (
421  const primitivePatch&,
423  labelList& rotation
424 ) const
425 {
426  // Nothing changed.
427  return false;
428 }
429 
430 
431 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
432 
434 {
435  clearAddressing();
436 
439  start_ = p.start_;
440 }
441 
442 
443 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
444 
446 {
447  p.write(os);
448  os.check(FUNCTION_NAME);
449  return os;
450 }
451 
452 
453 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
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:62
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:62
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:396
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:130
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:53
Foam::PstreamBuffers
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Definition: PstreamBuffers.H:87
Foam::polyPatch::clearGeom
virtual void clearGeom()
Clear geometry.
Definition: polyPatch.C:74
Foam::polyPatch::write
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Definition: polyPatch.C:405
Foam::PrimitivePatch::meshEdges
labelList meshEdges(const edgeList &allEdges, const labelListList &cellEdges, const labelList &faceCells) const
Definition: PrimitivePatchMeshEdges.C:37
Foam::polyPatch::offset
label offset() const
The offset where this patch starts in the boundary face list.
Definition: polyPatch.C:301
Foam::polyPatch::areaFraction
tmp< scalarField > areaFraction() const
Definition: polyPatch.C:344
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: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.
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:228
Foam::patchIdentifier
Identifies a patch by name, patch index and physical type.
Definition: patchIdentifier.H:54
Foam::Field< vector >
Foam::polyPatch::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:307
Foam::polyPatch::operator=
void operator=(const polyPatch &)
Assignment.
Definition: polyPatch.C:433
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
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:419
Foam::polyBoundaryMesh::mesh
const polyMesh & mesh() const
Return the mesh reference.
Definition: polyBoundaryMesh.H:144
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:281
Foam::polyPatch::constraintType
static bool constraintType(const word &pt)
Return true if the given type is a constraint type.
Definition: polyPatch.C:275
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::List< label >::subList
SubList< label > subList
Declare type of subList.
Definition: List.H:114
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:414
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:363
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:313
Foam::polyPatch::~polyPatch
virtual ~polyPatch()
Destructor.
Definition: polyPatch.C:267
found
bool found
Definition: TABSMDCalcMethod2.H:32
Foam::polyPatch::faceCellCentres
tmp< vectorField > faceCellCentres() const
Return face cell centres.
Definition: polyPatch.C:325
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:313
Foam::List< word >
Foam::polyPatch::faceAreas
const vectorField::subField faceAreas() const
Return face normals.
Definition: polyPatch.C:319
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
Foam::word::null
static const word null
An empty word.
Definition: word.H:77
polyBoundaryMesh.H
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:270
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:232
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: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:172
Foam::PrimitivePatch::operator=
void operator=(const PrimitivePatch< FaceList, PointField > &rhs)
Copy assign faces. Leave points alone (could be a reference).
Definition: PrimitivePatch.C:457
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:377
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:85
Foam::polyPatch::disallowGenericPolyPatch
static int disallowGenericPolyPatch
Debug switch to disallow the use of genericPolyPatch.
Definition: polyPatch.H:133